/* ===================== Tokens ===================== */
:root {
  --font-display: 'Alexandria', 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;

  --radius-lg: 26px;
  --radius: 18px;
  --radius-sm: 12px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.4, .5, 1);

  --c-blue: #6f8ff2;
  --c-purple: #a585ef;
  --c-emerald: #4fb48b;
  --c-amber: #e0a446;
  --c-pink: #e07ba8;
  --c-cyan: #4db5c9;
  --c-rose: #e5766b;
  --c-lime: #9cbc4a;
}

[data-theme='dark'] {
  color-scheme: dark;
  --bg: #12110e;
  --bg-2: #18160f;
  --surface: #1c1a15;
  --surface-2: #24221c;
  --line: #302d25;
  --line-soft: #26241e;
  --text: #f3ede0;
  --muted: #a39b8b;
  --faint: #6f695d;
  --accent: #e3b85e;
  --accent-ink: #1a1508;
  --accent-soft: rgba(227, 184, 94, .13);
  --danger: #ef7d6d;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, .7), 0 2px 0 rgba(255, 255, 255, .02) inset;
  --grain-op: .07;
  --tint: 18%;
}

[data-theme='light'] {
  color-scheme: light;
  --bg: #f5f0e6;
  --bg-2: #efe8da;
  --surface: #fffcf5;
  --surface-2: #f6f0e4;
  --line: #e3dacb;
  --line-soft: #ece5d8;
  --text: #1e1b15;
  --muted: #6c6457;
  --faint: #a49b8c;
  --accent: #a0701a;
  --accent-ink: #fffaf0;
  --accent-soft: rgba(160, 112, 26, .1);
  --danger: #c2483a;
  --shadow: 0 18px 40px -22px rgba(70, 50, 20, .35);
  --grain-op: .045;
  --tint: 13%;
  --c-blue: #4a6ae0;
  --c-purple: #8159d6;
  --c-emerald: #2c9468;
  --c-amber: #c27f17;
  --c-pink: #c9507f;
  --c-cyan: #23889c;
  --c-rose: #cc5244;
  --c-lime: #6f9020;
}

/* ===================== Base ===================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  padding-bottom: calc(110px + env(safe-area-inset-bottom));
  transition: background-color .4s var(--ease), color .4s var(--ease);
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 10px; }
[hidden] { display: none !important; }
.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: .01em; }

.ico { width: 1.15em; height: 1.15em; flex: none; display: inline-block; vertical-align: -.2em; }
.ico svg { width: 100%; height: 100%; display: block; }

/* Atmosphere */
.atmos {
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(900px 500px at 110% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(700px 500px at -20% 30%, color-mix(in srgb, var(--c-blue) 8%, transparent), transparent 60%),
    var(--bg);
}
.grain {
  position: fixed; inset: -50%; z-index: -1; pointer-events: none; opacity: var(--grain-op);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.offline {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 12.5px; font-weight: 600; padding: 6px 12px;
}

/* ===================== Top bar ===================== */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  max-width: 640px; margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 20px 12px;
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 14px;
  display: grid; place-items: center;
  font-family: Georgia, 'Times New Roman', serif; font-size: 24px; font-weight: 700;
  color: var(--accent); background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 3px var(--bg), inset 0 0 0 4px color-mix(in srgb, var(--accent) 35%, transparent);
}
.brand h1 { margin: 0; font-family: var(--font-display); font-size: 19px; font-weight: 700; line-height: 1.1; }
.brand p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; gap: 6px; align-items: center; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 13px;
  display: grid; place-items: center; color: var(--muted);
  transition: background .2s, color .2s, transform .15s var(--ease);
}
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.pill-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 13px;
}

