/* ============================================================
   GrindAdvisor – Liquid Glass Design System
   Dunkler Standard mit treibenden Farbfeldern hinter echten
   Glas-Panels (backdrop-filter), heller Modus als Variante.
   ============================================================ */

:root {
  --bg: #0c0d12;
  --ink: #f4f2ee;
  --muted: rgba(244, 242, 238, .58);
  --faint: rgba(244, 242, 238, .32);

  /* Glas */
  --glass: rgba(255, 255, 255, .065);
  --glass-strong: rgba(255, 255, 255, .10);
  --glass-border: rgba(255, 255, 255, .14);
  --glass-highlight: rgba(255, 255, 255, .32);
  --glass-shadow: 0 18px 50px rgba(0, 0, 0, .45);
  --blur: 22px;

  --accent: #ecb64f;          /* Crema-Gold */
  --accent-soft: rgba(236, 182, 79, .16);
  --accent-ink: #241a06;
  --good: #8fd694;
  --sour: #86b6f2;
  --bitter: #f0907a;
  --danger: #f0907a;

  --radius-l: 24px;
  --radius: 18px;
  --radius-s: 12px;

  --font-display: "Sora", -apple-system, sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-num: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --ease-spring: cubic-bezier(.32, 1.4, .35, 1);
  --ease-out: cubic-bezier(.22, .8, .3, 1);
}

[data-theme="light"] {
  --bg: #eceef4;
  --ink: #1c1d24;
  --muted: rgba(28, 29, 36, .60);
  --faint: rgba(28, 29, 36, .35);
  --glass: rgba(255, 255, 255, .48);
  --glass-strong: rgba(255, 255, 255, .66);
  --glass-border: rgba(255, 255, 255, .75);
  --glass-highlight: rgba(255, 255, 255, .95);
  --glass-shadow: 0 16px 44px rgba(40, 46, 80, .16);
  --accent: #b3801f;
  --accent-soft: rgba(179, 128, 31, .13);
  --accent-ink: #ffffff;
  --good: #3d9a4a;
  --sour: #2f6fc4;
  --bitter: #cd5a3e;
  --danger: #cd5a3e;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
}
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 15px; }
[hidden] { display: none !important; }

