/* ============================================================
   Hub — design system
   Concept: an atoll seen from above. Deep water, a bright lagoon
   ring, sand. Glass panels float over a slow tidal light field.
   Controls are pills; surfaces are wide-radius glass.
   ============================================================ */

/* ---------- tokens ---------- */
:root {
  /* base palette */
  --trench:   #04101a;
  --deep:     #071b28;
  --hull:     #0d2a3c;
  --lagoon:   #17c6c4;
  --lagoon-d: #0b8f97;
  --shallow:  #6fe3d6;
  --sand:     #f2e7d3;
  --crimson:  #e4212f;
  --coral:    #ff7a5c;
  --dusk:     #7b5cff;

  /* semantic (dark is the origin theme) */
  --bg:        #061019;
  --bg-2:      #08182a;
  --fg:        #eaf6f8;
  --fg-dim:    #9fb6c2;
  --fg-faint:  #6b8494;
  --line:      rgba(255,255,255,.10);
  --line-2:    rgba(255,255,255,.055);
  --glass:     rgba(255,255,255,.055);
  --glass-2:   rgba(255,255,255,.085);
  --glass-hi:  rgba(255,255,255,.16);
  --accent:    var(--lagoon);
  --accent-ink:#00201f;
  --alert:     var(--crimson);
  --ok:        #3ddc97;
  --warn:      #ffb84d;

  --blur: 22px;
  --sat: 1.45;

  /* radii — three steps only, each meaning something */
  --r-pill: 999px;
  --r-card: 26px;
  --r-sheet: 34px;

  /* spacing */
  --gap: 14px;
  --pad: 18px;
  --shell: 560px;

  /* elevation: one soft ambient + one tight contact shadow */
  --lift-1: 0 1px 0 rgba(255,255,255,.06) inset, 0 10px 30px -18px rgba(0,0,0,.9);
  --lift-2: 0 1px 0 rgba(255,255,255,.09) inset, 0 24px 60px -28px rgba(0,0,0,.95);

  --type-display: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --type-body: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  --scale: 1;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

[data-theme="light"] {
  --bg:       #e9f2f4;
  --bg-2:     #dbeaee;
  --fg:       #082230;
  --fg-dim:   #476271;
  --fg-faint: #7893a2;
  --line:     rgba(8,34,48,.12);
  --line-2:   rgba(8,34,48,.07);
  --glass:    rgba(255,255,255,.58);
  --glass-2:  rgba(255,255,255,.75);
  --glass-hi: rgba(255,255,255,.9);
  --accent-ink: #00201f;
  --lift-1: 0 1px 0 rgba(255,255,255,.9) inset, 0 10px 26px -18px rgba(6,40,55,.55);
  --lift-2: 0 1px 0 rgba(255,255,255,.9) inset, 0 26px 60px -30px rgba(6,40,55,.5);
  --ok: #0f9b6c;
}

/* accent choices offered in settings */
[data-accent="lagoon"] { --accent: #17c6c4; --accent-ink: #00201f; }
[data-accent="coral"]  { --accent: #ff7a5c; --accent-ink: #2b0a02; }
[data-accent="dusk"]   { --accent: #8c76ff; --accent-ink: #120436; }
[data-accent="sand"]   { --accent: #f0cf8b; --accent-ink: #241a04; }
[data-accent="crimson"]{ --accent: #ff4757; --accent-ink: #2a0207; }

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--type-body);
  font-size: calc(15px * var(--scale));
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}
h1,h2,h3,h4 { font-family: var(--type-display); font-weight: 600; letter-spacing: -.02em; margin: 0; line-height: 1.12; }
h1 { font-size: calc(28px * var(--scale)); letter-spacing: -.035em; }
h2 { font-size: calc(21px * var(--scale)); letter-spacing: -.028em; }
h3 { font-size: calc(17px * var(--scale)); letter-spacing: -.02em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
::selection { background: color-mix(in srgb, var(--accent) 40%, transparent); }

.skip {
  position: fixed; left: 12px; top: -60px; z-index: 999;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; border-radius: var(--r-pill); font-weight: 600;
  transition: top .18s;
}
.skip:focus { top: calc(12px + var(--safe-t)); }
.noscript { padding: 40px; text-align: center; }

/* ---------- ambient field ---------- */
.ambient { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: radial-gradient(120% 90% at 50% 0%, var(--bg-2), var(--bg) 62%); }
.ambient__blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; }
.ambient__blob--a { width: 62vmax; height: 62vmax; left: -22vmax; top: -26vmax; background: radial-gradient(circle, var(--accent), transparent 66%); opacity: .34; animation: drift-a 34s ease-in-out infinite alternate; }
.ambient__blob--b { width: 46vmax; height: 46vmax; right: -18vmax; top: 22vh; background: radial-gradient(circle, var(--crimson), transparent 68%); opacity: .2; animation: drift-b 42s ease-in-out infinite alternate; }
.ambient__blob--c { width: 54vmax; height: 54vmax; left: 12vw; bottom: -30vmax; background: radial-gradient(circle, #2b6cff, transparent 70%); opacity: .22; animation: drift-c 50s ease-in-out infinite alternate; }
.ambient__grain {
  position: absolute; inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E");
  opacity: .16; mix-blend-mode: overlay;
}
[data-theme="light"] .ambient__grain { opacity: .3; mix-blend-mode: multiply; }
@keyframes drift-a { to { transform: translate3d(14vw, 8vh, 0) scale(1.14); } }
@keyframes drift-b { to { transform: translate3d(-12vw, -10vh, 0) scale(1.2); } }
@keyframes drift-c { to { transform: translate3d(9vw, -12vh, 0) scale(.88); } }

/* ---------- shell ---------- */
.app { min-height: 100dvh; }
.shell { max-width: var(--shell); margin: 0 auto; padding: 0 16px; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  padding: calc(10px + var(--safe-t)) 16px 8px;
  max-width: var(--shell); margin: 0 auto;
}
.topbar__inner {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 16px;
  border-radius: var(--r-pill);
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: var(--lift-1);
  backdrop-filter: blur(var(--blur)) saturate(var(--sat));
  -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--sat));
}
.topbar__title { flex: 1; min-width: 0; }
.topbar__title h1 { font-size: calc(19px * var(--scale)); }
.topbar__title span { display: block; font-size: 12px; color: var(--fg-faint); }

main { padding-bottom: calc(120px + var(--safe-b)); }
.view { animation: view-in .34s cubic-bezier(.2,.8,.25,1) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- floating pill navigation ---------- */
.nav {
  position: fixed; z-index: 60;
  left: 50%; transform: translateX(-50%);
  bottom: calc(14px + var(--safe-b));
  display: flex; gap: 2px; padding: 6px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--bg) 52%, transparent);
  border: 1px solid var(--glass-hi);
  box-shadow: var(--lift-2);
  backdrop-filter: blur(26px) saturate(1.7);
  -webkit-backdrop-filter: blur(26px) saturate(1.7);
}
.nav__item {
  position: relative; z-index: 1;
  display: grid; place-items: center; gap: 2px;
  width: 62px; padding: 8px 0 7px;
  border-radius: var(--r-pill);
  color: var(--fg-faint);
  transition: color .2s;
}
.nav__item svg { width: 21px; height: 21px; }
.nav__item b { font-size: 10px; font-weight: 600; letter-spacing: -.01em; }
.nav__item[aria-current="page"] { color: var(--accent-ink); }
.nav__pill {
  position: absolute; z-index: 0; top: 6px; bottom: 6px; left: 6px;
  width: 62px; border-radius: var(--r-pill);
  background: var(--accent);
  box-shadow: 0 8px 22px -10px var(--accent);
  transition: transform .38s cubic-bezier(.3,1.3,.4,1);
}
.nav__dot { position: absolute; top: 7px; right: 12px; width: 7px; height: 7px; border-radius: 50%; background: var(--crimson); border: 1.5px solid var(--bg); }

@media (min-width: 940px) {
  :root { --shell: 720px; }
  .nav { left: max(20px, calc(50vw - 560px)); bottom: 50%; transform: translateY(50%); flex-direction: column; }
  .nav__pill { top: 6px; left: 6px; right: 6px; width: auto; height: 58px; bottom: auto; }
  .nav__item { width: 68px; padding: 10px 0; }
  main { padding-bottom: 60px; }
}

/* ---------- glass surfaces ---------- */
.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--lift-1);
  backdrop-filter: blur(var(--blur)) saturate(var(--sat));
  -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--sat));
}
.glass--solid { background: var(--glass-2); }
.card { padding: var(--pad); }
.stack { display: grid; gap: var(--gap); }
.row { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.section { margin-top: 22px; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; padding: 0 4px; }
.section__head p { font-size: 12.5px; color: var(--fg-faint); }
.muted { color: var(--fg-dim); }
.faint { color: var(--fg-faint); }
.tiny { font-size: 12px; }
.num { font-family: var(--type-display); font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divide { height: 1px; background: var(--line-2); margin: 4px 0; }

/* ---------- pills & buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px;
  border-radius: var(--r-pill);
  font-weight: 600; font-size: 14.5px; letter-spacing: -.01em;
  background: var(--glass-2); border: 1px solid var(--line);
  backdrop-filter: blur(12px);
  transition: transform .16s cubic-bezier(.2,.8,.2,1), background .2s, opacity .2s;
}
.btn:active { transform: scale(.96); }
.btn svg { width: 18px; height: 18px; }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: 0 12px 26px -14px var(--accent); }
.btn--alert { background: var(--crimson); color: #fff; border-color: transparent; box-shadow: 0 12px 26px -14px var(--crimson); }
.btn--ghost { background: transparent; }
.btn--block { width: 100%; }
.btn--sm { min-height: 34px; padding: 0 14px; font-size: 13px; }
.btn--icon { width: 40px; min-height: 40px; padding: 0; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 13px; border-radius: var(--r-pill);
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  background: var(--glass); border: 1px solid var(--line); color: var(--fg-dim);
  transition: background .18s, color .18s, transform .16s;
}
.chip:active { transform: scale(.95); }
.chip[aria-pressed="true"], .chip--on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.chip--alert { background: color-mix(in srgb, var(--crimson) 22%, transparent); color: color-mix(in srgb, var(--crimson) 88%, var(--fg)); border-color: color-mix(in srgb, var(--crimson) 34%, transparent); }
.chip--ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: color-mix(in srgb, var(--ok) 92%, var(--fg)); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.chip--sm { height: 26px; padding: 0 10px; font-size: 11.5px; }
.chip__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.scroller { display: flex; gap: 8px; overflow-x: auto; padding: 2px 4px 8px; scroll-snap-type: x proximity; scrollbar-width: none; }
.scroller::-webkit-scrollbar { display: none; }
.scroller > * { scroll-snap-align: start; flex: none; }

/* ---------- form ---------- */
.field { display: grid; gap: 6px; }
.field > label { font-size: 12.5px; color: var(--fg-dim); padding-left: 14px; }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 11px 16px;
  border-radius: var(--r-pill);
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  transition: border-color .2s, background .2s;
}
.textarea { border-radius: 22px; resize: vertical; min-height: 92px; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); outline: none; }
.input::placeholder, .textarea::placeholder { color: var(--fg-faint); }
.select { appearance: none; background-image: none; }
.search { position: relative; }
.search svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--fg-faint); pointer-events: none; }
.search .input { padding-left: 42px; }