/* ===================== Layout ===================== */
main { max-width: 640px; margin: 0 auto; padding: 6px 20px 0; }
.view { display: none; }
.view.is-active { display: block; animation: viewIn .45s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.section-title { margin: 10px 2px 18px; }
.section-title h2 { margin: 0; font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.section-title p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }

/* ===================== Hero ===================== */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius-lg);
  padding: 22px 22px 20px;
  background:
    radial-gradient(420px 220px at 0% 0%, color-mix(in srgb, var(--hc, var(--accent)) 26%, transparent), transparent 70%),
    linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  min-height: 210px;
  transition: --hc .6s;
}
.hero::after { /* fine ruled lines, like a notebook */
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background: repeating-linear-gradient(0deg, transparent 0 27px, color-mix(in srgb, var(--line) 50%, transparent) 27px 28px);
  mask-image: linear-gradient(to left, transparent 30%, #000);
  -webkit-mask-image: linear-gradient(to left, transparent 30%, #000);
}
.hero > * { position: relative; z-index: 1; }
.hero-skeleton { height: 166px; border-radius: 14px; background: linear-gradient(90deg, var(--surface-2), var(--line-soft), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.status {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600;
  padding: 5px 12px 5px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--hc, var(--accent)) 16%, transparent);
  color: var(--hc, var(--accent));
}
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.live .dot { animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 currentColor; } 100% { box-shadow: 0 0 0 9px transparent; } }
.hero-date { font-size: 12.5px; color: var(--muted); }

.hero-main { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; }
.hero-eyebrow { font-size: 12.5px; color: var(--muted); margin: 0 0 2px; }
.hero-subject { margin: 0; font-family: var(--font-display); font-size: clamp(28px, 8vw, 38px); font-weight: 800; line-height: 1.15; letter-spacing: -.01em; }
.hero-code { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 600; letter-spacing: .08em; color: var(--hc, var(--accent)); }
.hero-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 13.5px; color: var(--muted); }
.hero-meta span { display: inline-flex; align-items: center; gap: 6px; }

.ring { position: relative; width: 116px; height: 116px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: var(--line); }
.ring .bar { stroke: var(--hc, var(--accent)); stroke-linecap: round; transition: stroke-dashoffset 1s linear; filter: drop-shadow(0 0 6px color-mix(in srgb, var(--hc, var(--accent)) 45%, transparent)); }
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-label b { font-family: var(--font-display); font-size: 26px; font-weight: 700; line-height: 1; }
.ring-label small { font-size: 11px; color: var(--muted); margin-top: 4px; }

.countdown {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 18px; padding: 12px 14px; border-radius: 16px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  border: 1px solid var(--line-soft);
}
.countdown-label { font-size: 12.5px; color: var(--muted); }
.digits { display: flex; gap: 4px; direction: ltr; }
.digit-group { display: flex; flex-direction: column; align-items: center; min-width: 42px; }
.digit-group b { font-family: var(--font-display); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.digit-group small { font-size: 10px; color: var(--faint); }
.digit-sep { font-family: var(--font-display); font-size: 20px; color: var(--faint); line-height: 1.2; }

.hero-cta { display: flex; gap: 8px; margin-top: 14px; }
.ghost-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 12px;
  font-size: 13px; font-weight: 600; color: var(--text);
  background: color-mix(in srgb, var(--text) 6%, transparent);
  transition: background .2s, transform .15s var(--ease);
}
.ghost-btn:hover { background: color-mix(in srgb, var(--text) 11%, transparent); }
.ghost-btn:active { transform: scale(.96); }

/* ===================== Day chips ===================== */
.days {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px;
  margin: 22px 0 18px; padding: 5px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  position: relative;
}
.day-chip {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 2px 8px; border-radius: 13px;
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  transition: color .25s, background .25s, transform .15s var(--ease);
}
.day-chip:active { transform: scale(.94); }
.day-chip.is-active { color: var(--accent-ink); background: var(--accent); box-shadow: 0 8px 18px -8px color-mix(in srgb, var(--accent) 70%, transparent); }
.day-chip .pips { display: flex; gap: 3px; height: 5px; }
.day-chip .pip { width: 5px; height: 5px; border-radius: 50%; background: var(--c, var(--faint)); }
.day-chip.is-active .pip { background: var(--accent-ink); opacity: .7; }
.day-chip .today-tag { position: absolute; top: -7px; inset-inline-start: 50%; transform: translateX(50%); font-size: 9.5px; font-weight: 700; padding: 0 6px; border-radius: 6px; background: var(--text); color: var(--bg); line-height: 15px; }

