/* Wine cellar. Every colour is a variable, defined once for the light theme and once for the dark
   theme (data-theme is set by i18n.js before the page is drawn). Contrast of each text pair is
   checked by test/smoke.js (4.5:1 at least, both themes). No information is carried by colour
   alone: states are always written (labels, aria-pressed with underline, messages in words). */

:root {
  color-scheme: light;
  --bg: #f7f4ef;
  --card: #ffffff;
  --field: #ffffff;
  --ink: #1f1b18;
  --muted: #5c554e;
  --line: #cdc3b5;
  --accent: #6b1d2a;
  --on-accent: #ffffff;
  --warn: #8a4b00;
  --ok: #1d5c2a;
  --danger: #8b0000;
  --focus: #1a56b8;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15110f;
  --card: #221c19;
  --field: #1a1512;
  --ink: #eee7df;
  --muted: #b8aea4;
  --line: #4d433c;
  --accent: #7d2636;
  --on-accent: #ffffff;
  --warn: #f2b066;
  --ok: #8fd3a0;
  --danger: #ff9a9a;
  --focus: #8ab4ff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.4; }
a { color: var(--ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.top { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: var(--accent); color: var(--on-accent); }
.top h1 { margin: 0; font-size: 1.2rem; }
.prefs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.langs { display: inline-flex; border: 1px solid var(--on-accent); border-radius: 999px; overflow: hidden; }
.lang { background: none; border: none; border-radius: 0; color: var(--on-accent); padding: 4px 10px; font-size: .85rem; }
.lang + .lang { border-left: 1px solid var(--on-accent); }
/* The chosen language is underlined and bold, not only inverted. */
.lang[aria-pressed="true"] { background: var(--on-accent); color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.pill { background: none; color: var(--on-accent); border: 1px solid var(--on-accent); border-radius: 999px; padding: 4px 12px; font-size: .85rem; }

main { max-width: 760px; margin: 0 auto; padding: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 12px; }
h2 { margin-top: 0; font-size: 1.15rem; }
h3 { font-size: 1rem; margin: 18px 0 8px; }
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 10px; }
label.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
input, select, textarea { display: block; width: 100%; font: inherit; color: var(--ink); padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); margin-top: 4px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
label.inline input { width: auto; margin: 0; }
button, .file-btn { font: inherit; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--field); color: var(--ink); cursor: pointer; display: inline-block; text-align: center; }
.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
.danger { border-color: var(--danger); color: var(--danger); }
.link { background: none; border: none; color: inherit; text-decoration: underline; padding: 4px 0; }
.file-btn input { display: none; }
.actions, .row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.row > input, .row > select { flex: 1 1 120px; width: auto; }
.filters { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.filters input[type=search] { grid-column: 1 / -1; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 520px) { .grid { grid-template-columns: 1fr; } }
.summary { font-weight: 600; margin: 4px 0 8px; }
.wines { list-style: none; padding: 0; margin: 0; }
.wines li { background: var(--card); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.wines li.muted { padding: 10px; }
.wines button { width: 100%; display: flex; gap: 12px; align-items: center; text-align: left; border: none; background: none; padding: 10px; color: var(--ink); }
.wines img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; flex: none; background: var(--line); }
.wines .noimg { width: 56px; height: 56px; border-radius: 6px; flex: none; background: var(--line); }
.wines .main { flex: 1; min-width: 0; }
.wines .name { font-weight: 600; }
.wines .sub { color: var(--muted); font-size: .9rem; }
.wines .qty { font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.tag { display: inline-block; font-size: .8rem; border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; margin-right: 4px; color: var(--ink); }
.photo img { max-width: 100%; max-height: 320px; border-radius: 8px; display: block; margin: 0 auto 10px; }
.msg { min-height: 1.2em; color: var(--warn); font-weight: 500; }
.msg.ok { color: var(--ok); }
.muted, .foot { color: var(--muted); font-size: .9rem; }
.moves { padding-left: 18px; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; }

/* 06/10/2026: drinking window, origins of values, totals, filters, photo editor, new version banner.
   Every state is written in words; weight, underline and dashed borders only add to the text. */
.newver { position: sticky; top: 0; z-index: 30; background: var(--card); border-bottom: 2px solid var(--accent); padding: 8px 12px; text-align: center; }
.newver button { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.newver button::before { content: "\21BB  "; }
.switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin: 4px 0 8px; }
.switch .view-btn { border: none; border-radius: 0; background: var(--field); color: var(--ink); padding: 8px 14px; }
.switch .view-btn + .view-btn { border-left: 1px solid var(--line); }
.switch .view-btn[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.totals { margin: 0 0 8px; font-size: .95rem; }
.totals div { margin: 2px 0; }
details.more { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 8px 0; }
details.more > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
details.more[open] > summary { margin-bottom: 8px; }
.origin { display: block; min-height: 0; margin-top: 2px; font-size: .8rem; color: var(--muted); }
.origin.check { color: var(--warn); font-weight: 700; }
.origin.check::before { content: "? "; }
.legend { font-size: .85rem; }
.tag.drink { font-weight: 600; }
.tag.drink-past, .tag.drink-lastYear { font-weight: 800; border-width: 2px; border-color: var(--ink); }
.tag.ai { border-style: dashed; }
.status-line { font-weight: 700; }
.btnlink { font: inherit; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--field); color: var(--ink); display: inline-block; text-decoration: underline; }
.stage { width: 100%; display: flex; justify-content: center; margin: 8px 0; padding: 14px; touch-action: none; }
.stage canvas { display: block; max-width: 100%; }
output { font-weight: 700; color: var(--ink); }
input[type=range] { padding: 0; }
dd { white-space: pre-line; }

/* 06/10/2026: users and paired devices. */
.me { flex-basis: 100%; margin: 0; font-size: .85rem; color: var(--on-accent); }
.codebox { border: 2px solid var(--ink); border-radius: 10px; padding: 12px; margin: 10px 0; text-align: center; background: var(--field); }
.codebox .code { font-size: 2.2rem; font-weight: 800; letter-spacing: .15em; margin: 6px 0; font-variant-numeric: tabular-nums; }
.users { list-style: none; padding: 0; margin: 0; }
.users > li h3 { margin-top: 0; }
.devices { padding-left: 18px; margin: 6px 0; }
.devices li { margin: 4px 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
button.small { padding: 4px 10px; font-size: .85rem; }