.switch { position: relative; width: 48px; height: 28px; flex: none; border-radius: var(--r-pill); background: var(--glass-2); border: 1px solid var(--line); transition: background .22s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--fg-faint); transition: transform .26s cubic-bezier(.3,1.4,.5,1), background .22s; }
.switch[aria-checked="true"] { background: var(--accent); border-color: transparent; }
.switch[aria-checked="true"]::after { transform: translateX(20px); background: var(--accent-ink); }

.segmented { display: flex; padding: 4px; gap: 3px; border-radius: var(--r-pill); background: var(--glass); border: 1px solid var(--line); }
.segmented button { flex: 1; height: 34px; border-radius: var(--r-pill); font-size: 13px; font-weight: 600; color: var(--fg-dim); transition: background .2s, color .2s; }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* ---------- list rows ---------- */
.tile {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  padding: 13px 15px; border-radius: 20px;
  background: var(--glass); border: 1px solid var(--line-2);
  transition: transform .16s, background .2s;
}
.tile:active { transform: scale(.985); }
.tile__icon { width: 40px; height: 40px; flex: none; border-radius: 14px; display: grid; place-items: center; background: var(--glass-2); color: var(--accent); }
.tile__icon svg { width: 19px; height: 19px; }
.tile__meta { font-size: 12.5px; color: var(--fg-faint); }
.tile__chev { color: var(--fg-faint); }

