:root {
  --ink: #15171b;
  --muted: #6d7179;
  --paper: #f3f3f0;
  --card: #ffffff;
  --accent: #536dfe;
  --accent-dark: #3148c8;
  --accent-soft: #e9edff;
  --line: #dedfda;
  --success: #17825c;
  --warning: #9a5b18;
  --danger: #a53a43;
  --radius: 14px;
  --shadow: 0 12px 30px rgba(18, 20, 25, .06);
  --dark-panel: #15171b;
  --on-dark: #ffffff;
  --input: #f8f8f6;
  --nav-bg: rgba(250,250,248,.94);
}

html[data-theme="smiski"] {
  --ink: #16351b;
  --muted: #4f694d;
  --paper: #b8dc69;
  --card: #edf7cf;
  --accent: #3d7e35;
  --accent-dark: #245c28;
  --accent-soft: #d9ef9d;
  --line: #8fba55;
  --success: #286a32;
  --dark-panel: #214d25;
  --input: #f5fadf;
  --nav-bg: rgba(235,247,203,.94);
}

html[data-theme="avatar"] {
  color-scheme: dark;
  --ink: #eefbff;
  --muted: #a8c7d0;
  --paper: #0a2532;
  --card: rgba(10, 47, 63, .9);
  --accent: #51b9e8;
  --accent-dark: #89ddff;
  --accent-soft: #183f56;
  --line: #2b5665;
  --success: #64dfb5;
  --warning: #ffd06f;
  --danger: #ff9aa5;
  --dark-panel: #061821;
  --input: rgba(8, 38, 51, .94);
  --nav-bg: rgba(5,25,35,.9);
  --shadow: 0 12px 30px rgba(0,0,0,.2);
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
html[data-theme="avatar"] body {
  background-color: #061821;
  background-image: linear-gradient(180deg, rgba(3, 20, 29, .28), rgba(3, 22, 32, .78)), url("assets/pandora-night.jpg");
  background-position: center;
  background-size: cover;
  background-attachment: fixed;
}
html[data-theme="avatar"] .shell { min-height: 100vh; background: linear-gradient(90deg, rgba(4, 23, 33, .32), rgba(5, 30, 41, .12)); }
button, input, select { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(2.55rem, 12vw, 4.4rem); line-height: .92; letter-spacing: -.07em; }
h2 { margin-bottom: 10px; font-size: 1.28rem; letter-spacing: -.035em; }
h3 { margin-bottom: 5px; font-size: .96rem; letter-spacing: -.01em; }
p { color: var(--muted); line-height: 1.5; }

.shell { min-height: 100vh; padding-bottom: 92px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 760px;
  margin: auto;
  padding: max(18px, env(safe-area-inset-top)) 20px 12px;
}
.wordmark { display: flex; align-items: center; gap: 10px; font-size: .72rem; letter-spacing: .1em; }
.wordmark > span { display: grid; place-items: center; width: 36px; height: 36px; color: var(--paper); background: var(--ink); border-radius: 8px; font-size: .7rem; font-weight: 850; letter-spacing: -.02em; }
.wordmark b { font-weight: 800; }
.header-tools { display: flex; align-items: center; gap: 9px; }
.sync-status { color: var(--muted); font-size: .68rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.sync-status::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: #9b9ea3; vertical-align: 1px; }
.sync-status[data-state="synced"]::before { background: var(--success); }
.sync-status[data-state="saving"]::before, .sync-status[data-state="connecting"]::before { background: var(--accent); }
.sync-status[data-state="offline"]::before { background: var(--warning); }
.avatar { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: var(--card); font-weight: 800; }
.content { max-width: 760px; margin: auto; padding: 16px 20px 40px; }

.page-index, .hero-index, .session-number, .eyebrow {
  margin-bottom: 14px;
  color: var(--accent-dark);
  font: 750 .69rem/1.2 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.subtle { color: var(--muted); font-size: .82rem; }
.fine-print { margin: 22px 0 0; font-size: .72rem; }

.hero { padding: 34px 0 24px; }
.hero p { max-width: 25rem; margin-bottom: 0; font-size: .95rem; }
.hero-row { display: flex; gap: 18px; align-items: flex-end; justify-content: space-between; }
.week-ring { flex: 0 0 86px; width: 86px; height: 86px; border-radius: 50%; display: grid; place-items: center; text-align: center; background: conic-gradient(var(--accent) var(--progress, 0%), #dedfda 0); position: relative; }
.week-ring::after { content: ""; position: absolute; inset: 7px; border-radius: inherit; background: var(--paper); }
.week-ring span { position: relative; z-index: 1; color: var(--muted); font: 700 .55rem/1.2 ui-monospace, monospace; letter-spacing: .04em; }
.week-ring b { display: block; margin-bottom: 2px; color: var(--ink); font: 800 1.05rem/1 system-ui, sans-serif; }

.card { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.today-card { margin-bottom: 28px; padding: 23px; color: var(--on-dark); background: var(--dark-panel); border-color: var(--dark-panel); box-shadow: 0 18px 38px rgba(18,20,25,.15); }
.today-card h2 { margin-bottom: 4px; font-size: 2rem; color: var(--on-dark); }
.today-card p { color: #b9bcc3; }
.today-card .session-number { color: #aeb9ff; }
.session-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 22px 0; padding: 15px 0; border-top: 1px solid #34363c; border-bottom: 1px solid #34363c; }
.session-stats div { padding-right: 8px; }
.session-stats b, .session-stats span { display: block; }
.session-stats b { font-size: .9rem; }
.session-stats span { margin-top: 4px; color: #8f9299; font: 650 .57rem ui-monospace, monospace; letter-spacing: .06em; }

.btn { display: inline-flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 48px; padding: 11px 16px; border: 0; border-radius: 10px; color: var(--on-dark); background: var(--accent); font-weight: 760; }
.btn:hover { background: var(--accent-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.secondary { color: var(--accent-dark); background: var(--accent-soft); }
.btn.ghost { color: var(--ink); background: transparent; border: 1px solid var(--line); }
.btn.danger { color: var(--danger); background: #f8e9e9; }
.btn.full { width: 100%; }
.btn.small { min-height: 38px; padding: 8px 11px; font-size: .8rem; }
.today-card .btn { width: 100%; color: var(--dark-panel); background: var(--on-dark); }

.meta { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0 17px; }
.chip { display: inline-flex; align-items: center; min-height: 26px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 7px; color: #555960; background: #f7f7f5; font-size: .7rem; font-weight: 700; }
.chip.warm { color: var(--warning); background: #fff6e8; border-color: #eddbbd; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 28px 0 12px; }
.section-head h2 { margin: 0; }

.routine-grid { display: grid; gap: 9px; }
.routine-card { display: grid; grid-template-columns: 42px 1fr 38px; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.routine-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 9px; color: var(--paper); background: var(--ink); font: 800 .78rem ui-monospace, monospace; }
.routine-card h3, .routine-card p { margin-bottom: 1px; }
.routine-card p { font-size: .76rem; }
.routine-card > button, .icon-btn { width: 38px; height: 38px; border: 0; border-radius: 8px; color: var(--accent-dark); background: var(--accent-soft); font-weight: 900; }
.routine-card.done { opacity: .56; }
.routine-grid > .card .routine-icon { margin-bottom: 18px; }

.bottom-nav { position: fixed; left: 50%; bottom: 0; z-index: 20; transform: translateX(-50%); width: min(100%, 760px); padding: 8px 12px max(8px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); background: var(--nav-bg); backdrop-filter: blur(18px); }
.nav-btn { display: grid; justify-items: center; gap: 3px; padding: 5px 2px; border: 0; color: #888b90; background: none; font-size: .62rem; font-weight: 700; }
.nav-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-btn.active { color: var(--accent-dark); }

.field { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; outline: none; color: var(--ink); background: var(--card); }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.library-tools { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 22px 0 14px; }
.exercise-list { display: grid; gap: 8px; }
.exercise-item { display: grid; grid-template-columns: 42px 1fr auto; gap: 11px; align-items: center; padding: 11px; border: 1px solid var(--line); border-radius: 11px; background: var(--card); }
.mini-art { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 8px; color: var(--accent-dark); background: var(--accent-soft); font-weight: 800; }
.exercise-item h3, .exercise-item p { margin: 0; }
.exercise-item p { font-size: .73rem; }

.workout-head { position: sticky; top: 0; z-index: 10; margin: -16px -20px 14px; padding: max(14px, env(safe-area-inset-top)) 20px 12px; background: var(--nav-bg); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px); }
.workout-head-row, .exercise-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.workout-head h2 { margin: 0; }
.exercise-card { margin-bottom: 10px; box-shadow: none; }
.exercise-card.current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.exercise-title button { padding: 5px 0; border: 0; color: var(--accent-dark); background: none; font-weight: 760; }
.set-row { display: grid; grid-template-columns: 26px 1fr 1fr 42px; align-items: center; gap: 7px; margin-top: 7px; }
.set-row label { color: var(--muted); font: 700 .62rem ui-monospace, monospace; text-align: center; text-transform: uppercase; }
.set-input { min-width: 0; width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); text-align: center; background: var(--input); }
.set-input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.set-check { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 8px; color: transparent; background: var(--card); }
.set-check.checked { color: white; background: var(--success); border-color: var(--success); }
.rest-banner { position: sticky; bottom: 78px; z-index: 8; display: flex; align-items: center; justify-content: space-between; margin: 12px 0; padding: 12px 14px; border-radius: 10px; color: white; background: var(--ink); box-shadow: var(--shadow); }
.rest-banner button { padding: 6px 9px; border: 0; border-radius: 7px; color: white; background: var(--accent); font-weight: 750; }

.progress-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin: 22px 0 26px; }
.stat { min-height: 115px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.stat > span { color: var(--muted); font: 700 .62rem ui-monospace, monospace; letter-spacing: .08em; }
.stat b { display: block; margin-top: 18px; font-size: 2rem; letter-spacing: -.055em; }
.stat small { font-size: .7rem; }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.day { aspect-ratio: 1; display: grid; place-items: center; border-radius: 7px; color: #7c7f84; background: #e5e5e1; font-size: .67rem; }
.day.done { color: white; background: var(--accent); }

.settings-list { display: grid; gap: 9px; margin-top: 24px; }
.setting { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 15px; }
.setting h3, .setting p { margin-bottom: 3px; }
.setting p { font-size: .82rem; }
.toggle { width: 48px; height: 28px; padding: 3px; border: 0; border-radius: 99px; background: #cacbc8; }
.toggle::after { content: ""; display: block; width: 22px; height: 22px; border-radius: 50%; background: white; transition: transform .2s; }
.toggle.on { background: var(--accent); }
.toggle.on::after { transform: translateX(20px); }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; align-items: end; background: rgba(13,14,17,.58); backdrop-filter: blur(3px); }
.modal { width: min(100%, 680px); max-height: 92vh; overflow-y: auto; margin: auto; padding: 22px 20px max(24px, env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0; background: var(--paper); box-shadow: 0 -20px 50px rgba(10,12,15,.2); }
.modal-close { float: right; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: var(--card); font-weight: 900; }
.safety-box { margin: 16px 0; padding: 14px; border: 1px solid #e8d0b4; border-radius: 10px; background: #fff6e9; }
.safety-box p:last-child { margin-bottom: 0; }
.check-line { display: flex; align-items: flex-start; gap: 10px; margin: 14px 0; color: var(--ink); line-height: 1.42; }
.check-line input { flex: 0 0 20px; width: 20px; height: 20px; accent-color: var(--accent); }
.video-wrap { position: relative; aspect-ratio: 16 / 9; margin: 16px 0 9px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #050607; }
.video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-credit { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; color: var(--muted); font-size: .72rem; }
.video-credit a { color: var(--accent-dark); font-weight: 750; text-decoration: none; }
.guide-steps { padding-left: 21px; color: var(--muted); line-height: 1.55; }
.guide-steps li { margin-bottom: 8px; }
.attachment { display: flex; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); }
.attachment b { display: block; }
.setup-icon { display: grid; place-items: center; align-self: flex-start; width: 32px; height: 32px; border-radius: 7px; color: var(--accent-dark); background: var(--accent-soft); font: 800 .55rem ui-monospace, monospace; }
.theme-select { width: 148px; }
.routine-field-label { display: block; margin: 14px 0 6px; font-weight: 750; }
.routine-picker-note { margin: 18px 0 10px; font-size: .78rem; }
.theme-credit { margin: 12px 0 0; font-size: .68rem !important; }
.theme-credit a { color: var(--accent-dark); }

.access-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--ink); }
.access-card { width: min(100%, 430px); padding: 26px; border-radius: 16px; background: var(--paper); box-shadow: 0 24px 70px rgba(0,0,0,.28); }
.access-card .wordmark { margin-bottom: 62px; }
.access-index { margin-bottom: 13px; color: var(--accent-dark); font: 750 .68rem ui-monospace, monospace; letter-spacing: .1em; }
.access-card h1 { font-size: clamp(2.6rem, 13vw, 4rem); }
.access-card label { display: block; margin: 26px 0 7px; font-size: .75rem; font-weight: 750; }
.access-card .btn { margin-top: 9px; }

#toast { position: fixed; left: 50%; bottom: 88px; z-index: 200; transform: translate(-50%, 14px); opacity: 0; width: max-content; max-width: calc(100% - 40px); padding: 10px 14px; border-radius: 9px; color: white; background: var(--ink); font-size: .8rem; transition: .2s; pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.theme-peek { display: none; position: fixed; right: -9px; bottom: 65px; z-index: 8; width: 70px; height: 100px; opacity: .82; pointer-events: none; }
.smiski-scatter { display: none; position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.smiski-friend { position: absolute; width: 35px; height: 46px; border-radius: 48% 52% 13px 13px; background: #e5f7a8; box-shadow: 0 0 18px rgba(240, 255, 184, .35); opacity: .38; transform: rotate(var(--tilt, 0deg)); }
.smiski-friend::before { content: ""; position: absolute; left: -2px; top: -22px; width: 39px; height: 38px; border-radius: 48% 52% 46% 54%; background: inherit; box-shadow: inherit; }
.smiski-friend::after { content: ""; position: absolute; left: -10px; top: 8px; width: 54px; height: 10px; border-radius: 99px; background: inherit; transform: rotate(-8deg); }
.smiski-friend i::before, .smiski-friend i::after { content: ""; position: absolute; z-index: 1; top: -5px; width: 3px; height: 4px; border-radius: 50%; background: #315927; }
.smiski-friend i::before { left: 10px; }
.smiski-friend i::after { right: 10px; }
.smiski-friend b::before, .smiski-friend b::after { content: ""; position: absolute; bottom: -12px; width: 11px; height: 19px; border-radius: 0 0 9px 9px; background: inherit; }
.smiski-friend b::before { left: 4px; transform: rotate(8deg); }
.smiski-friend b::after { right: 4px; transform: rotate(-8deg); }
.friend-1 { left: 4%; top: 16%; --tilt: -12deg; transform: rotate(var(--tilt)) scale(.72); }
.friend-2 { right: 6%; top: 29%; --tilt: 10deg; transform: rotate(var(--tilt)) scale(.58); }
.friend-3 { left: 11%; top: 54%; --tilt: 7deg; transform: rotate(var(--tilt)) scale(.5); }
.friend-4 { right: 13%; top: 68%; --tilt: -9deg; transform: rotate(var(--tilt)) scale(.7); }
.friend-5 { left: 47%; top: 9%; --tilt: 4deg; transform: rotate(var(--tilt)) scale(.45); }
.friend-6 { left: 30%; bottom: 9%; --tilt: -8deg; transform: rotate(var(--tilt)) scale(.55); }
.friend-7 { right: 34%; top: 44%; --tilt: 11deg; transform: rotate(var(--tilt)) scale(.42); }
.peek-head { position: absolute; left: 13px; top: 2px; z-index: 2; width: 51px; height: 51px; border-radius: 48% 52% 46% 54%; }
.peek-head i { position: absolute; top: 23px; width: 4px; height: 5px; border-radius: 50%; background: #18351b; }
.peek-head i:first-child { left: 16px; }
.peek-head i:nth-child(2) { right: 16px; }
.peek-head b { position: absolute; left: 24px; top: 34px; width: 4px; height: 2px; border-radius: 50%; background: #18351b; }
.peek-body { position: absolute; left: 19px; top: 43px; width: 43px; height: 57px; border-radius: 47% 53% 12px 12px; }
.peek-ear { display: none; position: absolute; top: 13px; z-index: 1; width: 28px; height: 20px; }
.peek-ear.left { left: 0; clip-path: polygon(100% 20%, 0 0, 78% 100%); }
.peek-ear.right { right: 0; clip-path: polygon(0 20%, 100% 0, 22% 100%); }

html[data-theme="smiski"] .theme-peek { display: block; }
html[data-theme="smiski"] .smiski-scatter { display: block; }
html[data-theme="smiski"] .peek-head,
html[data-theme="smiski"] .peek-body { background: #e4f6a7; box-shadow: 0 0 18px rgba(237,255,175,.34); }

html[data-theme="avatar"] body::before {
  content: "";
  position: fixed;
  inset: 18% 8% auto auto;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #8df4ff;
  box-shadow: -240px 42px #6cd7ff, -65px 115px #bd7bff, -290px 230px #73f5d1, -120px 330px #8edcff, 18px 410px #a988ff;
  opacity: .45;
  pointer-events: none;
}
html[data-theme="avatar"] .chip { color: var(--ink); background: var(--input); }
html[data-theme="avatar"] .safety-box { color: var(--ink); background: #173e48; border-color: #3f7180; }
html[data-theme="avatar"] .btn.danger { color: #ffb1b9; background: #532c37; }
html[data-theme="avatar"] .today-card p { color: #a8c7d0; }
html[data-theme="avatar"] .today-card .session-number { color: #86e6ff; }
html[data-theme="avatar"] .session-stats { border-color: #294552; }
html[data-theme="avatar"] .session-stats span { color: #83a7b2; }
html[data-theme="avatar"] .day { color: #a8c7d0; background: #173c49; }

@media (min-width: 700px) {
  .routine-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal { border-radius: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