.day-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 2px 12px; }
.day-head h3 { margin: 0; font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.day-head span { font-size: 13px; color: var(--muted); }

/* ===================== Timeline ===================== */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline > li { animation: rise .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.slot { display: grid; grid-template-columns: 58px 1fr; gap: 12px; }
.slot-time { text-align: center; padding-top: 16px; }
.slot-time b { display: block; font-family: var(--font-display); font-size: 15px; font-weight: 600; line-height: 1.1; }
.slot-time small { font-size: 11px; color: var(--faint); }

.card {
  position: relative; width: 100%; text-align: start;
  display: block; padding: 16px 16px 14px 16px; margin-bottom: 10px;
  border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  overflow: hidden;
  transition: transform .25s var(--ease), border-color .25s, box-shadow .25s;
}
.card::before { content: ''; position: absolute; inset-block: 12px; inset-inline-start: 0; width: 4px; border-radius: 0 4px 4px 0; background: var(--c); }
.card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--c) 45%, var(--line)); box-shadow: var(--shadow); }
.card:active { transform: scale(.985); }
.card.is-now { border-color: color-mix(in srgb, var(--c) 60%, var(--line)); background: linear-gradient(135deg, color-mix(in srgb, var(--c) var(--tint), var(--surface)), var(--surface) 70%); }
.card.is-past { opacity: .55; }
.card.is-past:hover { opacity: .85; }
.card-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card h4 { margin: 0; font-family: var(--font-display); font-size: 18px; font-weight: 700; line-height: 1.3; }
.code-tag { font-size: 11px; font-weight: 700; letter-spacing: .07em; padding: 3px 8px; border-radius: 8px; color: var(--c); background: color-mix(in srgb, var(--c) var(--tint), transparent); white-space: nowrap; }
.card-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.card-meta span { display: inline-flex; align-items: center; gap: 5px; }
.card-note { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; padding: 9px 11px; border-radius: 12px; font-size: 13px; background: var(--surface-2); color: var(--text); }
.card-note .ico { color: var(--accent); margin-top: 3px; }
.card-note p { margin: 0; white-space: pre-wrap; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.badges { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge.live { color: var(--c); background: color-mix(in srgb, var(--c) var(--tint), transparent); }
.progress { height: 4px; border-radius: 4px; background: var(--line-soft); margin-top: 12px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--c); border-radius: inherit; transform-origin: right; transition: transform 1s linear; }

.gap { display: grid; grid-template-columns: 58px 1fr; gap: 12px; margin: -2px 0 8px; }
.gap-line { display: flex; justify-content: center; }
.gap-line i { width: 2px; height: 100%; min-height: 26px; background: repeating-linear-gradient(to bottom, var(--line) 0 4px, transparent 4px 8px); }
.gap-text { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--faint); }

.empty {
  text-align: center; padding: 34px 22px; border-radius: var(--radius);
  border: 1.5px dashed var(--line); background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.empty-art { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 20px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 28px; }
.empty h4 { margin: 0 0 4px; font-family: var(--font-display); font-size: 18px; }
.empty p { margin: 0 auto 16px; color: var(--muted); font-size: 13.5px; max-width: 300px; }

.hint { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12px; color: var(--faint); margin: 14px 0 0; }

/* ===================== Week ===================== */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.stat { padding: 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); animation: rise .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms); }
.stat b { display: block; font-family: var(--font-display); font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--muted); }
.stat:first-child b { color: var(--accent); }

