:root {
  color-scheme: dark;
  --page: #111620;
  --surface: #1a222f;
  --surface-high: #232e40;
  --input: #141b27;
  --ink: #eff3fa;
  --muted: #b2bed1;
  --line: #36445a;
  --accent: #b1caff;
  --accent-ink: #172743;
  --accent-soft: #273852;
  --focus: #c4d5ff;
  --warn: #f1c08c;
  --shadow: 0 12px 32px #070b1445;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
}
:root[data-wallpaper="city"] {
  --page: #171622;
  --surface: #242433;
  --surface-high: #2c2b40;
  --input: #1d1d2a;
  --line: #494765;
  --accent: #dfd2fb;
  --accent-ink: #231933;
  --accent-soft: #36304f;
  --focus: #e2d4ff;
}
:root[data-wallpaper="forest"] {
  --page: #101a19;
  --surface: #1b2824;
  --surface-high: #23342d;
  --input: #15211e;
  --line: #3a5148;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--page); color: var(--ink); }
body::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: linear-gradient(140deg, #0c121a55, transparent 52%), linear-gradient(0deg, var(--page), transparent);
}
.page-wallpaper {
  position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: .25; pointer-events: none; object-position: center 43%;
}
h1, h2, h3, p { margin: 0; }
p, li { line-height: 1.55; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: wait; }
button, a, input, select { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
.icon { width: 19px; height: 19px; flex: 0 0 19px; display: inline-block; }
.layout, .signin { position: relative; z-index: 1; }

.layout { min-height: 100vh; display: grid; grid-template-columns: 212px minmax(0, 1fr); }
.rail {
  position: sticky; top: 0; height: 100dvh; padding: 33px 16px 23px;
  background: #111824f5; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 44px;
}
.wordmark {
  width: fit-content; display: inline-flex; align-items: center; gap: 10px;
  font-size: 24px; line-height: 1; font-weight: 810; letter-spacing: -.055em;
}
.mark {
  display: grid; place-items: center; width: 31px; height: 31px; flex: 0 0 31px;
  background: var(--accent); color: var(--accent-ink); border-radius: 9px;
}
.mark svg { width: 21px; height: 21px; }
.rail > .wordmark { margin-left: 7px; }
#nav { display: grid; gap: 6px; }
#nav a {
  display: flex; align-items: center; gap: 11px; min-height: 48px;
  color: var(--muted); padding: 0 12px; border: 1px solid transparent;
  border-radius: 10px; font-weight: 660; font-size: .94rem;
}
#nav a:hover { background: var(--surface-high); color: var(--ink); }
#nav a[aria-current="page"] { background: var(--accent-soft); border-color: var(--line); color: var(--accent); }
.nav-icon { width: 22px; height: 22px; flex: 0 0 22px; }
.account { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding: 16px 4px 0; border-top: 1px solid var(--line); }
.account strong, .account small { display: block; }
.account small { color: var(--muted); margin-top: 4px; font-size: .75rem; }
.plain { min-height: 44px; padding: 4px 7px; color: var(--muted); border: 0; background: transparent; }
.plain:hover { color: var(--ink); }

.screen { width: min(100%, 1240px); margin: 0 auto; padding: 25px clamp(22px, 4vw, 61px) 64px; }
.topline { display: flex; flex-wrap: wrap; min-height: 42px; align-items: center; justify-content: space-between; gap: 9px; margin-bottom: 17px; color: var(--muted); font-size: .86rem; }
.topline > span::first-letter { text-transform: uppercase; }
.top-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.control-button, .sync-button {
  display: inline-flex; gap: 7px; align-items: center; justify-content: center; min-height: 40px;
  padding: 5px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
  color: var(--muted); font-size: .82rem; font-weight: 630;
}
.control-button:hover, .sync-button:hover { color: var(--ink); border-color: var(--muted); }
.control-button .icon { width: 16px; height: 16px; flex-basis: 16px; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.sync-button[data-state='offline'] .sync-dot, .sync-button[data-state='auth'] .sync-dot,
.sync-button[data-state='error'] .sync-dot { background: var(--warn); }
.sync-button[data-state='working'] .sync-dot { background: #96c6eb; }
.notice {
  position: fixed; z-index: 5; right: 24px; bottom: 24px; max-width: min(420px, calc(100vw - 48px));
  padding: 13px 17px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-high); color: var(--ink); box-shadow: var(--shadow);
  font-size: .9rem; animation: appear .19s ease-out;
}
@keyframes appear { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.hero {
  grid-column: 1 / -1; position: relative; min-height: 300px; isolation: isolate; overflow: hidden;
  padding: clamp(24px, 3.8vw, 42px); display: flex; justify-content: space-between; align-items: flex-end;
  gap: 24px; background: #202a3b; border: 1px solid var(--line); border-radius: 21px; box-shadow: var(--shadow);
}
.hero-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 48%; z-index: -2; }
.hero::after {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(90deg, #101928f8 1%, #101928e8 31%, #10192892 64%, #1522385c),
    linear-gradient(0deg, #111b30c2, transparent 80%);
}
.hero-copy { min-width: 0; }
.hero-meta { display: inline-flex; align-items: center; gap: 9px; font-size: .88rem; color: #d8e4fa; font-weight: 650; }
.hero-meta span:first-child {
  color: var(--accent); font-variant-numeric: tabular-nums; letter-spacing: .045em;
  padding: 4px 8px; border: 1px solid #a6bde754; border-radius: 7px; background: #172842cd;
}
.hero h1 { max-width: 16ch; font-size: clamp(2.1rem, 4.7vw, 3.9rem); line-height: 1.02; letter-spacing: -.068em; margin: 16px 0 10px; text-wrap: balance; }
.hero p { color: #dce5f6; max-width: 43ch; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 23px; }
.button {
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 8px 15px; border: 1px solid transparent; border-radius: 9px; font-size: .9rem;
  font-weight: 735; white-space: normal; text-align: center;
}
.button:hover { filter: brightness(1.09); }
.hero-button, .primary { color: var(--accent-ink); background: var(--accent); }
.ghost { color: var(--ink); background: #16233ab0; border-color: #a6bce37a; }
.secondary { color: var(--accent); background: var(--accent-soft); border-color: var(--line); }
.hero-side {
  width: 224px; flex: 0 0 224px; padding: 13px; background: #111b2cb5;
  border: 1px solid #b4c4e343; border-radius: 11px;
}
.hero-side > span { color: #d4e1f5; font-size: .68rem; font-weight: 720; letter-spacing: .085em; }
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin: 8px 0 11px; }
.day { display: grid; place-items: center; min-height: 34px; border: 1px solid #b3c8ec52; border-radius: 6px; color: #d7e4fa; font-size: .8rem; }
.day.done { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 800; }
.partner { display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid #b3c8ec42; padding-top: 9px; font-size: .8rem; color: #e7edfa; }
.partner strong { font-weight: 630; color: #cedcf5; }

.sheet { padding: 22px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: var(--shadow); min-width: 0; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 11px; margin-bottom: 13px; }
h2 { font-size: 1.3rem; letter-spacing: -.035em; line-height: 1.26; }
.section-heading > span { color: var(--muted); font-size: .8rem; }
.pills { display: flex; flex-wrap: wrap; gap: 7px; }
.pill {
  min-height: 43px; padding: 6px 11px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--input); color: var(--ink); font-weight: 660; font-size: .86rem;
}
.pill:hover { border-color: var(--muted); }
.pill.checked { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.pill.obstacle { color: var(--muted); font-size: .82rem; }
.habit {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 50px; text-align: left;
  margin: 13px 0 15px; padding: 10px 0; background: transparent; color: var(--ink);
  border: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.square { display: inline-grid; place-items: center; width: 21px; height: 21px; flex: 0 0 21px; border: 1px solid var(--muted); border-radius: 5px; color: var(--accent-ink); font-size: .8rem; }
[aria-pressed="true"] .square { background: var(--accent); border-color: var(--accent); }
.overline { margin-bottom: 7px; color: var(--muted); font-size: .82rem; font-weight: 750; }
.helper-line { color: var(--muted); font-size: .84rem; line-height: 1.5; margin-top: 11px; }
.tasks { display: grid; }
.task { display: flex; align-items: center; gap: 8px; justify-content: space-between; border-bottom: 1px solid var(--line); }
.task-check { display: flex; gap: 9px; align-items: center; background: transparent; color: var(--ink); border: 0; padding: 9px 0; min-height: 48px; text-align: left; min-width: 0; overflow-wrap: anywhere; }
.task.done .task-check > span:last-child { text-decoration: line-through; color: var(--muted); }
.task select { width: 99px; flex: 0 0 99px; font-size: .82rem; padding: 5px 6px; }
.new-task { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; margin-top: 14px; }
.new-task select { max-width: 99px; font-size: .82rem; padding: 6px; }
.new-task .button { padding-inline: 10px; }
input, select, textarea {
  color: var(--ink); background: var(--input); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 10px; min-height: 44px; min-width: 0; max-width: 100%;
}
input::placeholder, textarea::placeholder { color: #98a9c3; opacity: 1; }
label { display: grid; gap: 6px; font-size: .86rem; font-weight: 640; }
textarea { width: 100%; resize: vertical; }

.page-heading { margin: 7px 0 20px; }
.page-heading h1, .signin h1 { font-size: clamp(2.12rem, 5.2vw, 4.05rem); font-weight: 790; letter-spacing: -.071em; line-height: 1.03; margin-bottom: 9px; }
.page-heading p { color: var(--muted); max-width: 62ch; }
.training-intro { border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 11px 15px; margin: 0 0 16px; background: var(--accent-soft); color: var(--ink); border-radius: 0 10px 10px 0; }
.training-intro p { margin: 3px 0; font-size: .91rem; }
.training-intro strong { color: var(--accent); }
.exercise-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; align-items: start; }
.exercise-title { display: flex; gap: 10px; align-items: center; margin-bottom: 11px; }
.exercise-index { display: grid; place-items: center; width: 35px; height: 35px; flex: 0 0 35px; background: var(--accent-soft); color: var(--accent); border-radius: 8px; font-weight: 740; }
.exercise-title h2 { font-size: 1.16rem; }
.exercise-title p { color: var(--muted); font-size: .86rem; }
.starter-weight {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 8px;
  margin: 0 0 4px; padding: 7px 9px; border-radius: 7px;
  background: var(--accent-soft); color: var(--ink); font-size: .86rem;
}
.starter-weight span { color: var(--accent); font-weight: 720; }
details summary { cursor: pointer; color: var(--accent); font-weight: 710; line-height: 1.5; padding: 9px 0; }
details p { max-width: 62ch; margin: 5px 0 8px; font-size: .93rem; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(77px, 1fr)); gap: 7px; margin-top: 8px; }
.fields label { font-size: .8rem; }
.fields input { width: 100%; }
.technique { margin: 3px 0 9px; }
.technique-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.technique-grid > div { display: grid; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; }
.technique-grid img { width: 100%; aspect-ratio: 5 / 4; object-fit: contain; background: #e9ebeb; }
.technique-grid span { padding: 5px 7px; color: var(--ink); font-size: .77rem; }
.technique figcaption { color: var(--muted); margin-top: 6px; font-size: .72rem; line-height: 1.4; }
.technique figcaption a, .credits a { text-decoration: underline; text-underline-offset: 3px; }
.gym-finish { display: grid; gap: 12px; margin-top: 13px; max-width: 620px; }
.gym-finish .button { justify-self: start; }
.gym-finish small { color: var(--muted); line-height: 1.5; }
.method-list { display: grid; gap: 11px; max-width: 820px; }
.method { padding-block: 13px; }
.method summary { color: var(--ink); font-size: 1.1rem; }
.method summary small { display: block; margin-left: 17px; color: var(--muted); font-size: .8rem; font-weight: 500; }
.method ol { padding-left: 25px; margin: 8px 0 16px; }
.method li { max-width: 62ch; margin-bottom: 5px; }
.excerpt { border-left: 2px solid var(--accent); padding-left: 12px; color: var(--muted); }
.journal-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 15px; }
.dayline { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 5px; }
.timeline-day { display: grid; place-items: center; height: 34px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; font-size: .8rem; }
.timeline-day.trained { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 720; }
.timeline-day.marked { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 15px; margin-top: 11px; color: var(--muted); font-size: .8rem; }
.legend b { display: inline-block; width: 9px; height: 9px; border-radius: 2px; background: var(--accent); }
.legend span + span b { background: var(--accent-soft); border: 1px solid var(--accent); }
.journal-list { display: grid; gap: 10px; margin: 19px 0; }
.journal-card ul, .obstacles ul { padding-left: 18px; margin: 8px 0; }
.journal-card h3 { font-size: 1.05rem; }
.journal-card p { margin: 8px 0; }
.obstacles li { display: flex; justify-content: space-between; gap: 8px; margin: 6px 0; }
.obstacles small { color: var(--muted); }
.follow-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.follow-form .wide { grid-column: 1 / -1; }
.follow-form button { justify-self: start; }
.report-panel { margin-top: 13px; }
.daily-history { margin-bottom: 12px; }

.signin { min-height: 100dvh; display: grid; place-items: center; padding: 26px 18px; }
.signin-inner { width: min(100%, 425px); background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--accent); padding: clamp(23px, 5vw, 41px); border-radius: 18px; box-shadow: var(--shadow); }
.signin-inner > .wordmark { margin-bottom: 24px; }
.signin h1 { font-size: clamp(2.4rem, 6vw, 3.7rem); }
.signin-inner > p { color: var(--muted); line-height: 1.48; }
.signin form { display: grid; gap: 13px; margin-top: 23px; }
.signin .message { color: var(--warn); min-height: 1.42em; font-size: .86rem; }
dialog {
  width: min(calc(100vw - 24px), 535px); max-height: min(90dvh, 720px);
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 17px; padding: 20px; box-shadow: 0 25px 90px #05080bbb;
}
dialog[open] { animation: appear .18s ease-out; }
dialog::backdrop { background: #060d13c9; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 13px; }
.icon-button { width: 42px; padding-inline: 0; }
.wallpaper-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.wall-tile { padding: 0; display: grid; align-content: end; min-width: 0; min-height: 95px; overflow: hidden; background: var(--input); border: 1px solid var(--line); color: var(--ink); border-radius: 10px; text-align: left; }
.wall-tile[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.wall-tile img { width: 100%; height: 72px; object-fit: cover; }
.wall-tile span { padding: 7px 9px; font-weight: 650; font-size: .85rem; }
.plain-wall { background: linear-gradient(145deg, var(--surface-high), var(--input) 60%); }
.file-control { margin: 14px 0; color: var(--muted); }
.file-control input { width: 100%; min-height: 44px; }
.file-control input::file-selector-button { color: var(--accent); background: var(--accent-soft); border: 0; border-radius: 4px; margin-right: 8px; padding: 4px 6px; }
.sound-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 13px; }
.sound-row p { color: var(--muted); font-size: .84rem; }
#sound-toggle[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
#appearance-message { min-height: 1.3rem; margin-top: 5px; color: var(--muted); font-size: .83rem; }
.credits { color: var(--muted); font-size: .79rem; line-height: 1.7; }

@media (max-width: 1080px) {
  .layout { grid-template-columns: 188px minmax(0, 1fr); }
  .rail { padding-inline: 12px; }
  .hero-side { flex-basis: 188px; }
  .home-grid { grid-template-columns: 1fr; }
}
@media (max-width: 740px) {
  .layout { display: block; min-height: 100dvh; }
  .rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 11px 14px; flex-direction: row; justify-content: space-between; align-items: center; gap: 10px; }
  .rail > .wordmark { margin: 0; font-size: 22px; }
  #nav {
    position: fixed; z-index: 4; bottom: 0; left: 0; right: 0;
    padding: 5px 7px max(6px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
    background: #111824fa; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px;
  }
  #nav a { flex-direction: column; gap: 2px; justify-content: center; font-size: .71rem; min-height: 52px; padding: 3px; }
  .nav-icon { width: 20px; height: 20px; flex-basis: auto; }
  .account { padding: 0; border: 0; margin: 0; gap: 6px; }
  .account strong { font-size: .87rem; }
  .account small { font-size: .68rem; }
  .account-out { font-size: .75rem; padding-inline: 4px; }
  .screen { padding: 12px 12px calc(86px + env(safe-area-inset-bottom)); }
  .topline { margin-bottom: 10px; font-size: .79rem; }
  .control-button, .sync-button { min-height: 39px; font-size: .74rem; padding-inline: 8px; }
  .top-actions { gap: 5px; }
  .home-grid { gap: 11px; }
  .hero { min-height: auto; padding: 17px; border-radius: 15px; flex-direction: column; align-items: stretch; gap: 15px; }
  .hero::after { background: linear-gradient(90deg, #101928ef, #10192885), linear-gradient(0deg, #101928f2, transparent); }
  .hero h1 { font-size: clamp(1.95rem, 8.2vw, 3.4rem); margin: 10px 0 8px; text-wrap: initial; }
  .hero-meta, .hero p { font-size: .84rem; }
  .hero-side { width: 100%; flex: 0 0 auto; padding: 9px 10px; }
  .actions { margin-top: 14px; }
  .actions .button { font-size: .8rem; gap: 5px; padding-inline: 9px; }
  .hero-button .icon { width: 15px; height: 15px; flex-basis: 15px; }
  .days { gap: 4px; margin: 5px 0 8px; }
  .day { min-height: 30px; }
  .partner { padding-top: 7px; }
  .sheet { padding: 15px; }
  .exercise-list { grid-template-columns: minmax(0, 1fr); gap: 9px; }
  .notice { bottom: calc(69px + env(safe-area-inset-bottom)); right: 12px; max-width: calc(100vw - 24px); }
  .journal-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
}
@media (max-width: 370px) {
  .new-task { grid-template-columns: minmax(0, 1fr) auto; }
  .new-task .button { grid-column: 1 / -1; justify-self: start; }
  .dayline { gap: 2px; }
  .timeline-day { font-size: .68rem; }
}
@media (prefers-reduced-motion: no-preference) {
  button, .button, #nav a { transition: background-color .14s ease, border-color .14s ease, color .14s ease; }
}
@media (prefers-reduced-motion: reduce) {
  .notice, dialog[open] { animation: none; }
}
.shared-plan { grid-column: 1 / -1; padding-block: 7px; }
.shared-plan > summary {
  display: flex; min-height: 43px; justify-content: space-between; gap: 8px; align-items: center;
  color: var(--ink); list-style: none;
}
.shared-plan > summary::-webkit-details-marker { display: none; }
.shared-plan > summary::after {
  content: ''; width: 7px; height: 7px; flex: 0 0 7px; border-right: 1px solid var(--accent);
  border-bottom: 1px solid var(--accent); transform: rotate(45deg); margin: -3px 4px 0 3px;
}
.shared-plan[open] > summary::after { transform: rotate(225deg); margin-top: 4px; }
.shared-plan > summary span { display: flex; align-items: center; gap: 8px; margin-right: auto; }
.shared-plan > summary .icon { color: var(--accent); }
.shared-plan > summary small { color: var(--muted); font-weight: 610; }
.plan-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 12px; margin-top: 4px; }
.plan-summary p { color: var(--muted); line-height: 1.42; margin-top: 0; }
.plan-summary strong { display: block; color: var(--ink); font-size: .85rem; }
.plan-form {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px;
  max-width: 730px; padding: 12px 0 9px; margin-top: 6px; border-top: 1px solid var(--line);
}
.plan-form .wide { grid-column: 1 / -1; }
.plan-form button { justify-self: start; grid-column: 1 / -1; }
.technique-grid img { background: #182131; }
@media (max-width: 440px) {
  .plan-summary { grid-template-columns: 1fr; }
  .shared-plan > summary { font-size: .89rem; }
}
