/* Arroa Eskola — diseinu sinplea eta argia */

:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #f0f2ef;
  --text: #1a1d1b;
  --text-dim: #666d69;
  --line: #e2e5e1;
  --accent: #1f6f4a;
  --accent-soft: rgba(31, 111, 74, .1);
  --danger: #c8483d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 6px 18px rgba(0, 0, 0, .05);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1613;
    --surface: #18211d;
    --surface-2: #212b26;
    --text: #eaefec;
    --text-dim: #98a49e;
    --line: #2a352f;
    --accent: #5fbd8c;
    --accent-soft: rgba(95, 189, 140, .14);
    --danger: #e8776b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .28);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1613;
  --surface: #18211d;
  --surface-2: #212b26;
  --text: #eaefec;
  --text-dim: #98a49e;
  --line: #2a352f;
  --accent: #5fbd8c;
  --accent-soft: rgba(95, 189, 140, .14);
  --danger: #e8776b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .28);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(64px + var(--safe-b));
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
button { font: inherit; color: inherit; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: var(--safe-t);
}
.topbar-inner { padding: 12px 16px 10px; }
.topbar h1 { font-size: 22px; }
.topbar-sub { margin: 2px 0 0; font-size: 13px; color: var(--text-dim); }

/* ---------- Views ---------- */
.view { padding: 14px 16px 24px; max-width: 640px; margin: 0 auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card-title {
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-dim); margin-bottom: 10px;
}

/* Eguneko goiburua */
.day-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.day-head .date { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.day-head .dow { font-size: 15px; color: var(--text-dim); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px;
  font-size: 13px; font-weight: 600; line-height: 1.3;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.day-hours { margin-top: 10px; font-size: 14px; color: var(--text-dim); }
.day-hours strong { color: var(--text); font-weight: 600; }

/* HF banner */
.hf-banner {
  display: flex; gap: 12px; align-items: flex-start;
  background: linear-gradient(135deg, #2f7fb8, #1f6f9e);
  color: #fff; border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.hf-banner .big { font-size: 26px; line-height: 1; }
.hf-banner h3 { font-size: 17px; margin-bottom: 4px; }
.hf-banner ol { margin: 6px 0 0; padding-left: 20px; font-size: 14px; }
.hf-banner li { margin: 2px 0; }
.hf-banner .kit-label { font-size: 13px; opacity: .9; }

/* Ordutegia */
.sched { list-style: none; margin: 0; padding: 0; }
.sched li {
  display: grid; grid-template-columns: 92px 1fr; gap: 12px;
  padding: 9px 0; border-top: 1px solid var(--line); align-items: center;
}
.sched li:first-child { border-top: 0; }
.sched .time { font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.sched .subj { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.sched .swatch { width: 4px; align-self: stretch; min-height: 20px; border-radius: 2px; }
.sched li.is-break .subj, .sched li.is-lunch .subj { color: var(--text-dim); }
.sched li.is-hf { background: var(--accent-soft); margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 8px; }
.sched li.is-hf .subj { font-weight: 650; }
.sched li.is-now { position: relative; }
.sched li.is-now::before {
  content: ''; position: absolute; left: -16px; top: 50%; transform: translateY(-50%);
  width: 6px; height: 6px; border-radius: 50%; background: var(--danger);
}

.empty { text-align: center; color: var(--text-dim); padding: 26px 10px; font-size: 15px; }
.empty .big { font-size: 40px; display: block; margin-bottom: 8px; }

/* ---------- Egutegia ---------- */
.month-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px;
}
.month-nav span { font-size: 17px; font-weight: 650; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font-size: 20px; line-height: 1; cursor: pointer;
}
.icon-btn:disabled { opacity: .35; cursor: default; }

.cal {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow);
}
.cal .dow-h {
  text-align: center; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  color: var(--text-dim); padding-bottom: 4px; text-transform: uppercase;
}
.cal-day {
  aspect-ratio: 1 / 1; border: 0; border-radius: 9px; cursor: pointer;
  background: transparent; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; padding: 0;
  font-variant-numeric: tabular-nums;
}
.cal-day .n { font-size: 14px; font-weight: 600; }
.cal-day .marks { display: flex; gap: 2px; height: 5px; }
.cal-day .marks i { width: 5px; height: 5px; border-radius: 50%; display: block; }
.cal-day.is-empty { visibility: hidden; }
.cal-day.is-out .n { color: var(--text-dim); opacity: .5; }
.cal-day.is-today { outline: 2px solid var(--accent); outline-offset: -2px; }

.legend { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.legend .item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; }

/* ---------- Menua ---------- */
.menu-day { font-size: 15px; font-weight: 650; margin-bottom: 2px; }
.menu-course { margin: 12px 0 0; }
.menu-course:first-child { margin-top: 0; }
.menu-course h4 {
  margin: 0 0 3px; font-size: 11.5px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-dim);
}
.menu-course p { margin: 0; font-size: 15px; }
.menu-course .side { color: var(--text-dim); font-size: 14px; }
.nutri { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.nutri span { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.src { text-align: center; font-size: 12px; color: var(--text-dim); margin-top: 4px; }

/* ---------- Ezarpenak ---------- */
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 0; border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
.row .label { font-size: 15px; }
.row .help { font-size: 13px; color: var(--text-dim); margin-top: 3px; line-height: 1.35; }
.row .grow { flex: 1; min-width: 0; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button {
  border: 0; background: transparent; border-radius: 8px; padding: 6px 14px;
  font-size: 14px; font-weight: 600; cursor: pointer; color: var(--text-dim);
}
.seg button.is-on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch .track {
  position: absolute; inset: 0; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; transition: background .18s;
}
.switch .track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s;
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:disabled + .track { opacity: .45; }

select, input[type="time"] {
  font: inherit; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
}
.btn {
  display: inline-block; width: 100%; padding: 12px 16px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--surface-2); cursor: pointer;
  font-size: 15px; font-weight: 600;
}
.btn:disabled { opacity: .5; cursor: default; }
.note {
  font-size: 13px; line-height: 1.4; color: var(--text-dim);
  background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin-top: 12px;
}
.note.warn { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tab {
  border: 0; background: none; cursor: pointer; padding: 8px 4px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-dim);
}
.tab-ico { font-size: 20px; line-height: 1; }
.tab-lbl { font-size: 11px; font-weight: 600; }
.tab.is-active { color: var(--accent); }

/* ---------- Sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  background: var(--surface); border-radius: 18px 18px 0 0;
  padding: 18px 18px calc(22px + var(--safe-b));
  max-height: 82vh; overflow-y: auto;
  box-shadow: 0 -8px 32px rgba(0,0,0,.2);
  max-width: 640px; margin: 0 auto;
  animation: rise .2s ease-out;
}
@keyframes rise { from { transform: translateY(16px); opacity: .6; } }
.sheet-close {
  position: absolute; top: 12px; right: 14px; width: 30px; height: 30px;
  border: 0; border-radius: 50%; background: var(--surface-2);
  font-size: 19px; line-height: 1; cursor: pointer; color: var(--text-dim);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(78px + var(--safe-b)); z-index: 50;
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 500;
  max-width: 88vw; text-align: center; box-shadow: var(--shadow);
}

.spinner {
  width: 22px; height: 22px; margin: 24px auto; border-radius: 50%;
  border: 2.5px solid var(--line); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