.week { padding: 16px 14px 10px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); }
.week-scale, .week-row { display: grid; grid-template-columns: 62px 1fr; gap: 10px; align-items: center; }
.week-scale { margin-bottom: 6px; }
.scale-track { position: relative; height: 16px; }
.scale-track span { position: absolute; transform: translateX(50%); font-size: 10.5px; color: var(--faint); font-family: var(--font-display); }
.week-row { padding: 8px 0; border-top: 1px solid var(--line-soft); animation: rise .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms); }
.week-day { font-size: 13px; font-weight: 600; display: flex; flex-direction: column; line-height: 1.25; }
.week-day small { font-size: 10.5px; color: var(--faint); font-weight: 500; }
.week-row.is-today .week-day { color: var(--accent); }
.track { position: relative; height: 46px; border-radius: 12px; background: repeating-linear-gradient(to left, transparent 0, transparent calc(var(--hour) - 1px), var(--line-soft) calc(var(--hour) - 1px), var(--line-soft) var(--hour)); }
.track.is-free::after { content: 'يوم حر'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; color: var(--faint); }
.block {
  position: absolute; top: 3px; bottom: 3px;
  border-radius: 10px; padding: 0 8px; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center; text-align: start;
  background: color-mix(in srgb, var(--c) calc(var(--tint) + 10%), var(--surface));
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  color: var(--text);
  transition: transform .2s var(--ease), box-shadow .2s;
}
.block:hover { transform: translateY(-2px); box-shadow: 0 10px 20px -12px var(--c); z-index: 2; }
.block b { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block small { font-size: 10px; color: var(--muted); white-space: nowrap; }
.now-line { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--danger); border-radius: 2px; z-index: 3; }
.now-line::before { content: ''; position: absolute; top: -3px; left: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }

/* ===================== Subjects ===================== */
.subjects { display: grid; gap: 10px; }
.subject {
  position: relative; display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center;
  padding: 16px; border-radius: var(--radius); text-align: start; width: 100%;
  background: var(--surface); border: 1px solid var(--line);
  animation: rise .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms);
  transition: transform .2s var(--ease), border-color .2s;
}
.subject:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--c) 45%, var(--line)); }
.subject-mark { width: 50px; height: 50px; border-radius: 15px; display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 20px; color: var(--c); background: color-mix(in srgb, var(--c) var(--tint), transparent); }
.subject h4 { margin: 0; font-family: var(--font-display); font-size: 17px; font-weight: 700; }
.subject p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.subject-hours { text-align: center; }
.subject-hours b { display: block; font-family: var(--font-display); font-size: 22px; font-weight: 700; line-height: 1; }
.subject-hours small { font-size: 10.5px; color: var(--faint); }
.subject-bar { grid-column: 1 / -1; height: 4px; border-radius: 4px; background: var(--line-soft); overflow: hidden; }
.subject-bar i { display: block; height: 100%; background: var(--c); border-radius: inherit; }
.halls-note { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; padding: 14px 16px; border-radius: 16px; background: var(--accent-soft); color: var(--text); font-size: 13px; }
.halls-note .ico { color: var(--accent); margin-top: 3px; }
.halls-note b { display: block; font-family: var(--font-display); }

/* ===================== Dock ===================== */
.dock {
  position: fixed; z-index: 45; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: 1fr 1fr auto 1fr 1fr; align-items: center; gap: 2px;
  width: min(440px, calc(100% - 28px)); padding: 7px;
  border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--line);
  box-shadow: 0 20px 40px -18px rgba(0, 0, 0, .55);
}
.dock-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 16px; font-size: 11px; font-weight: 600; color: var(--faint); transition: color .2s, background .2s; }
.dock-btn .ico { width: 21px; height: 21px; }
.dock-btn:hover { color: var(--text); }
.dock-btn.is-active { color: var(--accent); background: var(--accent-soft); }
.dock-fab {
  width: 54px; height: 54px; margin: -22px 6px 0; border-radius: 19px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 12px 24px -8px color-mix(in srgb, var(--accent) 75%, transparent), inset 0 1px 0 rgba(255, 255, 255, .3);
  transition: transform .25s var(--spring);
}
.dock-fab .ico { width: 24px; height: 24px; }
.dock-fab:hover { transform: translateY(-2px) rotate(90deg); }
.dock-fab:active { transform: scale(.9); }