/* ---------- Aurora-Hintergrund ---------- */
.aurora { position: fixed; inset: -20%; z-index: -1; overflow: hidden; }
.blob {
  position: absolute; border-radius: 50%;
  filter: blur(90px); opacity: .55;
  will-change: transform;
}
.b1 {
  width: 55vmax; height: 55vmax; left: -12vmax; top: -14vmax;
  background: radial-gradient(circle, #b4802a, transparent 65%);
  animation: drift1 46s ease-in-out infinite alternate;
}
.b2 {
  width: 48vmax; height: 48vmax; right: -14vmax; top: 8vmax;
  background: radial-gradient(circle, #43356b, transparent 65%);
  animation: drift2 58s ease-in-out infinite alternate;
}
.b3 {
  width: 44vmax; height: 44vmax; left: 22vmax; bottom: -20vmax;
  background: radial-gradient(circle, #235347, transparent 65%);
  animation: drift3 52s ease-in-out infinite alternate;
}
[data-theme="light"] .blob { opacity: .38; }
[data-theme="light"] .b1 { background: radial-gradient(circle, #f0c26a, transparent 65%); }
[data-theme="light"] .b2 { background: radial-gradient(circle, #a9b6ee, transparent 65%); }
[data-theme="light"] .b3 { background: radial-gradient(circle, #9fd8c4, transparent 65%); }
@keyframes drift1 { to { transform: translate(9vmax, 7vmax) scale(1.12); } }
@keyframes drift2 { to { transform: translate(-8vmax, 9vmax) scale(.92); } }
@keyframes drift3 { to { transform: translate(6vmax, -8vmax) scale(1.08); } }
.grain {
  position: absolute; inset: 0; opacity: .5; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Glas-Panels ---------- */
.glass, .card, .sheet, .item-row, .stat-tile, .chart-card, .toast, .auth-card {
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.6);
  backdrop-filter: blur(var(--blur)) saturate(1.6);
  border: 1px solid var(--glass-border);
  box-shadow:
    inset 0 1px 0 var(--glass-highlight),
    inset 0 -1px 0 rgba(0,0,0,.08),
    var(--glass-shadow);
}

/* ---------- Layout ---------- */
#app {
  display: grid;
  grid-template-columns: 244px 1fr;
  gap: 20px;
  min-height: 100dvh;
  padding: 20px;
  max-width: 1240px;
  margin: 0 auto;
}
#sidebar {
  border-radius: var(--radius-l);
  padding: 22px 14px;
  display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 20px;
  height: calc(100dvh - 40px);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px;
  background: linear-gradient(145deg, #f3cd7e, #b3801f);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 6px 16px rgba(200,150,50,.35);
  display: grid; place-items: center;
}
.brand-mark span {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid #241a06; border-top-color: transparent;
  transform: rotate(35deg);
}
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.brand-sub { font-size: 11.5px; color: var(--muted); margin-top: -1px; }

#nav-desktop { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-s);
  color: var(--muted); cursor: pointer;
  border: 1px solid transparent; background: none;
  font-size: 14.5px; text-align: left; width: 100%;
  transition: background .18s var(--ease-out), color .18s, transform .18s var(--ease-out);
}
.nav-item:hover { color: var(--ink); background: rgba(255,255,255,.05); transform: translateX(2px); }
[data-theme="light"] .nav-item:hover { background: rgba(255,255,255,.5); }
.nav-item.active {
  background: var(--glass-strong); color: var(--ink); font-weight: 600;
  border-color: var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.nav-item .ico { width: 20px; text-align: center; opacity: .9; }
.sidebar-foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 0 10px; display: flex; flex-direction: column; gap: 8px; }
.sidebar-foot .userline { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linkish { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0; font-size: 12px; text-align: left; text-decoration: underline; text-underline-offset: 3px; }
.linkish:hover { color: var(--ink); }

#main { padding: 8px 4px 40px; min-width: 0; }

/* Seiten-Übergang */
.view-enter { animation: view-in .38s var(--ease-out) both; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(14px) scale(.995); }
  to { opacity: 1; transform: none; }
}
.rise { animation: rise .5s var(--ease-out) both; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
h1.page-title { font-family: var(--font-display); font-weight: 700; font-size: 28px; margin: 0; letter-spacing: -.02em; }
.page-sub { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
h2.section-title { font-family: var(--font-display); font-size: 16px; font-weight: 600; margin: 26px 0 12px; letter-spacing: -.01em; }

/* ---------- Cards & Tiles ---------- */
.card { border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 12px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 12px; }
.stat-tile { border-radius: var(--radius); padding: 14px 16px; transition: transform .25s var(--ease-spring); }
.stat-tile:hover { transform: translateY(-2px); }
.stat-tile .v { font-family: var(--font-display); font-size: 25px; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; }
.stat-tile .v small { font-size: 14px; color: var(--muted); font-family: var(--font-body); font-weight: 400; }
.stat-tile .l { color: var(--muted); font-size: 12px; margin-top: 3px; }

.hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius-l);
  padding: 26px 26px 22px; margin-bottom: 14px;
  background: linear-gradient(135deg, var(--glass-strong), var(--glass));
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.7);
  backdrop-filter: blur(var(--blur)) saturate(1.7);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-highlight), var(--glass-shadow);
}
.hero::after {
  content: ""; position: absolute; top: -60%; left: -20%;
  width: 60%; height: 220%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.10), transparent);
  transform: rotate(12deg);
  animation: sheen 7s ease-in-out infinite;
  pointer-events: none;
}
@keyframes sheen { 0%, 55%, 100% { translate: 0 0; } 25% { translate: 160% 0; } }
.hero .eyebrow { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.hero .big { font-family: var(--font-display); font-size: clamp(32px, 5.5vw, 50px); font-weight: 700; line-height: 1.08; margin: 8px 0 6px; letter-spacing: -.025em; }
.hero .sub { color: var(--muted); font-size: 14px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 999px; padding: 10px 18px;
  font-size: 14.5px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent;
  transition: transform .25s var(--ease-spring), filter .15s, box-shadow .25s;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(160deg, #f3cd7e, var(--accent));
  color: var(--accent-ink);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 8px 22px rgba(210,160,60,.30);
}
[data-theme="light"] .btn-primary { background: linear-gradient(160deg, #cc9a30, var(--accent)); color: #fff; }
.btn-secondary {
  background: var(--glass); border-color: var(--glass-border); color: var(--ink);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.btn-danger { background: none; border-color: var(--danger); color: var(--danger); }
.btn-ghost { background: none; color: var(--muted); border: none; }
.btn-ghost:hover { color: var(--ink); }
.btn.small { padding: 6px 13px; font-size: 13px; }
.btn.big { padding: 14px 28px; font-size: 16px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.field input, .field select, .field textarea, .toolbar input, .toolbar select, .settings-row select, .settings-row input {
  width: 100%;
  background: rgba(0,0,0,.22);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-s);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
[data-theme="light"] .field input, [data-theme="light"] .field select, [data-theme="light"] .field textarea,
[data-theme="light"] .toolbar input, [data-theme="light"] .toolbar select,
[data-theme="light"] .settings-row select, [data-theme="light"] .settings-row input {
  background: rgba(255,255,255,.6);
}
.field input:focus, .field select:focus, .field textarea:focus, .toolbar input:focus, .toolbar select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { resize: vertical; min-height: 66px; }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 9px; font-size: 14px; }
.checkbox-row input { width: 17px; height: 17px; accent-color: var(--accent); }

.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid var(--glass-border);
  background: var(--glass); color: var(--muted);
  border-radius: 999px; padding: 6px 13px; font-size: 13px; cursor: pointer;
  transition: transform .22s var(--ease-spring), background .15s, color .15s;
}
.chip:hover { transform: translateY(-1px); color: var(--ink); }
.chip.active {
  background: linear-gradient(160deg, #f3cd7e, var(--accent));
  border-color: transparent; color: var(--accent-ink); font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5);
}
[data-theme="light"] .chip.active { background: linear-gradient(160deg, #cc9a30, var(--accent)); color: #fff; }

/* ---------- Rows / Lists ---------- */
.row-list { display: flex; flex-direction: column; gap: 10px; }
.item-row {
  display: flex; align-items: center; gap: 14px;
  border-radius: var(--radius); padding: 13px 16px;
  cursor: pointer;
  transition: transform .28s var(--ease-spring), background .18s;
}
.item-row:hover { transform: translateY(-2px) scale(1.005); background: var(--glass-strong); }
.item-row .grow { flex: 1; min-width: 0; }
.item-row .t { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-row .s { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.item-row .num { font-family: var(--font-num); font-size: 13px; text-align: right; white-space: nowrap; color: var(--muted); }

.badge { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2.5px 9px; letter-spacing: .02em; }
.badge.roast-light { background: rgba(236,182,79,.18); color: var(--accent); }
.badge.roast-medium { background: rgba(200,140,80,.20); color: #d29a68; }
.badge.roast-dark { background: rgba(150,100,70,.22); color: #b3866b; }
[data-theme="light"] .badge.roast-medium { color: #9a6532; }
[data-theme="light"] .badge.roast-dark { color: #7c4f33; }
.badge.judg-perfect { background: rgba(120,210,130,.16); color: var(--good); }
.badge.judg-under { background: rgba(120,170,240,.16); color: var(--sour); }
.badge.judg-over { background: rgba(240,140,110,.16); color: var(--bitter); }
.badge.neutral { background: var(--glass); border: 1px solid var(--glass-border); color: var(--muted); }

.stars { color: var(--accent); letter-spacing: 1px; font-size: 13px; }
.stars .off { color: var(--faint); }

.empty {
  border: 1.5px dashed var(--glass-border); border-radius: var(--radius);
  padding: 36px 22px; text-align: center; color: var(--muted); font-size: 14px;
}
.empty .btn { margin: 12px 5px 0; }

/* ---------- Timer ---------- */
.timer-wrap { display: flex; flex-direction: column; align-items: center; gap: 20px; padding: 14px 0 4px; }
.dial { position: relative; width: min(300px, 76vw); filter: drop-shadow(0 14px 30px rgba(0,0,0,.35)); }
.dial svg { width: 100%; height: auto; display: block; }
.dial .readout { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.dial .readout .time { font-family: var(--font-num); font-size: clamp(40px, 9vw, 56px); font-weight: 600; font-variant-numeric: tabular-nums; }
.dial .readout .phase { color: var(--muted); font-size: 12.5px; letter-spacing: .12em; text-transform: uppercase; }
.timer-actions { display: flex; gap: 12px; }

/* ---------- Charts ---------- */
.chart-card { border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.chart-card h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.chart-card .desc { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }
.chart-card svg { width: 100%; height: auto; display: block; }
.chart-card svg text { font-family: var(--font-body); }

/* ---------- Sheet ---------- */
#sheet-root:empty { display: none; }
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(6,6,10,.55);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 50;
  animation: fade-in .2s ease;
}
@keyframes fade-in { from { opacity: 0; } }
.sheet {
  border-radius: 26px 26px 0 0;
  width: 100%; max-width: 660px;
  max-height: 92dvh; overflow-y: auto;
  padding: 22px 22px calc(26px + env(safe-area-inset-bottom));
  background: rgba(24,25,33,.78);
  animation: sheet-in .42s var(--ease-spring);
}
[data-theme="light"] .sheet { background: rgba(248,249,253,.82); }
@keyframes sheet-in { from { transform: translateY(48px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 720px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 26px; padding-bottom: 26px; }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sheet-head h2 { font-family: var(--font-display); font-size: 20px; margin: 0; letter-spacing: -.01em; }
.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; flex-wrap: wrap; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: calc(84px + env(safe-area-inset-bottom)); left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 90; pointer-events: none; }
@media (min-width: 861px) { #toast-root { bottom: 30px; } }
.toast { border-radius: 999px; padding: 10px 20px; font-size: 13.5px; animation: toast-in .35s var(--ease-spring); }
@keyframes toast-in { from { transform: translateY(12px) scale(.95); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Prediction ---------- */
.pred-result { text-align: center; padding: 26px 18px; border-radius: var(--radius-l); }
.pred-result .val {
  font-family: var(--font-display); font-size: 58px; font-weight: 700; line-height: 1;
  background: linear-gradient(160deg, #f6d992, var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: pop-in .5s var(--ease-spring);
}
@keyframes pop-in { from { transform: scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }
.pred-result .lab { color: var(--muted); font-size: 13px; margin-top: 8px; }
.conf-bar { height: 7px; background: rgba(0,0,0,.25); border-radius: 4px; overflow: hidden; margin: 14px auto 0; max-width: 300px; }
[data-theme="light"] .conf-bar { background: rgba(0,0,0,.10); }
.conf-bar > div { height: 100%; background: linear-gradient(90deg, #f3cd7e, var(--accent)); border-radius: 4px; transition: width .7s var(--ease-out); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; gap: 9px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type="search"] { flex: 1; min-width: 150px; width: auto; }
.toolbar select { width: auto; }

/* ---------- Settings ---------- */
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--glass-border); }
.settings-row:last-child { border-bottom: none; }
.settings-row .t { font-weight: 600; font-size: 14.5px; }
.settings-row .s { color: var(--muted); font-size: 12.5px; max-width: 430px; }
.settings-row select, .settings-row input { width: auto; }

/* ---------- Auth ---------- */
#auth-root:empty { display: none; }
.auth-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 22px; }
.auth-card {
  width: 100%; max-width: 420px; border-radius: 28px; padding: 30px 28px;
  animation: rise .6s var(--ease-out) both;
}
.auth-card .brand { margin-bottom: 20px; padding: 0; }
.auth-card h1 { font-family: var(--font-display); font-size: 23px; margin: 0 0 4px; letter-spacing: -.02em; }
.auth-card .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 20px; }
.auth-card .field { margin-bottom: 12px; }
.auth-card .btn { width: 100%; margin-top: 6px; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 13px; color: var(--muted); }
.auth-error { color: var(--danger); font-size: 13px; margin-top: 10px; text-align: center; min-height: 18px; }
.auth-lang { position: fixed; top: 18px; right: 20px; z-index: 5; }
.setup-note { max-width: 560px; }
.setup-note code { background: rgba(0,0,0,.3); border-radius: 6px; padding: 2px 6px; font-size: 12.5px; }
[data-theme="light"] .setup-note code { background: rgba(0,0,0,.08); }

/* Sync-Indikator */
.sync-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--good); margin-right: 6px; }
.sync-dot.busy { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.sync-dot.err { background: var(--danger); }
@keyframes pulse { 50% { opacity: .4; } }

/* ---------- Mobile ---------- */
#nav-mobile { display: none; }
@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; padding: 14px 14px calc(96px + env(safe-area-inset-bottom)); gap: 0; }
  #sidebar { display: none; }
  #main { padding: 4px 0 0; }
  #nav-mobile {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; bottom: 12px; left: 12px; right: 12px; z-index: 40;
    border-radius: 24px;
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom) / 2);
  }
  .mnav-item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    background: none; border: none; color: var(--muted);
    font-size: 10.5px; padding: 6px 2px; cursor: pointer; border-radius: 14px;
    transition: color .15s, transform .25s var(--ease-spring);
  }
  .mnav-item:active { transform: scale(.92); }
  .mnav-item .ico { font-size: 19px; line-height: 1; }
  .mnav-item.active { color: var(--accent); font-weight: 600; }
  h1.page-title { font-size: 24px; }
}
@media (max-width: 420px) { .form-grid { grid-template-columns: 1fr; } }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

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