/* ---------- sheets ---------- */
.sheet-scrim { position: fixed; inset: 0; z-index: 90; background: rgba(2,10,16,.55); backdrop-filter: blur(3px); animation: fade .22s both; }
.sheet {
  position: fixed; z-index: 91; left: 0; right: 0; bottom: 0;
  max-width: var(--shell); margin: 0 auto;
  max-height: 88dvh; display: flex; flex-direction: column;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border: 1px solid var(--glass-hi); border-bottom: 0;
  box-shadow: var(--lift-2);
  backdrop-filter: blur(30px) saturate(1.6);
  -webkit-backdrop-filter: blur(30px) saturate(1.6);
  animation: sheet-up .38s cubic-bezier(.2,.9,.25,1) both;
  padding-bottom: var(--safe-b);
}
.sheet__grip { width: 40px; height: 4px; border-radius: 99px; background: var(--glass-hi); margin: 10px auto 4px; flex: none; }
.sheet__head { padding: 6px 20px 10px; display: flex; align-items: flex-start; gap: 12px; }
.sheet__body { padding: 4px 18px 22px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet__foot { padding: 12px 18px calc(16px + var(--safe-b)); border-top: 1px solid var(--line-2); display: flex; gap: 10px; }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
@media (min-width: 940px) {
  .sheet { bottom: 24px; border-radius: var(--r-sheet); border-bottom: 1px solid var(--glass-hi); max-height: 82dvh; }
}

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 95; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-b)); display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 16px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  border: 1px solid var(--glass-hi); box-shadow: var(--lift-2);
  backdrop-filter: blur(20px) saturate(1.6);
  font-size: 13.5px; font-weight: 600;
  animation: toast-in .3s cubic-bezier(.2,1.2,.3,1) both;
}
.toast svg { width: 17px; height: 17px; flex: none; color: var(--accent); }
.toast--alert svg { color: var(--crimson); }
.toast.is-out { animation: toast-out .24s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.94); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.96); } }
@media (min-width: 940px) { .toasts { bottom: 24px; } }