/* ===================== Sheet ===================== */
.scrim { position: fixed; inset: 0; z-index: 80; background: rgba(10, 9, 6, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade .25s both; }
.scrim.out { animation: fade .2s reverse both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  position: fixed; z-index: 90; left: 50%; bottom: 0;
  width: min(560px, 100%); max-height: 92dvh; overflow: auto; overscroll-behavior: contain;
  transform: translateX(-50%);
  border-radius: 28px 28px 0 0;
  background: var(--surface); border: 1px solid var(--line); border-bottom: 0;
  padding: 8px 22px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 60px -20px rgba(0, 0, 0, .6);
  animation: sheetIn .42s var(--spring) both;
}
.sheet.out { animation: sheetOut .22s var(--ease) both; }
@keyframes sheetIn { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
@keyframes sheetOut { to { transform: translate(-50%, 100%); } }
@media (min-width: 640px) {
  .sheet { bottom: 50%; border-radius: 28px; border-bottom: 1px solid var(--line); max-height: 86dvh; animation-name: sheetInC; }
  .sheet.out { animation-name: sheetOutC; }
  @keyframes sheetInC { from { opacity: 0; transform: translate(-50%, 54%) scale(.96); } to { opacity: 1; transform: translate(-50%, 50%); } }
  @keyframes sheetOutC { from { opacity: 1; transform: translate(-50%, 50%); } to { opacity: 0; transform: translate(-50%, 54%) scale(.96); } }
  .sheet-grip { visibility: hidden; }
}
.sheet-grip { width: 42px; height: 5px; border-radius: 5px; background: var(--line); margin: 4px auto 14px; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.sheet-head h2 { margin: 0; font-family: var(--font-display); font-size: 22px; font-weight: 700; line-height: 1.25; }
.sheet-head p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.sheet-body > * { animation: rise .4s var(--ease) both; }

.detail-hero { padding: 18px; border-radius: 20px; background: linear-gradient(135deg, color-mix(in srgb, var(--c) var(--tint), var(--surface-2)), var(--surface-2)); border: 1px solid color-mix(in srgb, var(--c) 30%, var(--line)); margin-bottom: 14px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.detail-grid div { padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--bg) 35%, transparent); }
.detail-grid small { display: block; font-size: 11px; color: var(--muted); }
.detail-grid b { font-family: var(--font-display); font-weight: 600; font-size: 15px; }

/* Forms */
.field { margin-bottom: 14px; }
.field label, .field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%; height: 48px; padding: 0 14px; border-radius: 14px;
  background: var(--surface-2); border: 1.5px solid var(--line);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
textarea.input { height: auto; min-height: 110px; padding: 12px 14px; resize: vertical; line-height: 1.6; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.input.invalid { border-color: var(--danger); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.seg.three { grid-template-columns: repeat(3, 1fr); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { margin: 0; display: flex; align-items: center; justify-content: center; gap: 6px; height: 42px; border-radius: 12px; background: var(--surface-2); border: 1.5px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; transition: all .2s; }
.seg input:checked + label { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.seg input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatches input { position: absolute; opacity: 0; pointer-events: none; }
.swatches label { margin: 0; width: 36px; height: 36px; border-radius: 50%; background: var(--c); cursor: pointer; display: grid; place-items: center; color: #fff; transition: transform .2s var(--spring), box-shadow .2s; }
.swatches label .ico { opacity: 0; transform: scale(.4); transition: all .2s var(--spring); }
.swatches input:checked + label { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--c); transform: scale(1.05); }
.swatches input:checked + label .ico { opacity: 1; transform: none; }
.swatches input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 5px; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.suggest button { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.suggest button:hover { color: var(--text); border-color: var(--accent); }
.form-msg { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; padding: 10px 12px; border-radius: 12px; margin-bottom: 14px; }
.form-msg.error { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.form-msg.warn { color: var(--c-amber); background: color-mix(in srgb, var(--c-amber) 13%, transparent); }
.form-msg .ico { margin-top: 2px; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px; border-radius: 14px; background: var(--surface-2); margin-bottom: 14px; cursor: pointer; }
.switch-row b { display: block; font-size: 14px; }
.switch-row small { color: var(--muted); font-size: 12px; }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .25s; pointer-events: none; }
.switch i::after { content: ''; position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); transition: transform .3s var(--spring); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(-20px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 3px; }

.actions { display: flex; gap: 10px; margin-top: 6px; }
.btn { flex: 1; height: 50px; border-radius: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; font-size: 14.5px; transition: transform .15s var(--ease), background .2s, opacity .2s; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 10px 22px -12px var(--accent); }
.btn-soft { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn-danger { background: color-mix(in srgb, var(--danger) 13%, transparent); color: var(--danger); }
.btn-icon { flex: none; width: 50px; }

.list { display: grid; gap: 8px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 14px; background: var(--surface-2); width: 100%; text-align: start; transition: background .2s; }
.list-item:hover { background: color-mix(in srgb, var(--surface-2) 70%, var(--line)); }
.list-item .ico { color: var(--accent); width: 20px; height: 20px; }
.list-item div { flex: 1; }
.list-item b { display: block; font-size: 14px; }
.list-item small { color: var(--muted); font-size: 12px; }
.list-item.danger .ico, .list-item.danger b { color: var(--danger); }
.group-label { font-size: 12px; font-weight: 700; color: var(--faint); letter-spacing: .04em; margin: 18px 4px 8px; }
.foot-note { text-align: center; font-size: 11.5px; color: var(--faint); margin-top: 18px; }

/* Guide */
.guide-steps { display: grid; gap: 10px; margin-bottom: 18px; }
.guide-step { display: grid; grid-template-columns: 44px 1fr; gap: 14px; align-items: start; padding: 14px; border-radius: 16px; background: var(--surface-2); animation: rise .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 90ms + 100ms); }
.guide-step .n { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.guide-step .n .ico { width: 22px; height: 22px; }
.guide-step b { display: block; font-family: var(--font-display); font-size: 15px; margin-bottom: 2px; }
.guide-step p { margin: 0; font-size: 13px; color: var(--muted); }

/* ===================== Toast ===================== */
.toast {
  position: fixed; z-index: 100; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 14px;
  max-width: calc(100% - 32px); padding: 10px 10px 10px 18px; padding-inline-start: 18px;
  border-radius: 16px; background: var(--text); color: var(--bg);
  font-size: 13.5px; font-weight: 500;
  box-shadow: 0 14px 34px -12px rgba(0, 0, 0, .5);
  opacity: 0; pointer-events: none; transform: translate(-50%, 16px) scale(.97);
  transition: opacity .3s var(--ease), transform .35s var(--spring);
}
.toast.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.toast-action { font-weight: 700; color: var(--accent); padding: 6px 12px; border-radius: 10px; background: color-mix(in srgb, var(--bg) 12%, transparent); }
[data-theme='light'] .toast-action { color: #f0c46a; }

/* ===================== Motion prefs ===================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}
@media (max-width: 380px) {
  .ring { width: 96px; height: 96px; }
  .ring-label b { font-size: 21px; }
  .digit-group { min-width: 34px; }
  .digit-group b { font-size: 19px; }
  .slot { grid-template-columns: 48px 1fr; gap: 8px; }
  .gap { grid-template-columns: 48px 1fr; gap: 8px; }
}
