/* App shell on top of moondar.css (the design kit's stylesheet, copied verbatim).
   Desktop: side nav + top bar. Phone (<768px): compact top bar, tab bar, «Ещё» sheet. */

html { background: var(--sky-0); }
body.md-root { margin: 0; min-height: 100vh; }
[x-cloak] { display: none !important; }
.md-root a.nav-item, .md-root a.navlink { color: var(--ink-2); }
.md-root a.nav-item[aria-current="page"], .md-root a.navlink { color: var(--bone); }
.md-root a.btn-secondary, .md-root a.btn-ghost { color: var(--bone); }
.md-root a.btn-primary { color: var(--on-moon); }
.phone-title { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.skip { position: absolute; left: 8px; top: -60px; z-index: 50; padding: 8px 12px; background: var(--moon); color: var(--on-moon); border-radius: var(--r); }
.md-root .skip:focus { top: 8px; color: var(--on-moon); }

.shell { min-height: 100vh; flex-wrap: nowrap; }
.side { flex: 0 0 248px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 12px 20px; text-decoration: none; }
.md-root a.side-brand { color: var(--bone); }
.side-brand .brand-word { font-size: 20px; line-height: 1; }
.side-bottom { margin-top: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 4px; }
.side-bottom form { margin: 0; }
.main { flex: 1 1 auto; }
.content { margin: 0 auto; }

.app-topbar { height: auto; min-height: 72px; flex-wrap: wrap; padding: 12px 32px; }
.topbar-heading { display: flex; align-items: baseline; gap: 4px 16px; flex-wrap: wrap; min-width: 0; }
.topbar-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar-moon { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.md-root .topbar-moon .t-label { color: var(--bone); }
.lvl-chip { display: inline-flex; align-items: center; height: 32px; padding: 0 10px; border-radius: var(--r); background: var(--sky-2); text-decoration: none; }
.md-root a.lvl-chip { color: var(--bone); }
.topbar-name { padding: 0 12px; }
.phone-brand { display: none; }

/* Phone tab bar + «Ещё» sheet */
.phone-nav { display: none; }
.plus-sq { width: 36px; height: 36px; border-radius: var(--r); background: var(--moon); color: var(--on-moon); display: grid; place-items: center; }
.md-root .tabbar a, .md-root .tabbar button { justify-content: flex-end; padding: 0 0 9px; color: var(--ink-3); cursor: pointer; }
.md-root .tabbar a[aria-current="page"] { color: var(--moon); }
.md-root .tabbar button[aria-expanded="true"] { color: var(--bone); }
.scrim { position: fixed; inset: 0 0 calc(64px + env(safe-area-inset-bottom)) 0; border: 0; padding: 0; background: var(--scrim); cursor: pointer; z-index: 30; }
.sheet { position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 31; background: var(--sky-1); border-top: 1px solid var(--rim); border-radius: var(--r) var(--r) 0 0; padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sheet-grid form { margin: 0; }
.navlink { display: flex; align-items: center; gap: 12px; width: 100%; height: 48px; padding: 0 12px; border: 0; border-radius: var(--r); background: var(--sky-2); color: var(--bone); font: 500 15px/1 var(--f-ui); text-decoration: none; cursor: pointer; transition: background-color var(--dur-2) ease; }
@media (hover: hover) and (pointer: fine) {
  .navlink:hover { background: var(--sky-3); }
  .md-root .tabbar a:hover, .md-root .tabbar button:hover { color: var(--bone); }
}

@media (max-width: 767px) {
  .side { display: none; }
  .phone-nav { display: block; }
  .tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 32; height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
  .main { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .app-topbar { min-height: 52px; padding: 4px 6px 4px 16px; border-bottom: 0; flex-wrap: nowrap; }
  .phone-brand { display: flex; flex-direction: column; gap: 2px; text-decoration: none; min-width: 0; }
  .md-root a.phone-brand { color: var(--bone); }
  .phone-brand .brand-word { font-size: 17px; line-height: 20px; }
  .topbar-heading { display: none; }
  .topbar-moon, .topbar-name { display: none; }
  .topbar-tools { gap: 2px; flex-wrap: nowrap; }
  .lvl-chip { height: 30px; padding: 0 9px; }
  .content { padding: 8px 16px 24px; gap: 20px; }
  /* Pages whose title lives in the desktop top bar show it here on phones. */
  .phone-title { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip-path: none; white-space: normal; }
}

/* Today (Today.dc.html helmet) */
.term-rx { transition: rx var(--dur-3) var(--ease-in-out); }
.dcell { width: 100%; max-width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--r); }
.dcell.now { box-shadow: inset 0 0 0 1.5px var(--moon); }
.fl { display: block; width: 40px; height: 5px; border-radius: var(--r-xs); transition: background-color var(--dur-2) ease; }
.fl-open { box-shadow: inset 0 0 0 1px var(--rim); }
@media (max-width: 767px) {
  .dcell { height: 36px; }
  .fl { width: 20px; height: 3px; border-radius: 1px; }
}
@media (prefers-reduced-motion: reduce) {
  .term-rx, .fl { transition: none; }
}

/* Shared layout helpers */
.bone { color: var(--bone); }
.moon-ink { color: var(--moon); }
.row-between { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
.row-baseline { display: flex; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; }
.icon-line { display: flex; align-items: center; gap: 8px; }
h3.icon-line { gap: 10px; }
.stack-0 { display: flex; flex-direction: column; min-width: 0; }
.stack-2 { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stack-6 { display: flex; flex-direction: column; gap: 6px; }
.stack-8 { display: flex; flex-direction: column; gap: 8px; }
.edge-right { margin: -8px -8px -8px 0; }
.md-root form { margin: 0; }

/* Today layout */
.today-grid { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.today-left { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.today-sky { padding: 24px 28px 28px; display: flex; flex-direction: column; gap: 24px; }
.sky-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 24px 32px; }
.sky-moon { position: relative; width: 240px; height: 240px; flex: none; }
.sky-text { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.sky-score { display: flex; align-items: center; gap: 20px; }
.sky-count { color: var(--moon); min-width: 84px; }
.day-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); row-gap: 4px; justify-items: center; align-items: center; }
.day-strip .day-now { color: var(--bone); font-weight: 600; }
.day-strip .dim { color: var(--ink-2); }
.ahead-rule { grid-row: 3; justify-self: stretch; display: flex; align-items: center; gap: 8px; min-width: 0; }
.ahead-rule .rule { flex: 1; height: 1px; background: var(--line); }
.skyline { display: flex; flex-direction: column; gap: 12px; }
.legend { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.legend .fl { width: 16px; }
.legend-won { background: var(--ink-2); }
.skyline-scroll { overflow-x: auto; }
.skyline-inner { min-width: calc(var(--n) * 66px); }
.skyline-row { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); column-gap: 8px; border-bottom: 1px solid var(--rim); }
.building { height: 112px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; }
.skyline-names { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); column-gap: 8px; }
.skyline-names li { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; min-width: 0; }
.bname { font: 500 12px/16px var(--f-ui); color: var(--bone); hyphens: auto; }
.today-ground { display: flex; flex-direction: column; gap: 12px; scroll-margin-top: 16px; }
.logbtn .quota { color: var(--ink-2); white-space: nowrap; }
.logbtn[disabled] { cursor: default; }
.logbtn[disabled]:active { transform: none; }
.add-habit { padding: 4px; }
.add-habit > summary { list-style: none; justify-content: flex-start; width: 100%; }
.add-habit > summary::-webkit-details-marker { display: none; }
.add-form { display: grid; gap: 12px; padding: 12px; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) auto; align-items: start; }
.add-form .btn { margin-top: 24px; }
.today-widgets { flex: 1 1 360px; min-width: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; align-content: start; }
.widget { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.widget-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; }
.xp-today { display: flex; align-items: center; gap: 16px; }
.xp-today .g { white-space: nowrap; min-width: 72px; }
.level-row { display: flex; align-items: center; gap: 12px; }
.level-row .g { white-space: nowrap; }
.level-row .blocks { flex: 1; }
.tg-link { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tg-code { width: 100%; word-break: break-all; color: var(--ink-2); }
@media (max-width: 767px) {
  .today-sky { padding: 16px; gap: 20px; }
  .sky-moon, .sky-moon svg { width: 176px; height: 176px; }
  .sky-count { min-width: 0; }
  .sky-score .g-xl { font-size: 64px; }
  .add-form { grid-template-columns: minmax(0, 1fr); }
  .add-form .btn { margin-top: 0; }
  .today-widgets { grid-template-columns: minmax(0, 1fr); }
  .skyline-inner { min-width: calc(var(--n) * 64px); }
  .building { height: 72px; }
}
