:root {
  color: #262124;
  background: #eeeae8;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #262124;
  --muted: #71686c;
  --paper: #fffdfb;
  --section: #f6f2f0;
  --wine: #8b2f43;
  --wine-dark: #6f2033;
  --wine-wash: #f8edf0;
  --gold: #a7844f;
  --line: #e4dcda;
  --error: #a12734;
  --content-max: 34rem;
  --body-font-size: 1rem;
  --body-line-height: 1.65;
  --body-font-weight: 400;
}

* { box-sizing: border-box; }
html { min-width: 20rem; background: var(--section); }
html.modal-open { overflow: hidden; }
body {
  min-width: 20rem;
  min-height: 100vh;
  margin: 0;
  background: var(--section);
  color: var(--ink);
  font-size: var(--body-font-size);
  font-weight: var(--body-font-weight);
  line-height: var(--body-line-height);
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, h4, p { margin-top: 0; }
:lang(zh-CN) {
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}
:lang(en) {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

.app-shell {
  width: min(100%, var(--content-max));
  min-height: 100vh;
  margin-inline: auto;
  background: var(--paper);
  box-shadow: 0 0 2.5rem rgb(66 42 49 / 8%);
}

.app-header {
  display: grid;
  justify-items: center;
  padding: 1.25rem 1rem 0.8rem;
  border-bottom: 1px solid rgb(139 47 67 / 10%);
  background: var(--paper);
}
.app-topbar { background: var(--paper); }

.app-header h1 { margin: 0; line-height: 0; }
.brand-wordmark { display: block; width: clamp(8.75rem, 36vw, 11.25rem); height: auto; }
.brand-slogan {
  margin: 0.42rem 0 0;
  color: var(--wine-dark);
  font-family: "Songti SC", STSong, "Noto Serif CJK SC", Georgia, serif;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.upload-panel {
  display: grid;
  gap: 0.9rem;
  padding: 1.1rem 1rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.button {
  display: inline-flex;
  min-height: 3rem;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 0.55rem;
  padding: 0.78rem 1rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled { cursor: wait; opacity: 0.62; }
.button-primary { background: var(--wine); color: white; box-shadow: 0 0.35rem 1rem rgb(111 32 51 / 15%); }
.button-primary:hover:not(:disabled) { background: var(--wine-dark); }
.button-secondary { border-color: var(--wine); background: transparent; color: var(--wine-dark); }
.button-secondary:hover:not(:disabled) { background: var(--wine-wash); }
.upload-action { gap: 0.18rem; min-height: 3.4rem; font-size: 0.95rem; }
.camera-icon { width: 1.35rem; height: 1.35rem; margin-right: 0.34rem; fill: currentColor; }

.button:focus-visible, .image-enlarge:focus-visible, .image-close:focus-visible,
.language-toggle:focus-visible, .history-open:focus-visible, .history-item:focus-visible,
.app-nav button:focus-visible, .selection-remove:focus-visible,
#wine-image:focus-visible + .button {
  outline: 3px solid #c39a5c;
  outline-offset: 3px;
}

.app-nav {
  display: flex;
  justify-content: center;
  gap: 0.3rem;
  padding: 0 1rem 0.65rem;
}
.app-nav button {
  min-height: 2.75rem;
  border: 0;
  padding: 0.45rem 0.6rem;
  background: transparent;
  color: var(--wine-dark);
  font-size: 0.78rem;
  font-weight: 750;
  cursor: pointer;
}
.app-nav button:hover { background: var(--wine-wash); }

.history-panel { padding: 1.1rem 1rem 1.5rem; }
.history-panel h2 {
  margin-bottom: 0.45rem;
  color: var(--wine-dark);
  font-family: Georgia, "Songti SC", STSong, serif;
  font-size: 1.35rem;
}
.history-privacy-note, .history-empty {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.55;
}
.history-list { display: grid; gap: 0.65rem; margin: 1rem 0; padding: 0; list-style: none; }
.history-item {
  width: 100%;
  min-height: 3rem;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  padding: 0.8rem;
  background: var(--section);
  color: var(--ink);
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
}
.history-item:hover { border-color: var(--gold); background: var(--wine-wash); }
.history-actions { display: grid; gap: 0.65rem; }

.batch-indicator {
  position: sticky;
  z-index: 5;
  top: 0;
  margin: 0;
  border-bottom: 1px solid var(--line);
  padding: 0.72rem 1rem;
  background: rgb(255 253 251 / 96%);
  color: var(--wine-dark);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
}
.batch-indicator [data-batch-status-line] { display: block; }
.global-activity {
  position: fixed;
  z-index: 20;
  right: max(0.75rem, env(safe-area-inset-right));
  bottom: max(0.75rem, env(safe-area-inset-bottom));
  display: grid;
  min-width: 2.65rem;
  min-height: 2rem;
  place-items: center;
  border: 1px solid rgb(139 47 67 / 18%);
  border-radius: 999px;
  background: rgb(255 253 251 / 94%);
  box-shadow: 0 0.25rem 0.9rem rgb(66 42 49 / 10%);
  color: var(--wine);
  pointer-events: none;
}
.global-activity-dots {
  animation: generation-pulse 1.2s ease-in-out infinite;
  letter-spacing: 0.14em;
}
.batch-panel { padding: 1rem; background: var(--section); }
.batch-index { display: grid; gap: 0.75rem; }
.beverage-card {
  display: grid;
  width: 100%;
  min-height: 6.5rem;
  grid-template-columns: 5.25rem minmax(0, 1fr);
  gap: 0.8rem;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  text-align: left;
}
button.beverage-card { cursor: pointer; }
button.beverage-card:hover { border-color: var(--gold); box-shadow: 0 0.35rem 1rem rgb(66 42 49 / 8%); }
button.beverage-card:focus-visible, .batch-back:focus-visible {
  outline: 3px solid #c39a5c;
  outline-offset: 3px;
}
.beverage-card-visual { display: grid; min-height: 6.5rem; place-items: center; overflow: hidden; background: #ebe6e4; }
.beverage-card-image { width: 100%; height: 100%; object-fit: cover; }
.beverage-card-placeholder {
  display: grid;
  width: 2.7rem;
  height: 2.7rem;
  place-items: center;
  border: 1px solid #d6c6c9;
  border-radius: 50%;
  color: var(--wine-dark);
  font-family: Georgia, serif;
  font-weight: 700;
}
.beverage-card-content { display: grid; min-width: 0; align-content: center; gap: 0.35rem; padding: 0.75rem 0.75rem 0.75rem 0; }
.beverage-card-title { overflow-wrap: anywhere; font-family: Georgia, "Songti SC", STSong, serif; font-size: 0.96rem; line-height: 1.35; }
.beverage-card-meta { overflow-wrap: anywhere; color: var(--muted); font-size: 0.72rem; line-height: 1.4; }
.beverage-card-state { width: fit-content; border-radius: 999px; padding: 0.2rem 0.5rem; background: var(--section); color: var(--muted); font-size: 0.66rem; font-weight: 750; line-height: 1.3; }
.beverage-card[data-card-state="ready"] .beverage-card-state,
.beverage-card[data-card-state="saved"] .beverage-card-state { background: #edf5ee; color: #386443; }
.beverage-card[data-card-state="failed"] .beverage-card-state { background: #faecee; color: var(--error); }
.batch-back { width: calc(100% - 2rem); margin: 0.85rem 1rem 0; }
.history-item.beverage-card { padding: 0; }
.history-item .beverage-card-visual { min-height: 5.75rem; }
.selection-remove {
  width: fit-content;
  min-height: 2.75rem;
  border: 1px solid var(--wine);
  border-radius: 999px;
  padding: 0.42rem 0.72rem;
  background: transparent;
  color: var(--wine-dark);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}
.selection-remove:hover { background: var(--wine-wash); }

.help { margin: -0.1rem 0 0; color: var(--muted); font-size: 0.76rem; line-height: 1.45; text-align: center; }
.supported-categories {
  margin: -0.15rem 0 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.45;
  text-align: center;
}
.preview-frame { margin: 0; background: var(--section); }
.preview-frame:has(img[hidden]) { display: none; }
.image-enlarge {
  position: relative;
  display: block;
  width: 100%;
  min-height: 2.75rem;
  overflow: hidden;
  border: 0;
  border-radius: 0.45rem;
  padding: 0;
  background: #ebe6e4;
  color: white;
  cursor: zoom-in;
}
#preview { display: block; width: 100%; max-height: 28rem; background: #ebe6e4; object-fit: contain; }
.image-enlarge-hint {
  position: absolute;
  right: 0.65rem;
  bottom: 0.6rem;
  border-radius: 999px;
  padding: 0.36rem 0.62rem;
  background: rgb(35 27 30 / 74%);
  font-size: 0.68rem;
  line-height: 1;
}

.status { min-height: 1.4rem; margin: 0; padding: 0.75rem 1rem; color: var(--muted); font-size: 0.82rem; font-weight: 600; line-height: 1.45; text-align: center; }
.status:empty { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; padding: 0; }
.status.error { display: block; color: var(--error); }
.status [data-bilingual-line] { display: block; }

.result-toolbar { display: flex; justify-content: flex-end; padding: 0 1rem; }
.result-toolbar:has(.language-toggle[hidden]) { display: none; }
.language-toggle {
  min-width: 4.5rem;
  min-height: 2.75rem;
  border: 1px solid var(--wine);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  background: var(--paper);
  color: var(--wine-dark);
  font-size: 0.76rem;
  font-weight: 750;
  cursor: pointer;
}

#app:not([data-state="idle"]):not([data-state="history"]) .app-topbar {
  display: flex;
  min-height: 3.25rem;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 0.45rem 1rem;
}
#app:not([data-state="idle"]):not([data-state="history"]) .app-header { display: block; padding: 0; border: 0; }
#app:not([data-state="idle"]):not([data-state="history"]) .brand-wordmark { width: 6.4rem; }
#app:not([data-state="idle"]):not([data-state="history"]) .brand-slogan { display: none; }
#app:not([data-state="idle"]):not([data-state="history"]) .app-nav { padding: 0; }
.selection-back { width: calc(100% - 2rem); margin: 0.85rem 1rem 0; }
#app:is([data-state="succeeded"], [data-state="partial"]) .help { display: none; }
#app:is([data-state="succeeded"], [data-state="partial"]) .supported-categories { display: none; }
#app[data-state="failed"] .help, #app[data-state="failed"] .supported-categories { display: none; }
#app[data-state="failed"] .upload-panel { gap: 0; padding: 0; border: 0; }
#app[data-state="failed"] .image-enlarge { border-radius: 0; }
#app:is([data-state="succeeded"], [data-state="partial"]) .preview-frame { background: #eae5e3; }
#app:is([data-state="succeeded"], [data-state="partial"]) #preview { max-height: 28rem; }
#app[data-state="succeeded"] .upload-panel { gap: 0; padding: 0; border: 0; }
#app[data-state="succeeded"] .image-enlarge { border-radius: 0; }
#app[data-state="succeeded"] #preview { height: clamp(17.5rem, 76vw, 28rem); }
#app[data-state="succeeded"] .status { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; padding: 0; }
#app[data-state="batch-detail"] .help,
#app[data-state="batch-detail"] .supported-categories { display: none; }
#app[data-state="batch-detail"] .upload-panel { gap: 0; padding: 0; border: 0; }
#app[data-state="batch-detail"] .image-enlarge { border-radius: 0; }
#app[data-state="batch-detail"] #preview { height: clamp(17.5rem, 76vw, 28rem); }
#app[data-state="succeeded"] .result-toolbar { padding-block: 0.7rem; border-bottom: 1px solid var(--line); }

.wine-result { background: var(--paper); }
.unsupported-result h2 { margin-bottom: 0.75rem; color: var(--wine-dark); font-size: 1.08rem; }
.unsupported-result p { margin: 0 0 0.65rem; color: var(--muted); font-size: 0.82rem; line-height: 1.55; }
.unsupported-result p:last-child { margin-bottom: 0; }
.bilingual-narrative, .bilingual-long-value, .bilingual-recommendation { display: grid; gap: 0.45rem; }
.bilingual-narrative p, .bilingual-long-value p, .bilingual-recommendation p { margin: 0; }
.bilingual-narrative [lang="zh-CN"], .bilingual-long-value [lang="zh-CN"], .bilingual-recommendation [lang="zh-CN"] { color: var(--muted); }
.generation-indicator {
  display: flex;
  min-height: 3.25rem;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-top: 1px solid var(--line);
  padding: 0.8rem 1rem;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.4;
  text-align: center;
}
.generation-dots { animation: generation-pulse 1.2s ease-in-out infinite; color: var(--wine); letter-spacing: 0.12em; }
@keyframes generation-pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .generation-dots, .global-activity-dots { animation: none; }
}
.wine-identity { padding: 1.25rem 1rem 1.1rem; border-bottom: 1px solid var(--line); text-align: left; }
.identity-eyebrow { margin-bottom: 0.45rem; color: var(--wine-dark); font-size: 0.66rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.wine-identity h2 { margin-bottom: 0.55rem; color: var(--ink); font-family: Georgia, "Songti SC", STSong, serif; font-size: clamp(1.35rem, 5.2vw, 1.72rem); font-weight: 650; letter-spacing: -0.015em; line-height: 1.22; }
.experimental-indicator {
  display: inline-block;
  margin: 0;
  border: 1px solid #d8c9aa;
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
  background: #faf6ed;
  color: #6b5d42;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.35;
}
.identity-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem 0.75rem; }
.identity-producer { margin: 0; color: var(--muted); font-size: 0.88rem; font-weight: 550; line-height: 1.4; }
.vintage { margin: 0; border-left: 2px solid var(--wine); padding-left: 0.55rem; color: var(--wine-dark); font-size: 0.8rem; font-weight: 750; letter-spacing: 0.06em; }
.recognition-quality {
  max-width: 31rem;
  margin: 0.8rem 0 0;
  border-left: 2px solid #b79b72;
  padding-left: 0.65rem;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.55;
}
.recognition-quality[data-level="low"] { border-left-color: var(--wine); color: #65575c; font-weight: 600; }
.multi-beverage-notice {
  margin: 0;
  border-bottom: 1px solid #e6d7b8;
  padding: 0.85rem 1rem;
  background: #faf6ed;
  color: #5f543f;
  font-size: 0.78rem;
  line-height: 1.55;
}
.multi-beverage-notice p { margin: 0; }
.multi-beverage-items { margin: 0.55rem 0 0; padding-left: 1.15rem; }
.multi-beverage-items li + li { margin-top: 0.3rem; }
.persistence-notice {
  margin: 0;
  border-top: 1px solid var(--line);
  padding: 0.8rem 1rem;
  background: #faf6ed;
  color: #655b48;
  font-size: 0.76rem;
  line-height: 1.5;
}
.partial-notice {
  margin: 0;
  border-top: 1px solid var(--line);
  padding: 0.8rem 1rem;
  background: #faf6ed;
  color: #655b48;
  font-size: 0.76rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.proper-name { overflow-wrap: anywhere; }
.inline-term { line-height: 1.45; }

.result-section { padding: 1.2rem 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.result-section h3 { margin-bottom: 0.9rem; color: var(--wine-dark); font-size: 0.9rem; font-weight: 750; letter-spacing: 0.015em; line-height: 1.35; }
.result-section h4 { margin: 0 0 0.48rem; color: var(--muted); font-size: 0.75rem; font-weight: 750; line-height: 1.35; }
.introduction { background: var(--wine-wash); }
.terroir, .serving { background: var(--section); }
.education-notes { background: #f5f3f2; color: #5f585b; }
.educator-disclaimer { border-left: 2px solid var(--gold); padding-left: 0.75rem; font-size: 0.8rem; }
.learning-block + .learning-block { margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.narrative, .bilingual-narrative, .bilingual-long-value, .bilingual-recommendation,
.recommendation-list, .recommendation-list li {
  font-size: var(--body-font-size);
  font-weight: var(--body-font-weight);
  line-height: var(--body-line-height);
}
.narrative { margin: 0; overflow-wrap: anywhere; }
.narrative:lang(zh-CN), .bilingual-narrative [lang="zh-CN"],
.bilingual-long-value [lang="zh-CN"], .bilingual-recommendation [lang="zh-CN"] {
  line-break: strict;
}

.fact-grid { display: grid; margin: 0; }
.fact-row { display: grid; grid-template-columns: minmax(6.8rem, 0.72fr) minmax(0, 1.28fr); gap: 0.7rem; padding: 0.68rem 0; }
.fact-row:first-child { padding-top: 0; }
.fact-row:last-child { padding-bottom: 0; }
.fact-row + .fact-row { border-top: 1px solid var(--line); }
.fact-row dt { color: var(--muted); font-size: 0.73rem; line-height: 1.45; }
.fact-row dd { margin: 0; font-size: 0.86rem; font-weight: 600; line-height: 1.5; }
.term-list { display: grid; gap: 0.42rem; }
.term-item { display: block; }
.tasting-scales { margin-top: 0.85rem; padding: 0.75rem; border-radius: 0.45rem; background: var(--section); }
.tasting-scales .fact-row { grid-template-columns: minmax(6.8rem, 1fr) minmax(0, 1fr); padding-block: 0.5rem; }

.reset-button { width: calc(100% - 2rem); margin: 1rem; }
.image-dialog { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; padding: 3.5rem 1rem 1rem; background: rgb(20 16 18 / 94%); }
.image-dialog img { display: block; max-width: 100%; max-height: calc(100vh - 5rem); object-fit: contain; }
.image-close { position: fixed; z-index: 1; top: max(0.75rem, env(safe-area-inset-top)); right: max(0.75rem, env(safe-area-inset-right)); display: grid; width: 2.75rem; height: 2.75rem; place-items: center; border: 1px solid rgb(255 255 255 / 55%); border-radius: 50%; background: rgb(0 0 0 / 34%); color: #fff; font-size: 1.75rem; line-height: 1; cursor: pointer; }
.confirmation-dialog { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; padding: 1rem; background: rgb(20 16 18 / 56%); }
.confirmation-dialog-content { width: min(100%, 28rem); border-radius: 0.7rem; padding: 1.2rem; background: var(--paper); box-shadow: 0 1rem 2.5rem rgb(20 16 18 / 24%); }
.confirmation-dialog-content h2 { margin-bottom: 0.65rem; color: var(--wine-dark); font-size: 1.15rem; }
.confirmation-dialog-content p { margin-bottom: 1rem; color: var(--muted); line-height: 1.5; }
.confirmation-dialog-actions { display: grid; gap: 0.65rem; }
.confirmation-dialog-actions .button { width: 100%; white-space: normal; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; padding: 0; }
[hidden] { display: none !important; }

@media (max-width: 23rem) {
  .fact-row, .tasting-scales .fact-row { grid-template-columns: 1fr; gap: 0.18rem; }
  .fact-row dt { font-size: 0.71rem; }
  .upload-action { font-size: 0.88rem; }
}

@media (min-width: 40rem) {
  body { padding-block: 1.5rem; }
  .app-shell { min-height: calc(100vh - 3rem); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
