:root {
  --paper: #ffffff;
  --surface: #ffffff;
  --ink: #252c29;
  --muted: #65706a;
  --accent: #345b48;
  --accent-soft: #edf3ef;
  --line: #dde3df;
  --warning: #856a31;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --shadow: 0 12px 40px #152a1e18;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.5 var(--sans); }
body[data-theme=clay] { --accent: #725542; --accent-soft: #f3eeea; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: default; opacity: .55; }
a { color: inherit; }
button, a, input, select, textarea { outline-offset: 3px; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 30px; line-height: 1.25; font-weight: 600; margin-bottom: 8px; }
h2 { font-size: 20px; font-weight: 600; margin-bottom: 16px; }
h3 { font-size: 19px; font-weight: 600; margin-bottom: 8px; }
[hidden] { display: none !important; }
.app-shell { display: grid; grid-template-columns: 200px 1fr; min-height: 100vh; }
.sidebar { border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 30px 20px 24px; position: sticky; top: 0; height: 100vh; background: #f7f9f8; }
.brand { text-decoration: none; font-size: 21px; font-weight: 600; padding: 0 10px; }
.main-nav { margin-top: 32px; display: grid; gap: 6px; }
.nav-item { border: 0; background: transparent; text-align: left; padding: 11px 12px; border-radius: 5px; color: var(--muted); font-size: 13px; min-height: 44px; }
.nav-item.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.local-label { font-size: 11px; color: var(--muted); margin-top: auto; }
.local-label small { display: block; font-size: 10px; margin: 6px 0 0 14px; }
.status-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #598266; vertical-align: middle; flex: none; }
.status-dot.warning { background: var(--warning); }
main { min-width: 0; padding: 0 36px; }
.topbar { height: 76px; display: flex; align-items: center; justify-content: flex-end; border-bottom: 1px solid var(--line); gap: 20px; }
.topbar-actions { display: flex; align-items: center; gap: 20px; }
.button { border: 1px solid var(--line); border-radius: 5px; padding: 10px 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; text-decoration: none; font-size: 13px; font-weight: 500; white-space: nowrap; }
.button.primary { background: var(--accent); color: white; border-color: var(--accent); }
.button.primary:hover { filter: brightness(1.08); }
.button.secondary { background: var(--surface); color: var(--accent); }
.button.secondary:hover { background: var(--accent-soft); }
.sync-button { display: flex; align-items: center; gap: 8px; background: transparent; border: 0; color: var(--muted); font-size: 12px; padding: 8px; min-height: 44px; }
.demo-banner { margin-top: 20px; padding: 9px 12px; border: 1px solid var(--line); background: #f7f9f8; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 15px; font-size: 12px; border-radius: 5px; }
.demo-banner button { background: none; border: 0; color: var(--accent); padding: 6px; white-space: nowrap; }
.view { padding-top: 28px; min-height: calc(100vh - 170px); }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 24px; }
.muted { color: var(--muted); font-size: 13px; margin-bottom: 0; }
.shelf-toolbar { display: grid; gap: 16px; margin-bottom: 20px; }
.status-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filter { padding: 7px 13px; border: 1px solid transparent; border-radius: 5px; font-size: 12px; background: transparent; color: var(--muted); min-height: 38px; }
.filter.active { background: var(--accent-soft); border-color: var(--line); color: var(--accent); }
.search-controls { display: flex; gap: 10px; }
.search-box { display: flex; flex-direction: row; align-items: center; flex: 1; min-width: 100px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); padding: 0 12px; }
.search-box input { width: 100%; border: 0; background: transparent; font-size: 12px; padding: 10px 0; min-height: 42px; }
.search-box input:focus { outline: 0; }
.search-box:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.search-controls select { width: auto; max-width: 190px; min-width: 135px; font-size: 12px; }
.tea-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.tea-card { padding: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--surface); text-align: left; display: flex; flex-direction: column; width: 100%; }
.tea-card:hover { border-color: #a6b7ac; background: #fafcfb; }
.tea-photo { height: 160px; overflow: hidden; }
.tea-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tea-card-body { padding: 18px; flex: 1; display: flex; flex-direction: column; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.tea-category { color: var(--muted); font-size: 12px; }
.stock-badge { border-radius: 3px; background: #f1f4f2; padding: 3px 6px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.tea-card h3 { font-size: 19px; margin: 0 0 8px; overflow-wrap: anywhere; }
.tea-origin { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.tags, .evaluation-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { background: #f3f5f4; color: var(--muted); border-radius: 3px; font-size: 11px; padding: 3px 7px; overflow-wrap: anywhere; }
.evaluation-tags { margin-bottom: 12px; }
.evaluation-tags .tag { background: var(--accent-soft); color: var(--accent); }
.card-bottom { margin-top: auto; padding-top: 18px; display: flex; justify-content: space-between; gap: 6px; color: var(--muted); font-size: 11px; }
.card-bottom span:last-child { color: var(--accent); }
.empty-state { grid-column: 1/-1; min-height: 240px; display: grid; place-content: center; text-align: center; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); padding: 30px; }
.empty-state h2 { color: var(--ink); margin-bottom: 9px; }
.empty-state p { margin-bottom: 20px; }
.empty-state .button { justify-self: center; }
.journal-list { max-width: 860px; display: grid; gap: 16px; }
.journal-entry { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 24px; }
.entry-top { display: flex; justify-content: space-between; gap: 15px; align-items: start; }
.entry-meta { font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.entry-link { font-size: 20px; font-weight: 600; background: none; border: 0; padding: 0; text-align: left; }
.entry-note { white-space: pre-wrap; font-size: 14px; line-height: 1.7; margin: 16px 0; }
.brew-tags { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.brew-tags span { padding: 4px 8px; border: 1px solid var(--line); border-radius: 4px; }
.photo-strip { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 15px; }
.photo-thumb { border: 0; background: transparent; padding: 0; border-radius: 5px; overflow: hidden; width: 75px; height: 75px; }
.photo-thumb img { height: 100%; width: 100%; object-fit: cover; }
.text-button { border: 0; background: transparent; padding: 9px 0; font-size: 12px; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; max-width: 950px; }
.settings-card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 26px; }
.settings-card > p { font-size: 13px; color: var(--muted); line-height: 1.7; }
.settings-card form { display: grid; gap: 15px; }
.settings-card .button { justify-self: start; }
.settings-card .fine-print { font-size: 11px; margin: 18px 0; }
.storage-status { background: #f7f9f8; border: 1px solid var(--line); border-radius: 5px; padding: 15px; display: flex; gap: 10px; align-items: baseline; margin: 20px 0; font-size: 13px; }
.storage-status p { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.settings-card #switch-collection { display: block; margin-top: 12px; }
footer { border-top: 1px solid var(--line); margin-top: 32px; padding: 18px 0; color: var(--muted); font-size: 11px; }
dialog { border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 0; color: var(--ink); background: var(--paper); max-height: 90dvh; width: calc(100% - 36px); }
dialog::backdrop { background: #17271e66; }
.detail-dialog { max-width: 900px; }
.form-dialog { max-width: 690px; }
.sync-dialog { max-width: 580px; }
.dialog-head, .dialog-top { display: flex; justify-content: space-between; align-items: start; gap: 20px; padding: 24px 28px 0; }
.dialog-head h2 { margin-bottom: 8px; }
.dialog-head p { color: var(--muted); font-size: 12px; margin-bottom: 0; }
.close-button { border: 0; background: transparent; font-size: 25px; color: var(--muted); width: 40px; height: 40px; line-height: 1; flex: none; }
.detail-body { padding: 24px 28px 28px; }
.detail-overview { margin-bottom: 24px; }
.detail-overview.with-photo { display: grid; grid-template-columns: 230px 1fr; gap: 28px; }
.detail-overview .tea-photo { height: 240px; border-radius: 5px; }
.detail-overview h1 { font-size: 28px; margin-bottom: 10px; }
.other-name { font-size: 13px; color: var(--muted); }
.detail-description { font-size: 14px; line-height: 1.7; white-space: pre-wrap; margin: 16px 0; }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.detail-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 20px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 20px 0; }
.detail-facts div { font-size: 13px; overflow-wrap: anywhere; }
.detail-facts small { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.detail-section { margin-top: 30px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.section-head h2 { font-size: 20px; margin: 0; }
.purchase-row { display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); padding: 14px 0; }
.purchase-row p { font-size: 13px; color: var(--muted); margin: 5px 0; }
.purchase-row strong { font-size: 14px; font-weight: 500; }
.section-empty { font-size: 13px; color: var(--muted); padding: 14px 0; }
.detail-section .journal-entry { margin-top: 12px; padding: 20px; }
.detail-section .entry-link { font-size: 18px; }
.tea-form { padding: 24px 28px 28px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.form-grid .full { grid-column: 1/-1; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink); }
.optional { font-size: 11px; color: var(--muted); margin-left: 4px; font-weight: 400; }
input, select, textarea { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 5px; padding: 10px 11px; width: 100%; font-size: 13px; min-height: 44px; }
textarea { resize: vertical; line-height: 1.6; min-height: 95px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
details { grid-column: 1/-1; border-top: 1px solid var(--line); padding-top: 12px; }
summary { font-size: 13px; color: var(--accent); cursor: pointer; margin-bottom: 13px; }
.evaluation-field { border: 1px solid var(--line); border-radius: 5px; padding: 12px; margin: 0; min-width: 0; }
.evaluation-field legend { padding: 0 4px; font-size: 13px; }
.evaluation-field small { display: block; color: var(--muted); font-size: 11px; margin-top: 9px; }
.evaluation-suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.evaluation-suggestions button { border: 1px solid var(--line); border-radius: 4px; padding: 6px 10px; background: var(--surface); font-size: 12px; min-height: 36px; }
.evaluation-suggestions button[aria-pressed=true] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.upload-area { padding: 14px; border: 1px solid var(--line); border-radius: 5px; background: #f7f9f8; grid-column: 1/-1; }
.upload-area input { padding: 7px; border: 0; background: transparent; font-size: 12px; }
.upload-area small { color: var(--muted); font-size: 11px; }
.photo-edit { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 10px; }
.photo-edit-item { position: relative; }
.photo-edit-item img { width: 70px; height: 70px; object-fit: cover; border-radius: 4px; }
.photo-edit-item button { position: absolute; right: -5px; top: -5px; border: 1px solid var(--line); border-radius: 50%; width: 25px; height: 25px; background: var(--surface); font-size: 15px; line-height: 1; }
.form-footer { display: flex; justify-content: space-between; align-items: center; gap: 15px; border-top: 1px solid var(--line); margin-top: 23px; padding-top: 20px; }
.form-footer small { color: var(--muted); font-size: 11px; max-width: 250px; }
.form-footer > div { display: flex; gap: 10px; }
.form-error { color: #9b4435; font-size: 12px; margin: 13px 0 0; white-space: pre-wrap; }
.sync-body { padding: 20px 28px 28px; }
.sync-summary { font-size: 13px; color: var(--muted); line-height: 1.7; }
.sync-notice { border: 1px solid var(--line); background: #f7f9f8; padding: 14px; border-radius: 5px; font-size: 12px; color: var(--muted); margin: 16px 0; }
.queue-item { border-top: 1px solid var(--line); padding: 14px 0; font-size: 13px; }
.queue-item small { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.queue-item .button { margin: 10px 6px 0 0; }
.conflict-versions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.conflict-versions div { padding: 12px; background: var(--surface); border: 1px solid var(--line); font-size: 12px; border-radius: 5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.conflict-versions strong { display: block; color: var(--muted); font-size: 11px; margin-bottom: 7px; }
.toast { position: fixed; bottom: 25px; left: 50%; transform: translateX(-50%); z-index: 30; background: var(--ink); color: white; padding: 12px 18px; border-radius: 5px; box-shadow: var(--shadow); font-size: 13px; max-width: calc(100% - 40px); width: max-content; }
.photo-dialog { max-width: 1100px; background: #1c231f; }
.photo-dialog img { max-height: 82dvh; width: 100%; object-fit: contain; display: block; }
.photo-dialog .close-button { position: absolute; top: 8px; right: 8px; background: #ffffffe0; border-radius: 50%; z-index: 1; }
.fine-print { color: var(--muted); font-size: 11px; line-height: 1.7; }
.busy-indicator { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.pending-marker { color: var(--warning) !important; }
#client-form { padding: 28px; display: grid; gap: 16px; }
#client-form .dialog-top { padding: 0; }
@media(min-width:1550px) { main { padding: 0 52px; } .tea-grid { grid-template-columns: repeat(4,minmax(0,1fr)); } }
@media(max-width:1150px) { .app-shell { grid-template-columns: 180px 1fr; } .sidebar { padding: 26px 16px; } .brand { font-size: 20px; } .tea-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } main { padding: 0 28px; } .settings-grid { grid-template-columns: 1fr; } .search-controls { flex-wrap: wrap; } .search-box { flex-basis: 100%; } .search-controls select { flex: 1; max-width: none; } }
@media(max-width:720px) {
  .app-shell { display: block; }
  .sidebar { height: auto; position: relative; padding: 18px 20px 0; border-right: 0; border-bottom: 1px solid var(--line); background: var(--paper); display: block; }
  .brand { font-size: 20px; padding: 0; }
  .main-nav { display: flex; gap: 4px; margin-top: 14px; justify-content: space-between; }
  .nav-item { font-size: 12px; padding: 10px 12px; border-radius: 5px 5px 0 0; min-height: 44px; }
  .local-label { display: none; }
  main { padding: 0 20px; }
  .topbar { height: 66px; }
  .topbar-actions { width: 100%; justify-content: space-between; gap: 8px; }
  .sync-button { font-size: 11px; padding-left: 0; }
  .demo-banner { font-size: 11px; align-items: flex-start; flex-direction: column; gap: 3px; margin-top: 14px; }
  .demo-banner button { padding: 2px 0; }
  .view { padding-top: 24px; min-height: calc(100vh - 230px); }
  .page-heading { align-items: start; flex-direction: column; gap: 16px; margin-bottom: 20px; }
  h1 { font-size: 28px; }
  .shelf-toolbar { gap: 14px; }
  .status-filters { gap: 2px; }
  .tea-grid { gap: 12px; }
  .tea-card-body { padding: 14px; }
  .tea-card h3 { font-size: 17px; }
  .card-meta { align-items: start; gap: 5px; }
  .tea-category, .stock-badge, .tag { font-size: 10px; }
  .stock-badge { padding: 2px 4px; }
  .tea-origin { font-size: 11px; }
  .card-bottom { font-size: 10px; padding-top: 16px; flex-wrap: wrap; }
  .tea-photo { height: 120px; }
  .journal-entry { padding: 20px; }
  .settings-card { padding: 22px; }
  .settings-grid { gap: 15px; }
  .dialog-head { padding: 20px 20px 0; }
  .detail-body, .tea-form, .sync-body { padding: 20px; }
  .detail-overview.with-photo { grid-template-columns: 1fr; gap: 18px; }
  .detail-overview .tea-photo { height: 180px; }
  .detail-facts { grid-template-columns: 1fr 1fr; }
  .form-grid { gap: 13px; }
  .form-footer { align-items: flex-start; flex-direction: column; gap: 13px; }
  .form-footer > div { width: 100%; justify-content: flex-end; }
  .form-footer small { max-width: none; }
  .conflict-versions { grid-template-columns: 1fr; }
  .form-dialog, .detail-dialog { max-height: 94dvh; width: calc(100% - 20px); }
  .photo-dialog { width: calc(100% - 16px); }
}
@media(max-width:370px) { .tea-grid { grid-template-columns: 1fr; } .form-grid { grid-template-columns: 1fr; } }
@media(prefers-reduced-motion:reduce) { * { transition: none !important; animation: none !important; } }
