:root {
  color-scheme: light;
  --ink: #1d2c25;
  --muted: #78847c;
  --line: #e7eae4;
  --paper: #fff;
  --canvas: #f5f6f1;
  --green: #245c43;
  --green-deep: #173c2c;
  --mint: #eaf2eb;
  --gold: #c99348;
  --gold-bg: #f8f2e7;
  --red: #a64b3c;
  --shadow: 0 15px 40px rgb(26 45 34 / 6%);
  font-family: "Segoe UI", ui-sans-serif, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, label { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
.app-shell { width: min(1190px, calc(100% - 56px)); margin: 0 auto; }
.topbar { height: 75px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e8ebe4; }
.brand { display: flex; gap: 10px; align-items: center; color: var(--ink); text-decoration: none; font-family: "Segoe UI", ui-sans-serif, system-ui, sans-serif; font-size: 19px; font-weight: 800; letter-spacing: -0.07em; }
.brand-mark { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 10px 10px 10px 4px; background: var(--green); color: white; font-size: 16px; }
.brand-period { color: var(--gold); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.privacy-note { margin-right: 10px; color: var(--muted); font-size: 11px; }
.privacy-dot { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: #68a479; }
.privacy-dot.sync-error { background: #bd5b4b; }
.sync-status-error { color: var(--red); }
.auth-panel { width: min(460px, 100%); margin: 70px auto; padding: 26px; }
.auth-panel h1 { font-size: 25px; }
.auth-description { margin: 0 0 18px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.auth-submit { width: 100%; margin-top: 18px; }
.auth-submit:disabled { cursor: wait; opacity: .7; }
.auth-message { min-height: 18px; margin: 12px 0 0; color: var(--green); font-size: 11px; line-height: 1.5; }
.auth-message.error { color: var(--red); }
.button { min-height: 38px; padding: 0 13px; border: 1px solid transparent; border-radius: 9px; display: inline-flex; gap: 7px; align-items: center; justify-content: center; font-size: 12px; font-weight: 650; transition: background .15s, border-color .15s, transform .15s; }
.button:active { transform: translateY(1px); }
.button-primary { border-color: var(--green); background: var(--green); color: white; box-shadow: 0 3px 8px rgb(36 92 67 / 15%); }
.button-primary:hover { background: var(--green-deep); }
.button-quiet { border-color: var(--line); background: var(--paper); color: #536159; }
.button-quiet:hover, .button-outline:hover { border-color: #b7c8b9; background: #f6f9f5; }
.button-outline { border-color: #dce5dc; background: white; color: var(--green); }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding: 38px 0 24px; }
.eyebrow { margin: 0 0 6px; color: #728078; font-size: 9px; font-weight: 700; letter-spacing: .14em; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: "Segoe UI", ui-sans-serif, system-ui, sans-serif; }
h1 { margin-bottom: 5px; font-size: clamp(24px, 3.2vw, 32px); line-height: 1.2; letter-spacing: -.055em; }
.page-intro { margin: 0; color: var(--muted); font-size: 12px; }
.summary-grid { display: grid; grid-template-columns: .8fr .8fr 1.4fr 1.2fr; gap: 13px; margin-bottom: 17px; }
.summary-card, .panel, .detail-card { border: 1px solid var(--line); border-radius: 13px; background: var(--paper); box-shadow: var(--shadow); }
.summary-card { min-height: 96px; padding: 15px 17px; display: grid; grid-template-columns: 1fr auto; align-items: start; }
.summary-label { grid-column: 1 / -1; color: #818c85; font-size: 9px; font-weight: 700; letter-spacing: .11em; }
.summary-card strong { align-self: center; font-family: "Segoe UI", ui-sans-serif, system-ui, sans-serif; font-size: 24px; letter-spacing: -.06em; }
.summary-foot { align-self: center; justify-self: end; color: #879189; font-size: 10px; }
.summary-latest { max-width: 290px; overflow: hidden; font-size: 18px !important; text-overflow: ellipsis; white-space: nowrap; }
.workspace-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); align-items: start; gap: 16px; }
.sidebar, .main-column { display: grid; gap: 15px; }
.panel { padding: 17px; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.section-title-row .eyebrow { margin-bottom: 3px; }
.section-title-row h2 { margin: 0; font-size: 15px; letter-spacing: -.04em; }
.count-pill { min-width: 24px; height: 24px; padding: 0 7px; display: grid; place-items: center; border-radius: 30px; background: #f2f4ef; color: #68756c; font-size: 10px; font-weight: 700; }
.brew-list { display: grid; gap: 7px; max-height: 260px; overflow: auto; }
.brew-list-empty { padding: 15px 9px 18px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.brew-item { width: 100%; padding: 10px 10px; border: 1px solid transparent; border-radius: 9px; display: flex; align-items: center; gap: 10px; background: transparent; color: var(--ink); text-align: left; }
.brew-item:hover { background: #f7f8f5; }
.brew-item.selected { border-color: #d9e7da; background: #f0f6f0; }
.brew-avatar { width: 31px; height: 31px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 9px; background: var(--gold-bg); color: #9c6d32; font-size: 14px; }
.brew-item.selected .brew-avatar { background: #dfece0; color: var(--green); }
.brew-item-copy { min-width: 0; display: grid; gap: 3px; }
.brew-item-name { overflow: hidden; font-size: 11px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.brew-item-meta { color: var(--muted); font-size: 9px; }
.new-brew-sidebar { width: 100%; margin-top: 11px; }
.tools-panel { padding-bottom: 15px; }
.calculator-block + .calculator-block { margin-top: 17px; padding-top: 15px; border-top: 1px solid #edf0ea; }
.calculator-block h3 { margin-bottom: 10px; font-size: 12px; letter-spacing: -.02em; }
.converter-fields { display: grid; grid-template-columns: 1fr 20px 1fr; gap: 7px; align-items: end; }
.converter-fields label { min-width: 0; display: grid; gap: 5px; color: var(--muted); font-size: 9px; font-weight: 700; }
.converter-fields input { width: 100%; min-width: 0; height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: #fcfdfa; color: var(--ink); font-size: 12px; }
.convert-arrow { padding-bottom: 9px; color: #99a39b; text-align: center; }
.helper-text { margin: 7px 0 0; color: #879189; font-size: 10px; line-height: 1.5; }
.settings-button { min-height: 32px; padding: 0 9px; font-size: 10px; }
.water-results { margin-top: 11px; padding: 10px; border-radius: 9px; background: #f5f7f3; color: #728078; font-size: 10px; line-height: 1.5; }
.water-results.has-data { display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; color: var(--ink); }
.water-results strong { font-size: 10px; }
.water-results b { color: var(--green); font-size: 11px; }
.tiny-note { margin: 7px 0 0; color: #929b94; font-size: 9px; line-height: 1.45; }
.detail-card { padding: 21px; }
.detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding-bottom: 15px; border-bottom: 1px solid #edf0ea; }
.detail-title { min-width: 0; }
.detail-title h2 { overflow-wrap: anywhere; margin: 0 0 4px; font-size: 21px; letter-spacing: -.055em; }
.detail-subtitle { margin: 0; color: var(--muted); font-size: 10px; }
.detail-actions { display: flex; flex: 0 0 auto; gap: 7px; }
.status-chip { display: inline-flex; align-items: center; gap: 5px; margin-top: 8px; padding: 4px 8px; border-radius: 30px; background: #edf4ed; color: var(--green); font-size: 9px; font-weight: 700; }
.status-chip.finished { background: #f7f0e4; color: #88612c; }
.detail-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; padding: 16px 0; }
.metric { min-width: 0; padding: 11px 10px; border: 1px solid #edf0ea; border-radius: 9px; background: #fbfcfa; }
.metric-label { display: block; min-height: 20px; color: #7d8981; font-size: 9px; }
.metric-value { display: block; overflow: hidden; font-family: "Segoe UI", ui-sans-serif, system-ui, sans-serif; font-size: 18px; font-weight: 750; letter-spacing: -.06em; text-overflow: ellipsis; white-space: nowrap; }
.metric-unit { margin-left: 2px; color: #7d8981; font-family: "DM Sans", sans-serif; font-size: 9px; font-weight: 500; letter-spacing: 0; }
.metric-note { display: block; margin-top: 3px; color: #9aa39c; font-size: 9px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 10px; }
.section-heading h3 { margin: 0; font-size: 14px; letter-spacing: -.035em; }
.section-heading .helper-text { margin: 0; }
.readings-list { display: grid; gap: 8px; }
.reading-row { padding: 11px 12px; border: 1px solid #edf0ea; border-radius: 9px; display: grid; grid-template-columns: minmax(110px, 1.1fr) repeat(3, minmax(55px, .7fr)) auto; align-items: center; gap: 8px; }
.reading-stage { display: grid; gap: 4px; }
.reading-stage strong { font-size: 10px; }
.reading-stage span, .reading-value span { color: #849087; font-size: 9px; }
.reading-value { display: grid; gap: 3px; }
.reading-value strong { font-size: 11px; }
.reading-notes { grid-column: 1 / -2; margin: 1px 0 0; color: #758179; font-size: 10px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.reading-controls { display: flex; justify-content: flex-end; gap: 2px; }
.icon-button { width: 28px; height: 28px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: #7f8a82; font-size: 17px; }
.icon-button:hover { background: #f0f3ee; color: var(--ink); }
.empty-readings { padding: 22px 14px; border: 1px dashed #dfe5dc; border-radius: 10px; color: var(--muted); font-size: 11px; line-height: 1.6; text-align: center; }
.dry-hop-row { padding: 10px 11px; border: 1px solid #edf0ea; border-radius: 9px; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; background: #fcfdfa; }
.dry-hop-info { min-width: 0; display: grid; gap: 4px; }
.dry-hop-info > strong { overflow-wrap: anywhere; font-size: 11px; }
.dry-hop-info > span { color: #849087; font-size: 9px; }
.dry-hop-info p { margin: 0; color: #758179; font-size: 10px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.dry-hop-amount { white-space: nowrap; color: var(--green); font-size: 11px; }
.timer-section { padding: 4px 0 16px; }
.timer-section-heading { margin-top: 0; }
.timer-section-heading .helper-text { margin-top: 4px; }
.timer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.timer-card { min-width: 0; padding: 11px; border: 1px solid #e9ede6; border-radius: 10px; background: #fcfdfa; }
.timer-card-heading, .timer-card-heading > div { display: flex; align-items: center; }
.timer-card-heading { justify-content: space-between; gap: 6px; min-height: 21px; }
.timer-card-heading > div { min-width: 0; gap: 7px; }
.timer-card-heading strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.timer-stage-icon { color: #9c7139; font-size: 14px; }
.timer-session-count { flex: 0 0 auto; color: #879189; font-size: 8px; }
.timer-start { width: 100%; min-height: 32px; margin-top: 8px; font-size: 10px; }
.active-timer { margin-top: 8px; padding: 8px; border-radius: 8px; background: #edf4ed; }
.active-timer-display { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.active-timer-display span { color: #637568; font-size: 8px; font-weight: 750; letter-spacing: .1em; }
.active-timer-display strong { color: var(--green-deep); font-family: "Segoe UI", ui-sans-serif, system-ui, sans-serif; font-size: 20px; font-variant-numeric: tabular-nums; letter-spacing: -.05em; }
.timer-controls { display: flex; gap: 6px; margin-top: 6px; }
.timer-controls .button { min-height: 29px; flex: 1; padding: 0 6px; font-size: 9px; }
.timer-empty { margin: 8px 0 0; color: #929b94; font-size: 9px; }
.timer-history { margin-top: 8px; padding-top: 6px; border-top: 1px solid #edf0ea; }
.timer-history-row { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; color: #839087; font-size: 8px; }
.timer-history-row strong { color: #56665b; font-size: 9px; font-variant-numeric: tabular-nums; }
.timer-history-more { display: block; margin-top: 3px; color: #929b94; font-size: 8px; }
.process-timeline { padding-top: 2px; }
.process-heading { margin-bottom: 12px; }
.process-heading > div .helper-text { margin-top: 4px; }
.process-phase { padding: 0 0 12px 12px; border-left: 2px solid #e8eee6; }
.process-phase:last-child { padding-bottom: 0; border-left-color: transparent; }
.phase-heading, .phase-heading > div { display: flex; align-items: center; }
.phase-heading { min-height: 34px; justify-content: space-between; gap: 9px; margin-left: -20px; }
.phase-heading > div { gap: 9px; }
.phase-index { width: 23px; height: 23px; flex: 0 0 auto; border: 2px solid #dfe9df; border-radius: 50%; display: grid; place-items: center; background: #fff; color: var(--green); font-size: 8px; font-weight: 750; }
.phase-heading h4 { margin: 0 0 2px; font-family: inherit; font-size: 11px; }
.phase-heading > div > div > span { color: #879189; font-size: 8px; }
.phase-heading .button { min-height: 30px; padding: 0 8px; font-size: 9px; }
.phase-entries { display: grid; gap: 7px; padding-top: 6px; }
.phase-empty { margin: 0; padding: 9px 10px; border: 1px dashed #e5eae3; border-radius: 8px; color: #929b94; font-size: 9px; }
.process-phase-fermentation { border-left-color: #e8eee6; }
.process-phase-conditioning { border-left-color: #e7e9ef; }
.process-phase-packaging { border-left-color: transparent; }
.empty-state { min-height: 385px; padding: 40px 30px; display: grid; place-items: center; border: 1px dashed #dce3db; border-radius: 13px; background: rgb(255 255 255 / 55%); text-align: center; }
.empty-state-inner { max-width: 370px; }
.empty-illustration { width: 64px; height: 64px; margin: 0 auto 17px; display: grid; place-items: center; border-radius: 22px 22px 22px 8px; background: #eaf2eb; font-size: 28px; }
.empty-state h2 { margin-bottom: 8px; font-size: 20px; letter-spacing: -.05em; }
.empty-state p { margin: 0 0 17px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.global-message { min-height: 18px; margin: 10px 0 0; color: var(--green); font-size: 11px; }
.global-message.error { color: var(--red); }
.footer { padding: 21px 0 24px; display: flex; justify-content: space-between; color: #89938b; font-size: 9px; }
.footer span:first-child { font-weight: 700; }
.app-dialog { width: min(470px, calc(100% - 28px)); max-height: min(90vh, 760px); padding: 0; overflow: auto; border: 1px solid var(--line); border-radius: 15px; background: white; color: var(--ink); box-shadow: 0 22px 80px rgb(20 35 26 / 20%); }
.app-dialog::backdrop { background: rgb(22 35 27 / 42%); backdrop-filter: blur(2px); }
.app-dialog form { padding: 22px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 5px; }
.dialog-heading .eyebrow { margin-bottom: 4px; }
.dialog-heading h2 { margin: 0; font-size: 21px; letter-spacing: -.05em; }
.dialog-heading .icon-button { margin: -4px -6px 0 0; font-size: 22px; }
.dialog-intro { margin: 0 0 17px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.field-label { display: grid; gap: 6px; margin-top: 12px; color: #4b5a50; font-size: 10px; font-weight: 650; }
.field-label input, .field-label select, .field-label textarea { width: 100%; min-height: 39px; padding: 9px 10px; border: 1px solid #dfe5dd; border-radius: 8px; background: #fcfdfa; color: var(--ink); font-size: 12px; font-weight: 400; }
.field-label textarea { min-height: 78px; resize: vertical; }
.field-label input::placeholder, .field-label textarea::placeholder { color: #a5aea7; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.optional { color: #909b92; font-size: 9px; font-weight: 400; }
.unit-label { color: #879189; font-size: 9px; font-weight: 500; }
.dialog-actions { margin-top: 20px; padding-top: 14px; border-top: 1px solid #edf0ea; display: flex; justify-content: flex-end; gap: 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, label.button:focus-within { outline: 3px solid #a2c6a9; outline-offset: 2px; }

@media (max-width: 850px) {
  .app-shell { width: min(100% - 36px, 740px); }
  .workspace-grid { grid-template-columns: 1fr; }
  .sidebar { grid-template-columns: 1fr 1fr; align-items: start; }
  .brew-list { max-height: 220px; }
}
@media (max-width: 600px) {
  .app-shell { width: calc(100% - 28px); }
  .topbar { height: 62px; }
  .privacy-note { display: none; }
  .topbar-actions { gap: 5px; }
  .button, .topbar-actions .import-button { min-height: 44px; }
  .topbar-actions .button, .topbar-actions .import-button { padding: 0 8px; font-size: 10px; }
  .page-heading { align-items: stretch; flex-direction: column; gap: 13px; padding: 24px 0 18px; }
  .page-heading .button { width: 100%; min-height: 44px; margin: 0; }
  .page-intro { max-width: none; line-height: 1.5; }
  .summary-grid { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 11px; }
  .summary-card { min-height: 82px; padding: 11px; }
  .summary-card:nth-child(3), .summary-card:last-child { grid-column: 1 / -1; min-height: 71px; }
  .summary-card strong { font-size: 21px; }
  .summary-latest { font-size: 16px !important; }
  .summary-foot { font-size: 9px; }
  .sidebar { grid-template-columns: 1fr; gap: 10px; }
  .main-column { gap: 10px; }
  .panel { padding: 14px; }
  .detail-card { padding: 14px; }
  .detail-header { flex-direction: column; }
  .detail-actions { width: 100%; }
  .detail-actions .button { flex: 1; }
  .detail-metrics { grid-template-columns: 1fr 1fr; gap: 7px; padding: 12px 0; }
  .timer-grid { grid-template-columns: 1fr; }
  .timer-section-heading { align-items: flex-start; flex-wrap: wrap; }
  .timer-section-heading > .button { min-height: 44px; }
  .metric { padding: 9px; }
  .metric-value { font-size: 17px; }
  .reading-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 9px 6px; padding: 10px; }
  .icon-button { width: 44px; height: 44px; }
  .dry-hop-row { grid-template-columns: minmax(0, 1fr) auto; gap: 5px 8px; }
  .dry-hop-row .reading-controls { grid-column: 2; grid-row: 1; }
  .dry-hop-amount { grid-column: 1 / -1; grid-row: 2; }
  .reading-stage { grid-column: 1 / 3; }
  .reading-stage strong { font-size: 11px; }
  .reading-controls { grid-column: 3; grid-row: 1; }
  .reading-value { grid-row: 2; }
  .reading-notes { grid-column: 1 / -1; }
  .timer-start { min-height: 44px; }
  .timer-controls .button { min-height: 44px; }
  .phase-heading { flex-wrap: wrap; }
  .phase-heading .button { min-height: 44px; margin-left: 32px; }
  .settings-button { min-height: 44px; }
  .field-label input, .field-label select { min-height: 44px; }
  .dialog-actions .button { min-height: 44px; }
  .footer { gap: 10px; }
}
@media (max-width: 380px) {
  .app-shell { width: calc(100% - 20px); }
  .page-heading h1 { font-size: 23px; }
  .topbar-actions .button, .topbar-actions .import-button { padding: 0 6px; }
  .detail-card { padding: 11px; }
  .phase-heading { row-gap: 6px; }
  .process-heading { align-items: flex-start; }
  .field-grid { grid-template-columns: 1fr; gap: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