/* ---------- boot ---------- */
.boot { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 18px; }
.boot__ring { width: 92px; height: 92px; fill: none; stroke: var(--accent); stroke-width: 2; opacity: .9; }
.boot__ring circle { stroke-dasharray: 40 200; transform-origin: 60px 60px; animation: spin 2.6s linear infinite; }
.boot__ring circle:nth-child(2) { animation-duration: 2s; animation-direction: reverse; opacity: .6; }
.boot__ring circle:nth-child(3) { animation-duration: 1.4s; opacity: .35; }
.boot__label { font-size: 13px; color: var(--fg-faint); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- command palette ---------- */
.palette { position: fixed; inset: 0; z-index: 100; display: grid; align-items: start; justify-items: center; padding: 12vh 16px; background: rgba(2,10,16,.5); backdrop-filter: blur(4px); animation: fade .18s both; }
.palette__box { width: min(520px, 100%); border-radius: 28px; overflow: hidden; background: color-mix(in srgb, var(--bg) 80%, transparent); border: 1px solid var(--glass-hi); box-shadow: var(--lift-2); backdrop-filter: blur(30px) saturate(1.6); animation: pal-in .26s cubic-bezier(.2,1,.3,1) both; }
@keyframes pal-in { from { opacity: 0; transform: translateY(-12px) scale(.97); } }
.palette__input { width: 100%; border: 0; background: none; padding: 18px 22px; font-size: 16px; outline: none; }
.palette__list { max-height: 46vh; overflow-y: auto; padding: 6px; border-top: 1px solid var(--line-2); }
.palette__row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px; border-radius: 16px; text-align: left; }
.palette__row[data-active="true"] { background: var(--glass-2); }
.palette__row svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.palette__row span { font-size: 12px; color: var(--fg-faint); margin-left: auto; }

/* ---------- misc ---------- */
.avatar { width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center; font-family: var(--type-display); font-weight: 600; font-size: 14px; color: var(--accent-ink); background: linear-gradient(150deg, var(--accent), color-mix(in srgb, var(--accent) 40%, var(--dusk))); }
.avatar--lg { width: 72px; height: 72px; font-size: 26px; }
.empty { display: grid; justify-items: center; gap: 12px; padding: 44px 24px; text-align: center; }
.empty svg { width: 30px; height: 30px; color: var(--accent); }
.badge-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--crimson); color: #fff; font-size: 11px; font-weight: 700; }
.bar { height: 6px; border-radius: 99px; background: var(--glass-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width .6s cubic-bezier(.2,.8,.2,1); }

@media (prefers-reduced-motion: reduce), (max-width: 1px) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
[data-motion="reduced"] .ambient__blob { animation: none; }
[data-motion="reduced"] *, [data-motion="reduced"] *::before, [data-motion="reduced"] *::after { animation-duration: .01ms !important; transition-duration: .06s !important; }

/* Thaana / Dhivehi runs right to left */
[dir="rtl"] .tile, [dir="rtl"] .row { direction: rtl; }
[dir="rtl"] .field > label { padding-left: 0; padding-right: 14px; }
[dir="rtl"] .search svg { left: auto; right: 15px; }
[dir="rtl"] .search .input { padding-left: 16px; padding-right: 42px; }
[dir="rtl"] body { font-family: "MV Faseyha", "A_Faruma", var(--type-body); }

/* ---------- icon sizing inside flex rows ----------
   Bare icons that are direct children of a flex row need an
   explicit box, or they expand to fill the row. */
.tile > svg, .tile__chev, .rank > svg, .note > svg { width: 18px; height: 18px; flex: none; }
.chip svg { width: 14px; height: 14px; flex: none; }
.sev svg { width: 13px; height: 13px; flex: none; }
.course__badge svg { width: 14px; height: 14px; flex: none; }
.setrow > svg { width: 18px; height: 18px; flex: none; }
.toast svg, .btn svg, .empty svg { flex: none; }
