/* Skuteu Sense, mengikuti desain di kanvas "Roast Advisor App". */
:root {
  --bg: #f3f1ee;
  --panel: #ffffff;
  --panel-2: #f6f4f1;
  --ink: #1c1a17;
  --ink-2: #4a443e;
  --muted: #5e5852;
  --line: #d6d0c9;
  --accent: #b4501a;
  --sense: #1f6f6a;
  --sense-soft: #dcebe9;
  --fc: #e8a317;
  --drop: #2d3f8f;
  --danger: #b3261e;
  --warn-bg: #fbeccf;
  --warn-ink: #6b4200;
  --dark: #1c1a17;
  --dark-2: #2b2824;
  --dark-muted: #b8b0a7;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--sense); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.two-col { display: flex; flex-direction: column; gap: 12px; }
details.card summary { cursor: pointer; font-weight: 600; min-height: 32px; }
label.field input, label.field textarea { width: 100%; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

#app {
  max-width: 1280px; margin: 0 auto; min-height: 100%;
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0 12px; }
.topbar .left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
h1 { margin: 0; font-size: 24px; line-height: 1.2; font-weight: 700; text-wrap: balance; }
h2 { margin: 0; font-size: 14px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.card { background: var(--panel); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card.sense { border: 2px solid var(--sense); }
.card.dark { background: var(--dark); color: #f3f1ee; }
.note { margin: 0; font-size: 13px; color: var(--muted); }
.warn { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-ink); font-size: 13px; line-height: 1.45; }
.ok-text { color: var(--sense); font-weight: 600; }
.err-text { color: var(--danger); font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 6px 10px; border-radius: 999px; background: #e3ded8; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.on { background: var(--sense-soft); color: #154f4b; }
.pill.on .dot { background: var(--sense); }
.pill.err { background: #f6dcd9; color: #7d1a14; }
.pill.err .dot { background: var(--danger); }

label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); min-width: 0; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: #faf9f7; color: var(--ink); font-size: 15px; width: 100%; min-width: 0;
}
textarea { padding: 10px 12px; resize: vertical; }
input.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
input.changed { border: 2px solid #8a4b0f; background: #fbf3ea; font-weight: 600; }

.btn { min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.sense { background: var(--sense); color: #fff; border-color: var(--sense); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.icon { width: 44px; min-height: 44px; padding: 0; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.dashed { border-style: dashed; background: transparent; font-weight: 500; color: var(--ink-2); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 4px; background: #efebe6; border-radius: 10px; }
.seg button { min-height: 40px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font-size: 14px; }
.seg button[aria-pressed=true] { background: var(--accent); color: #fff; font-weight: 600; }
.seg.sense button[aria-pressed=true] { background: var(--sense); }
.seg.dark button[aria-pressed=true] { background: var(--ink); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: #faf9f7; font-size: 14px; }
.chip[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.tag { padding: 3px 8px; border-radius: 6px; background: #efebe6; font-size: 12px; }

/* Bean list */
.beans { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.bean { display: flex; flex-direction: column; gap: 10px; padding: 14px; background: var(--panel); border: 1px solid #e3ded8; border-radius: 12px; text-align: left; width: 100%; }
.bean.selected { border: 2px solid var(--accent); }
.bean .stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; font-size: 12px; color: var(--muted); }
.bean .stats b { display: block; font-family: var(--mono); font-size: 14px; color: var(--ink); }

/* Profile spectrum */
.spectrum-bar { height: 12px; border-radius: 999px; background: linear-gradient(90deg, #dcc59b 0%, #c08a4a 30%, #7a4a26 55%, #4a2c1a 78%, #1a120d 100%); }
.spectrum { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.spectrum label { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; font-size: 11px; line-height: 1.3; color: var(--muted); padding: 6px 2px; border-radius: 8px; cursor: pointer; }
.spectrum label b { font-size: 12px; color: var(--ink); }
.spectrum label:has(input:checked) { background: #f6efe6; outline: 2px solid var(--accent); }
.spectrum input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }

/* Recipe steps */
.phase { padding: 12px; border-radius: 10px; background: var(--panel-2); display: flex; flex-direction: column; gap: 8px; }
.phase-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.phase-name { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; }
.phase-dot { width: 10px; height: 10px; border-radius: 50%; }
.step-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) minmax(0, 1fr) 40px; gap: 6px; align-items: center; }
.step-row input { min-height: 40px; padding: 0 8px; font-family: var(--mono); font-size: 13px; }
.step-head { font-size: 11px; color: var(--muted); }

/* Live */
.live { display: flex; flex-direction: column; gap: 12px; }
.readings { background: var(--dark); color: #f3f1ee; border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.readings .big { font-family: var(--mono); font-size: 56px; font-weight: 600; line-height: 1; color: var(--accent); }
.readings .big small { font-size: 24px; color: var(--dark-muted); }
.readings .time { font-family: var(--mono); font-size: 32px; font-weight: 600; line-height: 1; }
.readings .lbl { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--dark-muted); }
.tile { padding: 8px; border-radius: 8px; background: var(--dark-2); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile span { font-size: 11px; color: var(--dark-muted); }
.tile b { font-family: var(--mono); font-size: 17px; font-weight: 600; }
.chart-card { background: var(--panel); border-radius: 12px; padding: 12px; }
.chart-card canvas { width: 100%; height: 220px; display: block; }
.bigbtns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.bigbtn { min-height: 96px; border: 0; border-radius: 14px; font-size: 20px; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.bigbtn small { font-size: 12px; font-weight: 500; }
.bigbtn.fc { background: var(--fc); color: var(--ink); }
.bigbtn.drop { background: var(--drop); color: #fff; }
.bigbtn.charge { background: var(--accent); color: #fff; grid-column: 1 / -1; }
.estop { width: 100%; min-height: 56px; border: 0; border-radius: 12px; background: var(--danger); color: #fff; font-size: 17px; font-weight: 700; }
.progress { height: 6px; border-radius: 999px; background: #ece8e3; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); }
.raw { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 160px; overflow: auto; margin: 0; }

.toast { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 50; max-width: calc(100% - 32px); }
.banner-offline { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; }

/* Tablet: two columns */
@media (min-width: 768px) {
  .two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
  .live.wide { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
  .chart-card canvas { height: 380px; }
}
/* Phone landscape: three columns, buttons always visible */
@media (max-height: 500px) and (orientation: landscape) {
  .live.wide { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 10px; }
  .readings .big { font-size: 44px; }
  .chart-card canvas { height: 230px; }
  .bigbtn { min-height: 72px; font-size: 17px; }
  .topbar { padding: 8px 0; }
}
.app-ver { margin-top: 20px; text-align: center; font-size: 12px; color: var(--muted); font-family: var(--mono); }
