/* ==========================================================================
   PADHLE.WTF — "Studio" layer
   --------------------------------------------------------------------------
   A refinement pass loaded after looseleaf.css. Nothing here replaces the
   Looseleaf language (paper, pencil ink, Kevin Sans, sticky notes, marker
   accents); it tightens the rhythm, makes interactive states obvious, and
   gives the dashboard a proper focal point.

   Rules of engagement:
     · Tokens first. New values are additive custom properties.
     · Motion is opt-in and compositor-friendly (transform / opacity only).
     · High-specificity legacy rules are overridden locally, never by editing
       the 3,600-line structural sheet.
     · Every selector assumes the existing DOM contracts, so the same markup
       keeps working without JavaScript changes.
   ========================================================================== */

/* --------------------------------------------------------------- 1. tokens */
:root {
  --studio-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --studio-ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
  --studio-ring: 0 0 0 2px var(--ll-paper), 0 0 0 5px var(--focus);
  --studio-hair: rgb(42 36 32 / 0.16);
  --studio-hair-strong: rgb(42 36 32 / 0.34);
  --studio-speck: rgb(42 36 32 / 0.06);
  --studio-paper-fixed: #fffdf6;
  --studio-ink-fixed: #2a2420;
}

/* ---------------------------------------------------------------- 2. base -- */
html {
  scrollbar-color: var(--ll-pencil-mark) transparent;
}

body {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  text-wrap: balance;
}

p, li, .card-note, .small, .muted, .field-hint {
  text-wrap: pretty;
}

::selection {
  background: var(--ll-hi);
  color: var(--ll-ink);
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  padding: 1px 5px;
  background: var(--surface);
  color: var(--text);
  border: var(--border-w-thin) solid var(--ink);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.5;
}

/* A slimmer scrollbar inside the workspace; the document itself rarely scrolls. */
#main {
  scrollbar-width: thin;
  scrollbar-color: var(--ll-pencil-mark) transparent;
}
#main::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}
#main::-webkit-scrollbar-track {
  background: transparent;
}
#main::-webkit-scrollbar-thumb {
  background: var(--ll-pencil-mark);
  border: 3px solid var(--ll-paper);
  border-radius: 999px;
}
#main::-webkit-scrollbar-thumb:hover {
  background: var(--ll-pencil);
}

/* --------------------------------------------------------- 3. app layout -- */
.view {
  padding: clamp(var(--sp-4), 2.2vw, var(--sp-7));
}

.view > * + * {
  margin-top: var(--sp-4);
}

.app-footer {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.app-shell > .sidebar {
  padding: 16px 12px 14px;
  overflow-x: hidden;
  background-image:
    linear-gradient(180deg, rgb(255 255 255 / 0.16), transparent 160px),
    radial-gradient(circle at 18% 4%, var(--studio-speck) 0 1px, transparent 1.5px);
  background-size: auto, 10px 10px;
}

/* Dark mode: the navbar and sidebar are one flat sheet of paper. The daylight
   texture wash reads as a muddy gradient on charcoal, so drop it entirely and
   let both chrome surfaces match the dashboard exactly. */
[data-theme="dark"] .app-shell > .sidebar,
[data-theme="dark"] .topbar {
  background-image: none;
  background-color: var(--surface);
}

/* ------------------------------------------------------------- 4. topbar --- */
.topbar {
  gap: var(--sp-3);
  padding: 10px clamp(var(--sp-3), 1.8vw, var(--sp-5));
  box-shadow: 0 1px 0 var(--studio-hair);
}

.topbar-lead {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 0 1 auto;
}

.topbar-title {
  min-width: 0;
}

.topbar .crumb {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  line-height: 1.2;
}

.topbar h1 {
  font-size: clamp(1.05rem, 0.75rem + 0.5vw, 1.35rem);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  gap: 7px;
  min-width: 0;
}

.topbar-timer:empty {
  display: none;
}

.topbar-timer {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.topbar-search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.topbar-search .input {
  width: min(270px, 25vw);
  min-height: 38px;
  padding: 7px 30px 7px 32px;
  background: var(--ll-slip);
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  transition: width var(--speed) var(--studio-ease), background var(--speed), box-shadow var(--speed);
}

.topbar-search .input:focus {
  width: min(320px, 32vw);
  transform: none;
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  box-shadow: var(--shadow-sm-hover);
}

.topbar-search-ico {
  position: absolute;
  left: 11px;
  top: 50%;
  translate: 0 -50%;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  pointer-events: none;
}

.topbar-kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  translate: 0 -50%;
  min-width: 17px;
  padding: 0 4px;
  font-size: 9px;
  color: var(--muted);
  background: var(--surface);
  border: var(--border-w-thin) solid var(--line);
  border-radius: 4px;
  line-height: 1.6;
  pointer-events: none;
}

.topbar-streak {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 3px 10px 3px 8px;
  background: var(--ll-sticky-yellow);
  color: var(--studio-ink-fixed);
  border: var(--border-w) solid var(--studio-ink-fixed);
  border-radius: var(--r-pill);
  box-shadow: 1px 2px 0 rgb(42 36 32 / 0.22);
  font-size: var(--fs-xs);
  white-space: nowrap;
}
.topbar-streak .streak-emoji {
  font-size: 14px;
  line-height: 1;
  filter: saturate(1.1);
}
.topbar-streak .streak-val b {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
.topbar-streak .streak-word {
  font-weight: 700;
}

.theme-btn {
  font-size: 17px;
  line-height: 1;
}

.avatar-menu {
  position: relative;
  display: inline-flex;
}

.avatar-btn {
  position: relative;
  width: 38px;
  height: 38px;
  min-width: 38px;
  padding: 0;
  border-radius: 50%;
  background: var(--ll-photo);
  font-size: 19px;
  line-height: 1;
}
.avatar-btn .avatar-emoji {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  transition: transform var(--speed) var(--studio-ease-spring);
}
.avatar-btn:hover .avatar-emoji {
  transform: rotate(-8deg) scale(1.06);
}
.avatar-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  background: var(--ll-green);
  border: 2px solid var(--surface);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--studio-ink-fixed);
}

.avatar-popup {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
  display: none;
  width: 248px;
  padding: 0;
  background: var(--surface);
  border: var(--border-w) solid var(--ink);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}
.avatar-popup.open {
  display: block;
  animation: studio-pop 160ms var(--studio-ease) both;
}
.avatar-popup-id {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--surface-3);
  border-bottom: var(--border-dash);
}
.avatar-popup-emoji {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  background: var(--ll-photo);
  border: var(--border-w) solid var(--ink);
  border-radius: 50%;
  font-size: 19px;
}
.avatar-popup-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}
.avatar-popup-meta b {
  font-size: var(--fs-sm);
  color: var(--text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.avatar-popup-meta small {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.avatar-popup-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 13px;
  background: transparent;
  border: 0;
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--speed), color var(--speed);
}
.avatar-popup-item .ico {
  width: 18px;
  text-align: center;
  color: var(--muted);
}
.avatar-popup-item:hover,
.avatar-popup-item:focus-visible {
  background: var(--yellow-light);
  color: var(--ink);
  text-decoration: none;
}
.avatar-popup-item.danger {
  color: var(--bad-ink);
}
.avatar-popup-item.danger:hover {
  background: var(--bad-light);
}
.avatar-popup-sep {
  height: 0;
  margin: 2px 0;
  border-top: var(--border-dash);
}

/* ------------------------------------------------------------ 5. sidebar --- */
.brand-header {
  position: relative;
  padding: 4px 6px 16px;
  text-align: left;
}

.sidebar-brand {
  text-decoration: none;
  color: var(--ll-ink);
  gap: 1px;
  letter-spacing: -0.045em;
  transition: transform var(--speed) var(--studio-ease-spring);
  transform-origin: left center;
}
.sidebar-brand:hover {
  text-decoration: none;
  transform: rotate(-1.5deg) scale(1.015);
}
.brand-header .ink-brand {
  display: block;
  margin-top: 2px;
  opacity: 0.8;
}
.brand-header .brand-tagline {
  margin-top: 4px;
  font-size: 9.5px;
  letter-spacing: 0.2em;
}

/* Public/welcome top bar: the same wordmark, underline and tagline as the app
   sidebar, compressed so it sits comfortably beside the auth actions. */
.public-brand.public-brand-header {
  display: block;
  padding: 0;
  line-height: 1;
}
.public-brand-header .sidebar-brand {
  font-size: clamp(1.3rem, 2.4vw, 1.65rem);
}
.public-brand-header .ink-brand {
  width: clamp(104px, 14vw, 132px);
  height: 9px;
  margin: 3px 0 0 1px;
  color: var(--accent);
  opacity: 1;
}
.public-brand-header .brand-tagline {
  margin-top: 2px;
  font-size: 8.5px;
  letter-spacing: 0.16em;
}

/* The drawer's close affordance only exists where the sidebar is a drawer.
   `.app-shell .sidebar` outranks `.btn.icon`'s inline-grid, so resizing back to
   desktop removes it completely instead of leaving a stray ✕ in the brand row. */
.app-shell .sidebar .sidebar-close {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
}

.nav {
  flex: 1 1 auto;
  min-height: 0;
  gap: 3px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding: 2px 4px 6px;
  margin-inline: -4px;
}

/* A quiet, paper-first nav: coloured ink tiles instead of eleven loud pills. */
.app-shell .nav a {
  position: relative;
  gap: 10px;
  padding: 7px 10px;
  background: transparent;
  border-color: transparent;
  border-radius: var(--r-sm);
  color: var(--text);
  font-weight: 600;
  line-height: 1.2;
  transition: background var(--speed), color var(--speed), transform var(--speed);
}
.app-shell .nav a:hover:not(.active) {
  background: var(--surface-2);
  color: var(--text-strong);
  border-color: var(--line);
  box-shadow: none;
  transform: translateX(2px);
}
.app-shell .nav a.active {
  background: var(--primary) !important;
  color: var(--primary-text) !important;
  border-color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.app-shell .nav a .ico {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  background: var(--ll-sticky-yellow);
  border: var(--border-w-thin) solid rgb(42 36 32 / 0.55);
  border-radius: 5px;
  box-shadow: 1px 1px 0 rgb(42 36 32 / 0.22);
  color: var(--studio-ink-fixed);
  font-size: 13px;
  line-height: 1;
}
.nav a[data-group="Plan"] .ico { background: var(--ll-sticky-blue); }
.nav a[data-group="Do"] .ico { background: var(--ll-sticky-orange); }
.nav a[data-group="Review"] .ico { background: var(--ll-sticky-green); }
.nav a.active .ico {
  background: var(--studio-paper-fixed);
  border-color: var(--studio-ink-fixed);
  box-shadow: none;
}

.nav a[data-group-start] {
  margin-top: 11px;
}
.nav a[data-group-start]::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 10px;
  right: 10px;
  border-top: var(--border-dash);
  opacity: 0.7;
  pointer-events: none;
}
.nav a:first-child[data-group-start] {
  margin-top: 0;
}
.nav a:first-child[data-group-start]::before {
  display: none;
}

.app-shell .nav a .count {
  margin-left: auto;
  min-width: 20px;
  min-height: 18px;
  padding: 1px 5px;
  display: inline-grid;
  place-items: center;
  background: var(--studio-paper-fixed);
  color: var(--studio-ink-fixed);
  border: 1px solid var(--studio-ink-fixed);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}
.app-shell .nav a.active .count {
  background: var(--studio-ink-fixed);
  color: var(--ll-sticky-yellow);
  border-color: var(--studio-ink-fixed);
}

.sidebar-foot {
  gap: 9px;
  padding-top: 12px;
}

.sidebar-cta {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  background: var(--ll-sticky-yellow);
  color: var(--studio-ink-fixed);
  border: var(--border-w) solid var(--studio-ink-fixed);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: transform var(--speed) var(--studio-ease), box-shadow var(--speed);
}
.sidebar-cta:hover {
  text-decoration: none;
  transform: translateY(-1px) rotate(-0.4deg);
  box-shadow: var(--shadow);
}
.sidebar-cta-ico {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  background: var(--studio-paper-fixed);
  border: 1px solid var(--studio-ink-fixed);
  border-radius: 50%;
  font-size: 14px;
}
.sidebar-cta-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}
.sidebar-cta-text b {
  font-size: var(--fs-sm);
}
.sidebar-cta-text small {
  font-size: 10px;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  opacity: 0.7;
}
.sidebar-cta-arrow {
  margin-left: auto;
  font-weight: 800;
}

.sidebar-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-inline: 2px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}

/* ------------------------------------------------------- 5b. sidebar collapsed ---
   When the desktop sidebar collapses to a narrow rail, make every target
   large enough to hit and understand: bigger ink tiles, hover tooltips, and a
   compact brand mark so the rail never feels like a row of mystery buttons. */

.app-shell .sidebar.collapsed .brand-header {
  display: block;
  padding: 8px 6px 10px;
  text-align: center;
  overflow: hidden;
}

.app-shell .sidebar.collapsed {
  overflow: hidden;
  box-sizing: border-box;
}

/* Compact brand mark: hide the full wordmark + tagline, show a small P mark */
.app-shell .sidebar.collapsed .sidebar-brand {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin: 0 auto 6px;
  background: var(--ll-sticky-yellow);
  border: var(--border-w-thin) solid rgb(42 36 32 / 0.45);
  border-radius: 8px;
  box-shadow: 1px 1px 0 rgb(42 36 32 / 0.22);
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
  color: var(--studio-ink-fixed);
  text-decoration: none;
  transform: none;
  gap: 0;
}
.app-shell .sidebar.collapsed .sidebar-brand:hover {
  transform: rotate(-1deg) scale(1.05);
  background: var(--ll-sticky-orange);
}
.app-shell .sidebar.collapsed .brand-name,
.app-shell .sidebar.collapsed .brand-dot,
.app-shell .sidebar.collapsed .brand-wtf,
.app-shell .sidebar.collapsed .brand-tagline,
.app-shell .sidebar.collapsed .brand-header .ink-brand {
  display: none !important;
}

/* Larger, clearer nav icons when collapsed */
.app-shell .sidebar.collapsed .nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 9px 4px;
  font-size: 0;
  min-height: auto;
}
.app-shell .sidebar.collapsed .nav a .ico {
  width: 38px;
  height: 38px;
  font-size: 17px;
  border-radius: 8px;
  box-shadow: 2px 2px 0 rgb(42 36 32 / 0.25);
  margin: 0 auto;
}
.app-shell .sidebar.collapsed .nav a .nav-label,
.app-shell .sidebar.collapsed .nav a span:not(.ico):not(.count) {
  display: none !important;
}
.app-shell .sidebar.collapsed .nav a .count {
  position: absolute;
  top: 6px;
  right: 4px;
  font-size: 9px;
  padding: 1px 5px;
  min-width: 18px;
  min-height: 18px;
}

/* Hover reveals the label as a tooltip so icons are never mystery meat */
.app-shell .sidebar.collapsed .nav a::after {
  content: attr(title);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 8px;
  padding: 4px 8px;
  background: var(--ink);
  color: var(--surface);
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.05em;
  white-space: nowrap;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transition: opacity 120ms var(--studio-ease), visibility 120ms var(--studio-ease);
  pointer-events: none;
  z-index: 60;
}
.app-shell .sidebar.collapsed .nav a:hover::after {
  opacity: 1;
  visibility: visible;
}

/* Group separators and spacing when collapsed */
.app-shell .sidebar.collapsed .nav a[data-group-start]::before {
  display: none;
}
.app-shell .sidebar.collapsed .nav a[data-group-start] {
  margin-top: 8px;
}

/* Compact CTA when collapsed */
.app-shell .sidebar.collapsed .sidebar-cta {
  display: inline-grid;
  place-items: center;
  padding: 8px 4px;
  gap: 5px;
  min-height: auto;
}
.app-shell .sidebar.collapsed .sidebar-cta-ico {
  width: 32px;
  height: 32px;
  font-size: 16px;
  margin: 0 auto 2px;
}
.app-shell .sidebar.collapsed .sidebar-cta-text,
.app-shell .sidebar.collapsed .sidebar-cta-arrow {
  display: none !important;
}

/* Hide level/XP hint when collapsed */
.app-shell .sidebar.collapsed .sidebar-hint {
  display: none;
}

/* Close button styled for collapsed state — only visible on small screens
   (see @media max-width: 1080px below). On desktop this stays hidden. */
.app-shell .sidebar.collapsed .sidebar-close {
  place-items: center;
  width: 32px;
  height: 32px;
  margin: 8px auto 0;
  font-size: 14px;
}

/* ------------------------------------------------------- 6. buttons/forms -- */
.btn {
  border-radius: var(--r-sm);
  min-height: 38px;
  transition:
    transform var(--speed) var(--studio-ease),
    box-shadow var(--speed) var(--studio-ease),
    background var(--speed),
    color var(--speed),
    border-color var(--speed);
}
.btn:active {
  transform: translateY(1px) scale(0.995);
  box-shadow: var(--shadow-sm);
}
.btn.primary:active {
  box-shadow: inset 0 1px 3px rgb(42 36 32 / 0.28);
}
.btn.icon {
  min-width: 38px;
  padding: 7px 9px;
  display: inline-grid;
  place-items: center;
  line-height: 1;
}
.btn.sm {
  min-height: 30px;
}
.btn.sm.icon {
  min-width: 30px;
}
.btn.ghost:active {
  transform: translateY(1px);
}

.input,
.select,
.textarea,
input[type="date"],
input[type="time"],
input[type="number"],
input[type="search"] {
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  transition: box-shadow var(--speed), border-color var(--speed), background var(--speed);
}
.input::placeholder,
.textarea::placeholder {
  color: var(--pencil-text, var(--faint));
  opacity: 0.78;
}
.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--ink);
  box-shadow: var(--shadow-sm-hover);
}

.chip {
  line-height: 1.5;
}

/* --------------------------------------------------------------- 7. cards -- */
.card {
  transition: box-shadow var(--speed) var(--studio-ease), border-color var(--speed);
}
@media (hover: hover) {
  .card:hover {
    box-shadow: var(--shadow-hover);
    transform: none;
  }
  /* Only cards that are actually links get the little lift. */
  a.card:hover,
  .metric-link:hover,
  .suggest-item:hover {
    transform: translate(-2px, -2px);
    box-shadow: var(--shadow-hover);
  }
}

.card-title h2::before {
  width: 11px;
  height: 11px;
  background: var(--ll-hi);
  transform: rotate(-6deg);
  box-shadow: 1px 1px 0 var(--ink);
}

.card-sub {
  margin: 2px 0 0;
  max-width: 68ch;
}

.card-note {
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  line-height: 1.55;
}

/* ----------------------------------------------------------- 8. dashboard -- */
.dash-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(18px, 2.3vw, 30px);
}

.dash-hero::after {
  content: "";
  position: absolute;
  right: -70px;
  bottom: -110px;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(255 253 246 / 0.34), transparent 68%);
  pointer-events: none;
}

.dash-hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(290px, 0.8fr);
  gap: clamp(18px, 2.5vw, 34px);
  align-items: start;
}

.dash-hero-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.dash-hero-readiness {
  display: flex;
  align-items: center;
  gap: clamp(16px, 2vw, 28px);
  flex-wrap: wrap;
}

.readiness-ring {
  --ring-size: 150px;
  width: var(--ring-size);
  aspect-ratio: 1;
  flex: 0 0 auto;
  padding: 12px;
  border-radius: 50%;
  border: 2px solid var(--studio-ink-fixed);
  background: conic-gradient(var(--studio-ink-fixed) calc(var(--p, 0) * 1%), rgb(42 36 32 / 0.16) 0);
  box-shadow: 4px 5px 0 rgb(42 36 32 / 0.16);
  transform: rotate(-2deg);
}

.readiness-ring-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--studio-paper-fixed);
  color: var(--studio-ink-fixed);
  border: 1px solid rgb(42 36 32 / 0.28);
  transform: rotate(2deg);
  text-align: center;
}

.readiness-ring .hero-num {
  font-size: clamp(1.75rem, 1.3rem + 1vw, 2.3rem);
  line-height: 1;
  color: var(--studio-ink-fixed);
}
.readiness-ring .ink-hero {
  width: 68%;
  height: auto;
  opacity: 0.85;
}
.readiness-ring .xs {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--studio-ink-fixed);
  opacity: 0.65;
}

.dash-hero-lede {
  display: flex;
  flex-direction: column;
  gap: 9px;
  flex: 1 1 240px;
  min-width: 0;
}

.dash-hero-title {
  margin: 2px 0 0;
  font-size: clamp(1.15rem, 0.95rem + 0.75vw, 1.55rem);
  line-height: 1.18;
  letter-spacing: -0.015em;
  color: var(--studio-ink-fixed);
}

.dash-hero-lede .small.muted {
  max-width: 56ch;
  margin: 0;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 2px;
}

.dash-hero-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.dash-hero .buddy-bubble {
  background: var(--studio-paper-fixed);
  color: var(--studio-ink-fixed);
  border-color: var(--studio-ink-fixed);
}
.dash-hero .buddy-title {
  color: rgb(42 36 32 / 0.62);
}
.dash-hero .buddy-text {
  color: var(--studio-ink-fixed);
}

.buddy {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}
.buddy-art {
  flex: 0 0 auto;
  filter: drop-shadow(0 4px 5px rgb(42 36 32 / 0.16));
}
.buddy-bubble {
  position: relative;
  min-width: 0;
  padding: 9px 12px;
  background: var(--ll-photo);
  color: var(--text);
  border: var(--border-w) solid var(--ink);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
}
.buddy-bubble::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 20px;
  width: 12px;
  height: 12px;
  background: inherit;
  border-left: var(--border-w) solid var(--ink);
  border-bottom: var(--border-w) solid var(--ink);
  transform: rotate(45deg);
}
.buddy-title {
  display: block;
  margin-bottom: 1px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.buddy-text {
  margin: 0;
  font-size: var(--fs-sm);
  line-height: 1.45;
}

.mascot {
  display: block;
  max-width: 100%;
  height: auto;
  overflow: visible;
}

@media (prefers-reduced-motion: no-preference) {
  .dash-buddy .mascot {
    transform-origin: 50% 92%;
    animation: studio-buddy-bob 5.5s ease-in-out infinite;
  }
  .dash-buddy:hover .mascot {
    animation-play-state: paused;
    transform: rotate(-4deg) translateY(-1px);
  }
}

.hero-statgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 16px;
  padding: 5px 12px;
  background: rgb(255 253 246 / 0.36);
  border: 1px solid rgb(42 36 32 / 0.26);
  border-radius: var(--r-sm);
}
.hero-statgrid .stat-line {
  padding: 6px 0;
  border-bottom: 1px dashed rgb(42 36 32 / 0.26);
}
.hero-statgrid .stat-line b {
  color: var(--studio-ink-fixed);
  font-size: var(--fs-sm);
  line-height: 1.3;
}
.hero-statgrid .stat-line .muted {
  color: rgb(42 36 32 / 0.68);
}
.hero-statgrid .stat-line:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  border-bottom: 0;
}

.xp-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 9px 12px;
  background: rgb(255 253 246 / 0.32);
  border: 1px solid rgb(42 36 32 / 0.28);
  border-radius: var(--r-sm);
}
.xp-card .small.muted {
  color: rgb(42 36 32 / 0.72);
}
.xp-card .xp-bar {
  height: 8px;
  background: rgb(255 253 246 / 0.7);
  border-color: var(--studio-ink-fixed);
}
.xp-card .xp-bar > span {
  background: var(--studio-ink-fixed);
  border-right-color: var(--studio-ink-fixed);
}

.dash-hero .callout {
  position: relative;
  z-index: 1;
}

/* Today + quests + streak form one calm, full-width reading column. Each
   surface gets the same rhythm whether the viewport is a laptop or a phone. */
.dash-focus-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-4);
  align-items: start;
}
.dash-focus-grid > .card {
  min-width: 0;
}
.dash-focus-grid > .card + .card {
  margin-top: 0;
}
/* Keep the quest header action on one line when the card gets narrow. */
.dash-quests .card-title .btn {
  white-space: nowrap;
}
/* Full-width quests prefer readable tiles over squeezing five into one row. */
.dash-quests .quest-list {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* A full-width streak card reads better as a label + week strip than as a
   seven-square island in a very wide row. */
@media (min-width: 861px) {
  .streak-card {
    display: flex;
    align-items: center;
    gap: clamp(18px, 3vw, 36px);
    flex-wrap: wrap;
  }
  .streak-card > .row {
    flex: 0 0 auto;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 3px;
  }
  .streak-card .streak-calendar {
    flex: 1 1 520px;
    width: auto;
    max-width: 760px;
    margin: 0 0 0 auto;
  }
}

.streak-calendar {
  gap: 7px;
}
.streak-day {
  width: auto;
  height: auto;
  aspect-ratio: 1;
  flex-direction: column;
  gap: 0;
  padding: 4px 2px;
  position: relative;
  border: var(--border-w-thin) solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: var(--fs-xs);
  line-height: 1.1;
}
.streak-day-dow {
  font-family: var(--font-mono);
  font-size: 8px;
  text-transform: uppercase;
  opacity: 0.62;
}
.streak-day-num {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.streak-day.done {
  background: var(--ll-sticky-green);
  color: var(--studio-ink-fixed);
  border-color: var(--studio-ink-fixed);
}
.streak-day.current {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--studio-ink-fixed);
  box-shadow: 0 0 0 3px rgb(217 119 36 / 0.24);
}
.streak-day-flame {
  position: absolute;
  top: -6px;
  right: -4px;
  font-size: 10px;
  filter: drop-shadow(0 1px 0 rgb(42 36 32 / 0.24));
}
.streak-card .streak-calendar {
  margin-top: 10px;
}

/* ---------------------------------------------------------------- 9. KPI -- */
/* KPI cards sit in a grid: the legacy ".card + .card" gap must not stagger rows. */
.metrics > .card + .card,
.tiles > .card + .card,
.grid-2 > .card + .card,
.grid-3 > .card + .card {
  margin-top: 0;
}
.metrics {
  gap: 10px;
}
.metrics > .card > .metric,
.metrics > .card.metric-link > .metric {
  position: relative;
  overflow: hidden;
  min-height: 92px;
  padding: 13px 14px;
  border-radius: var(--r-sm);
  transition: border-color var(--speed), background var(--speed);
}
.metrics .metric::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--ll-sticky-yellow);
}
.metrics .metric[data-tone="ok"]::before { background: var(--ok); }
.metrics .metric[data-tone="warn"]::before { background: var(--warn); }
.metrics .metric[data-tone="bad"]::before { background: var(--bad); }
.metrics .metric .k {
  font-size: 10px;
  letter-spacing: 0.12em;
  line-height: 1.35;
}
.metrics .metric .v {
  font-size: clamp(1.2rem, 0.95rem + 0.85vw, 1.65rem);
  line-height: 1.1;
}
.metrics .metric .s {
  line-height: 1.35;
  margin-top: auto;
}
.metric-link:hover .metric {
  border-color: var(--studio-ink-fixed);
}

/* --------------------------------------------------------------- 10. tiles -- */
.tiles {
  gap: 10px;
}
.tile {
  border-radius: var(--r-sm);
}
.tile .tile-mark {
  border-radius: 5px;
  box-shadow: 2px 2px 0 var(--ink);
}
.tile h3 {
  line-height: 1.25;
}
@media (hover: hover) {
  .tile:hover {
    transform: translate(-2px, -2px) rotate(-0.2deg);
    box-shadow: var(--shadow-hover);
  }
  .tile:hover .tile-mark {
    transform: rotate(-4deg);
  }
}
.tile .tile-mark {
  transition: transform var(--speed) var(--studio-ease-spring);
}

/* ------------------------------------------------------------- 11. toasts -- */
.toasts {
  right: max(var(--sp-4), env(safe-area-inset-right));
  bottom: max(var(--sp-4), env(safe-area-inset-bottom));
  gap: 9px;
  width: min(410px, calc(100vw - 24px));
  max-width: none;
  z-index: 90;
}

.toast {
  --toast-tone: var(--info);
  --toast-soft: var(--info-light);
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 24px;
  align-items: start;
  gap: 9px;
  padding: 10px 8px 12px 12px;
  overflow: hidden;
  background: var(--surface);
  color: var(--text);
  border: var(--border-w) solid var(--ink);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  font-weight: 500;
  animation: studio-toast-in 220ms var(--studio-ease) both;
}
.toast.ok { --toast-tone: var(--ok-ink); --toast-soft: var(--ok-light); background: var(--surface); }
.toast.err { --toast-tone: var(--bad-ink); --toast-soft: var(--bad-light); background: var(--surface); }
.toast.warn { --toast-tone: var(--warn-ink); --toast-soft: var(--warn-light); background: var(--surface); }
.toast.info { --toast-tone: var(--info); --toast-soft: var(--info-light); background: var(--surface); }

.toast::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--toast-tone);
}

.toast-ico {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--toast-soft);
  color: var(--toast-tone);
  border: 1px solid var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.toast-body {
  min-width: 0;
}
.toast-kind {
  display: block;
  margin-bottom: 1px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--toast-tone);
}
.toast-msg {
  font-size: var(--fs-sm);
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.toast-close {
  align-self: start;
  min-width: 24px;
  min-height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-size: 12px;
}
.toast-close:hover {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: none;
}
.toast-life {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 3px;
  background: var(--toast-tone);
  transform-origin: left center;
  animation: studio-toast-life var(--toast-life, 5000ms) linear forwards;
}
.toast.paused .toast-life {
  animation-play-state: paused;
}
.toast-out {
  animation: studio-toast-out 160ms var(--studio-ease) both;
}

/* -------------------------------------------------------------- 12. modal -- */
.modal-backdrop {
  background-color: rgb(26 22 18 / 0.34);
  background-image:
    repeating-linear-gradient(45deg, rgb(255 255 255 / 0.035) 0 10px, transparent 10px 20px);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.modal {
  border-radius: var(--r-sm);
  animation: studio-modal-in 180ms var(--studio-ease) both;
}
.modal-head h2 {
  letter-spacing: 0.02em;
}

/* --------------------------------------------------------- 13. empty state -- */
.empty {
  position: relative;
  overflow: hidden;
  background: var(--surface-3);
  border: var(--border-w-thick) dashed var(--ink);
  border-radius: var(--r-sm);
  color: var(--text);
}
.empty::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 22px;
  width: 52px;
  height: 15px;
  background: var(--ll-tape);
  border: 1px solid var(--ll-tape-edge);
  transform: rotate(-3deg);
  pointer-events: none;
}
.empty::after {
  content: "";
  position: absolute;
  right: -18px;
  bottom: -22px;
  width: 92px;
  height: 92px;
  border: var(--border-dash);
  border-radius: 50%;
  opacity: 0.5;
  pointer-events: none;
}
.empty-art {
  position: relative;
  display: grid;
  place-items: center;
  margin-bottom: 2px;
}
.empty-mascot {
  filter: drop-shadow(0 6px 7px rgb(42 36 32 / 0.18));
  transition: transform var(--speed) var(--studio-ease-spring);
}
@media (hover: hover) {
  .empty:hover .empty-mascot {
    transform: rotate(-3deg) translateY(-2px);
  }
}
.empty .em-ico {
  position: absolute;
  right: -12px;
  bottom: -2px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--ll-sticky-yellow);
  border: var(--border-w) solid var(--studio-ink-fixed);
  box-shadow: 2px 2px 0 rgb(42 36 32 / 0.18);
  color: var(--studio-ink-fixed);
  font-size: 16px;
  transform: rotate(-6deg);
}
.empty[data-mood="oops"] .em-ico { background: var(--ll-sticky-pink); }
.empty[data-mood="curious"] .em-ico { background: var(--ll-sticky-blue); }
.empty[data-mood="cheer"] .em-ico,
.empty[data-mood="wow"] .em-ico { background: var(--ll-sticky-green); }
.empty h3 {
  font-size: var(--fs-lg);
}
.empty p {
  max-width: 52ch;
  line-height: 1.55;
}

/* ----------------------------------------------------------- 14. landing --- */
.landing-title {
  text-wrap: balance;
}
.landing-lead {
  max-width: 62ch;
}

.landing-buddy {
  position: absolute;
  left: -22px;
  bottom: -26px;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  transform: rotate(-3deg);
  filter: drop-shadow(0 8px 12px rgb(42 36 32 / 0.18));
  pointer-events: none;
}
.landing-buddy-note {
  margin-bottom: 16px;
  padding: 5px 9px;
  background: var(--ll-sticky-yellow);
  color: var(--studio-ink-fixed);
  border: var(--border-w) solid var(--studio-ink-fixed);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 2px 2px 0 rgb(42 36 32 / 0.18);
}

@media (hover: hover) {
  .landing-marquee:hover .landing-marquee-track {
    animation-play-state: paused;
  }
}

/* -------------------------------------------------------- 15. route motion -- */
@media (prefers-reduced-motion: no-preference) {
  .view.route-enter > * {
    animation: studio-rise 360ms var(--studio-ease) both;
  }
  .view.route-enter > *:nth-child(2) { animation-delay: 28ms; }
  .view.route-enter > *:nth-child(3) { animation-delay: 56ms; }
  .view.route-enter > *:nth-child(4) { animation-delay: 84ms; }
  .view.route-enter > *:nth-child(5) { animation-delay: 112ms; }
  .view.route-enter > *:nth-child(6) { animation-delay: 140ms; }
  .view.route-enter > *:nth-child(7) { animation-delay: 168ms; }
  .view.route-enter > *:nth-child(8) { animation-delay: 196ms; }
  .view.route-enter > *:nth-child(n + 9) { animation-delay: 220ms; }
}

/* ----------------------------------------------------------- 16. confetti --- */
.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 120;
  overflow: hidden;
  pointer-events: none;
}
.confetti-layer span {
  position: absolute;
  top: 0;
  left: 50%;
  width: 9px;
  height: 12px;
  background: var(--c, var(--ll-sticky-yellow));
  border: 1px solid rgb(42 36 32 / 0.3);
  border-radius: 2px;
  opacity: 0;
  animation: studio-confetti var(--dur, 1000ms) cubic-bezier(0.2, 0.7, 0.3, 1) var(--delay, 0ms) forwards;
}

/* ------------------------------------------------------ 17. responsive ----- */
@media (max-width: 1080px) {
  .app-shell .sidebar.collapsed .brand-header {
    display: block;
  }
  .app-shell .sidebar .sidebar-close {
    display: inline-grid;
  }
  .app-shell .sidebar.collapsed .nav a[data-group-start]::before {
    display: none;
  }
  .nav-scrim {
    background: rgb(20 18 14 / 0.48);
    -webkit-backdrop-filter: blur(1px);
    backdrop-filter: blur(1px);
  }
}

@media (max-width: 1000px) {
  .dash-hero-grid {
    grid-template-columns: 1fr;
  }
  .dash-hero-side {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    align-items: start;
  }
  .dash-hero-side .dash-buddy {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .topbar-kbd {
    display: none;
  }
  .topbar-search .input {
    width: min(210px, 28vw);
    padding-right: 12px;
  }
  .topbar-search .input:focus {
    width: min(260px, 36vw);
  }
  .streak-word {
    display: none;
  }
  .topbar-streak {
    padding-inline: 8px;
  }
}

@media (max-width: 760px) {
  .topbar .crumb {
    display: none;
  }
  .topbar-search .input {
    width: min(180px, 30vw);
  }
  .topbar-streak {
    display: none;
  }
}

@media (max-width: 720px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .metrics .metric {
    min-height: 84px;
    padding: 11px 12px;
  }
  .metrics .metric .k {
    font-size: 9px;
  }
  .metrics .metric .v {
    font-size: 1.15rem;
  }
  .dash-focus-grid {
    grid-template-columns: 1fr;
  }
  .hero-actions .btn {
    flex: 1 1 auto;
  }
  .landing-buddy {
    display: none;
  }
  .view {
    padding: var(--sp-3);
  }
  .view > * + * {
    margin-top: var(--sp-3);
  }
  .toasts {
    left: 10px;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    width: auto;
  }
}

@media (max-width: 640px) {
  .topbar {
    flex-wrap: wrap;
    row-gap: 8px;
  }
  .topbar-lead {
    flex: 1 1 auto;
  }
  .topbar-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .topbar-search {
    flex: 1 1 auto;
  }
  .topbar-search .input,
  .topbar-search .input:focus {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .dash-hero {
    padding: 15px;
  }
  .dash-hero-readiness {
    align-items: flex-start;
    gap: 14px;
  }
  .readiness-ring {
    --ring-size: 124px;
  }
  .dash-hero-side {
    grid-template-columns: 1fr;
  }
  .hero-statgrid {
    grid-template-columns: 1fr 1fr;
  }
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .empty {
    padding: var(--sp-6) var(--sp-4);
  }
}

@media (max-width: 400px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }
  .metrics .metric {
    min-height: 76px;
    padding: 9px 10px;
  }
  .hero-actions .btn {
    flex: 1 1 100%;
  }
  .readiness-ring {
    --ring-size: 112px;
  }
  .avatar-popup {
    width: min(248px, calc(100vw - 20px));
  }
}

/* ------------------------------------------------------ 18. modal sheet ---- */
@media (max-width: 620px) {
  .modal-backdrop {
    padding: 0;
    place-items: end center;
  }
  .modal {
    width: 100%;
    max-width: none;
    max-height: 90dvh;
    border-radius: 14px 14px 0 0;
    border-bottom-width: 0;
    animation: studio-sheet-up 240ms var(--studio-ease) both;
  }
  .modal-foot {
    padding-bottom: max(var(--sp-4), env(safe-area-inset-bottom));
  }
}

/* ------------------------------------------------------ 19. accessibility -- */
@media (prefers-contrast: more) {
  .card,
  .btn,
  .input,
  .select,
  .textarea,
  .chip,
  .toast,
  .avatar-popup {
    border-width: 2px;
  }
  .nav a[data-group-start]::before {
    border-top-style: solid;
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dash-buddy .mascot,
  .view.route-enter > *,
  .toast,
  .toast-out,
  .avatar-popup.open,
  .modal,
  .confetti-layer span {
    animation: none !important;
  }
  .confetti-layer {
    display: none;
  }
  .topbar-search .input {
    transition: none;
  }
}

/* ---------------------------------------------------------- 20. keyframes --- */
@keyframes studio-pop {
  from { opacity: 0; transform: translateY(-4px) scale(0.984); }
  to { opacity: 1; transform: none; }
}

@keyframes studio-rise {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: none; }
}

@keyframes studio-buddy-bob {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-3px) rotate(1deg); }
}

@keyframes studio-toast-in {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@keyframes studio-toast-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateX(14px); }
}

@keyframes studio-toast-life {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

@keyframes studio-modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.992); }
  to { opacity: 1; transform: none; }
}

@keyframes studio-sheet-up {
  from { opacity: 0; transform: translateY(28px); }
  to { opacity: 1; transform: none; }
}

@keyframes studio-confetti {
  0% { opacity: 0; transform: translate3d(var(--x, 0), -8vh, 0) rotate(0); }
  8% { opacity: 1; }
  100% { opacity: 0; transform: translate3d(calc(var(--x, 0) + var(--drift, 0px)), 96vh, 0) rotate(var(--spin, 360deg)); }
}

/* ==========================================================================
   21. Micro-interactions — the small confirmations that make an app feel hand-made.
   Everything here is transform/opacity first, so it stays compositor-friendly.
   ========================================================================== */

/* ------------------------------------------------ 21.1 page rhythm & heads -- */
.view h1 {
  text-wrap: balance;
}
.view > .card.stripe:first-child {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: clamp(16px, 2vw, 26px);
}
.view > .card.stripe:first-child::after {
  content: "";
  position: absolute;
  z-index: -1;
  right: -60px;
  top: -80px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--stripe, var(--accent)) 26%, transparent), transparent 68%);
  pointer-events: none;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.eyebrow::before {
  content: "";
  width: 15px;
  height: 3px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.5;
}
.view > .card.stripe:first-child h1 {
  letter-spacing: -0.02em;
}

/* --------------------------------------------------- 21.2 tactile controls -- */
.btn {
  transition:
    transform 140ms var(--studio-ease),
    box-shadow 160ms var(--studio-ease),
    background-color 160ms var(--studio-ease),
    border-color 160ms var(--studio-ease),
    color 160ms var(--studio-ease);
}
.btn:not(:disabled):active {
  transform: translateY(1px) scale(0.985);
  box-shadow: 1px 1px 0 var(--ink);
}
.btn.primary:not(:disabled):active {
  box-shadow: 1px 1px 0 var(--ink), inset 0 2px 5px rgb(42 36 32 / 0.18);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}
.chip {
  transition: transform 140ms var(--studio-ease), background-color 140ms var(--studio-ease), border-color 140ms var(--studio-ease);
}
@media (hover: hover) {
  .chip:hover {
    transform: translateY(-1px);
  }
}
.input,
.select,
.textarea {
  transition: border-color 150ms var(--studio-ease), box-shadow 150ms var(--studio-ease), background-color 150ms var(--studio-ease);
}
.field:focus-within > label {
  color: var(--text);
}

/* rows and recommendations respond to the pointer without lifting the page */
@media (hover: hover) {
  .list-item {
    transition: background-color 160ms var(--studio-ease), border-color 160ms var(--studio-ease), transform 160ms var(--studio-ease);
  }
  .list-item.flat:hover {
    background: color-mix(in srgb, var(--ll-sticky-yellow) 14%, var(--surface));
    border-color: var(--studio-hair-strong);
  }
  .suggest-item {
    transition: transform 160ms var(--studio-ease), box-shadow 160ms var(--studio-ease);
  }
  .suggest-item:hover {
    transform: translateX(3px);
    box-shadow: var(--shadow-sm);
  }
  .tree .leaf {
    transition: background-color 150ms var(--studio-ease);
  }
  .tree .leaf:hover {
    background: color-mix(in srgb, var(--ll-sticky-yellow) 16%, transparent);
  }
}

/* ------------------------------------------------------ 21.3 progress motion -- */
.bar > span,
.card-bar > span,
.pq-bar > span,
.xp-bar > span {
  transition: width 520ms var(--studio-ease), background-color 220ms var(--studio-ease);
}
@media (prefers-reduced-motion: no-preference) {
  .view.route-enter .bar > span,
  .view.route-enter .card-bar > span,
  .view.route-enter .pq-bar > span,
  .view.route-enter .xp-bar > span {
    transform-origin: left center;
    animation: studio-bar-grow 640ms var(--studio-ease) both;
  }
  .view.route-enter .metrics > * {
    animation: studio-rise 380ms var(--studio-ease) both;
  }
  .view.route-enter .metrics > *:nth-child(2) { animation-delay: 30ms; }
  .view.route-enter .metrics > *:nth-child(3) { animation-delay: 60ms; }
  .view.route-enter .metrics > *:nth-child(4) { animation-delay: 90ms; }
  .view.route-enter .metrics > *:nth-child(5) { animation-delay: 120ms; }
  .view.route-enter .metrics > *:nth-child(6) { animation-delay: 150ms; }
  .view.route-enter .metrics > *:nth-child(n + 7) { animation-delay: 175ms; }
}

/* -------------------------------------------------- 21.4 completion feedback -- */
@media (prefers-reduced-motion: no-preference) {
  .check input:checked + .box {
    animation: studio-tick 300ms var(--studio-ease-spring);
  }
  .check input:checked + .box::after {
    animation: studio-check-in 240ms var(--studio-ease-spring) both;
  }
  .streak-day.current .streak-day-flame {
    animation: studio-flame 1.9s ease-in-out infinite;
  }
}
.check .box,
.check .box::after {
  transition: opacity 160ms var(--studio-ease), transform 200ms var(--studio-ease-spring), background-color 150ms var(--studio-ease);
}
.check.done .label-text {
  transition: color 200ms var(--studio-ease);
}
.quest {
  transition: transform 160ms var(--studio-ease), box-shadow 160ms var(--studio-ease), background-color 200ms var(--studio-ease), border-color 200ms var(--studio-ease);
}
@media (hover: hover) {
  .quest:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
  }
}
.quest.done {
  border-color: color-mix(in srgb, var(--ok) 70%, var(--ink));
}
.quest.done .quest-ico {
  animation: none;
}

/* tabs keep the hand-drawn border but gain a sliding active rule */
.tabs .tab {
  position: relative;
}
.tabs .tab::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: -2px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 220ms var(--studio-ease);
  pointer-events: none;
}
.tabs .tab.active::after {
  transform: scaleX(1);
}

/* tables: a whisper of highlight so long lists stay trackable */
.table-wrap tbody tr {
  transition: background-color 140ms var(--studio-ease);
}
@media (hover: hover) {
  .table-wrap tbody tr:hover {
    background: color-mix(in srgb, var(--ll-sticky-yellow) 14%, transparent);
  }
}

/* timer face reads as a physical desk clock, not a plain box */
.timer-face {
  background:
    radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--ll-sticky-yellow) 24%, transparent), transparent 62%),
    var(--surface);
  border-radius: var(--r-sm);
}
.timer-clock {
  letter-spacing: -0.05em;
  text-shadow: 2px 2px 0 color-mix(in srgb, var(--ink) 12%, transparent);
}
.timer-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: var(--border-w-thin) solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
}
.timer-state::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}

/* answer feedback reads instantly, in both directions */
.review-detail {
  padding-left: 10px;
  border-left: 3px solid var(--studio-hair-strong);
}
.review-detail .chip.ok {
  box-shadow: 2px 2px 0 color-mix(in srgb, var(--ok) 60%, var(--ink));
}
.review-detail .chip.bad {
  box-shadow: 2px 2px 0 color-mix(in srgb, var(--bad) 60%, var(--ink));
}
.explain-box {
  border-left: 3px solid var(--info);
}

/* a calm, consistent keyboard ring everywhere */
:where(a, button, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* -------------------------------------------------- 21.5 Chotu's moment card -- */
.moment-root {
  position: fixed;
  left: calc(var(--sidebar-w, 0px) + 16px);
  bottom: max(44px, calc(env(safe-area-inset-bottom) + 36px));
  z-index: 88;
  width: min(380px, calc(100vw - 28px));
  pointer-events: none;
}
body:has(.app-shell.sidebar-collapsed) .moment-root {
  left: 72px;
}
.chotu-moment {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  pointer-events: none;
  animation: studio-moment-in 280ms var(--studio-ease-spring) both;
}
.chotu-moment-art {
  flex: 0 0 auto;
  transform: translateY(2px) rotate(-2deg);
  filter: drop-shadow(0 6px 7px rgb(42 36 32 / 0.2));
}
.chotu-moment-bubble {
  position: relative;
  pointer-events: auto;
  min-width: 0;
  padding: 8px 30px 10px 12px;
  background: var(--ll-sticky-yellow);
  color: var(--studio-ink-fixed);
  border: var(--border-w) solid var(--studio-ink-fixed);
  border-radius: var(--r-sm);
  box-shadow: 3px 3px 0 rgb(42 36 32 / 0.18);
  transform: rotate(-0.6deg);
}
.chotu-moment-bubble::before {
  content: "";
  position: absolute;
  left: -7px;
  bottom: 16px;
  width: 12px;
  height: 12px;
  background: inherit;
  border-left: var(--border-w) solid var(--studio-ink-fixed);
  border-bottom: var(--border-w) solid var(--studio-ink-fixed);
  transform: rotate(45deg);
}
.chotu-moment--cheer .chotu-moment-bubble,
.chotu-moment--milestone .chotu-moment-bubble,
.chotu-moment--welcome .chotu-moment-bubble {
  background: var(--ll-sticky-green);
}
.chotu-moment--focus .chotu-moment-bubble {
  background: var(--ll-sticky-blue);
}
.chotu-moment--encourage .chotu-moment-bubble,
.chotu-moment--oops .chotu-moment-bubble {
  background: var(--ll-sticky-orange);
}
.chotu-moment-name {
  display: block;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: rgb(42 36 32 / 0.62);
}
.chotu-moment-bubble p {
  margin: 1px 0 0;
  font-size: var(--fs-sm);
  line-height: 1.4;
  color: var(--studio-ink-fixed);
}
.chotu-moment-close {
  position: absolute;
  top: 3px;
  right: 3px;
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgb(42 36 32 / 0.58);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}
.chotu-moment-close:hover {
  background: rgb(42 36 32 / 0.12);
  color: var(--studio-ink-fixed);
}
.chotu-moment.is-leaving {
  animation: studio-moment-out 200ms var(--studio-ease) both;
}
.chotu-moment.is-quiet {
  animation: studio-fade-in 160ms linear both;
}

/* ------------------------------------------------------- 21.6 extra keyframes */
@keyframes studio-bar-grow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
@keyframes studio-tick {
  0% { transform: scale(1); }
  35% { transform: scale(0.86) rotate(-4deg); }
  70% { transform: scale(1.08) rotate(2deg); }
  100% { transform: scale(1); }
}
@keyframes studio-check-in {
  from { opacity: 0; transform: scale(0.3) rotate(-18deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}
@keyframes studio-moment-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
@keyframes studio-moment-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(8px) scale(0.98); }
}
@keyframes studio-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes studio-flame {
  0%, 100% { transform: rotate(-4deg) scale(1); }
  50% { transform: rotate(5deg) scale(1.12); }
}

/* ---------------------------------------------------------- 21.7 responsive -- */
@media (max-width: 720px) {
  .moment-root {
    left: 10px;
    bottom: max(78px, calc(env(safe-area-inset-bottom) + 70px));
    width: min(340px, calc(100vw - 20px));
  }
  .chotu-moment-art svg {
    width: 52px;
    height: 52px;
  }
}
@media (max-width: 420px) {
  .chotu-moment-bubble {
    font-size: var(--fs-xs);
  }
}

/* ------------------------------------------------ 21.8 reduced motion opt-out */
@media (prefers-reduced-motion: reduce) {
  .view.route-enter .bar > span,
  .view.route-enter .card-bar > span,
  .view.route-enter .pq-bar > span,
  .view.route-enter .xp-bar > span,
  .view.route-enter .metrics > *,
  .check input:checked + .box,
  .check input:checked + .box::after,
  .streak-day.current .streak-day-flame,
  .chotu-moment,
  .chotu-moment.is-leaving {
    animation: none !important;
  }
  .chotu-moment-art,
  .chotu-moment-bubble {
    transform: none !important;
  }
  .btn,
  .chip,
  .quest,
  .tile,
  .list-item,
  .suggest-item,
  .bar > span {
    transition: none !important;
  }
}

/* ==========================================================================
   22. Screen refinements — timer dial, revision next-step, sidebar level, boot.
   ========================================================================== */

/* ------------------------------------------------------------------ timer -- */
.timer-dial {
  --dial: 250px;
  width: min(var(--dial), 100%);
  aspect-ratio: 1;
  padding: 13px;
  border-radius: 50%;
  border: var(--border-w-thick) solid var(--ink);
  background:
    conic-gradient(var(--accent) calc(var(--p, 0) * 1%), var(--surface-3) 0);
  box-shadow: var(--shadow-lg);
  transition: box-shadow 220ms var(--studio-ease);
}
.timer-dial-inner {
  display: grid;
  place-items: center;
  gap: 3px;
  width: 100%;
  height: 100%;
  padding: 16px;
  border-radius: 50%;
  border: var(--border-w) solid var(--ink);
  background: var(--surface);
  text-align: center;
}
.timer-dial .timer-clock {
  font-size: clamp(30px, 3.4vw + 12px, 52px);
  text-shadow: none;
}
.timer-dial-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.timer-state.pulse {
  background: var(--ll-sticky-green);
  border-color: color-mix(in srgb, var(--ok) 55%, var(--ink));
}
@media (prefers-reduced-motion: no-preference) {
  .timer-state.pulse::before {
    animation: studio-flame 1.6s ease-in-out infinite;
  }
}

/* -------------------------------------------------------- revision start -- */
.revision-start {
  position: relative;
  overflow: hidden;
  background: color-mix(in srgb, var(--ll-sticky-green) 20%, var(--surface));
  border-color: color-mix(in srgb, var(--ok) 60%, var(--ink));
}
.revision-start::after {
  content: "";
  position: absolute;
  right: -34px;
  bottom: -46px;
  width: 140px;
  height: 140px;
  border: var(--border-dash);
  border-radius: 50%;
  opacity: 0.45;
  pointer-events: none;
}
.revision-start .eyebrow {
  color: color-mix(in srgb, var(--ok-ink) 55%, var(--muted));
}

/* ------------------------------------------------------------ sidebar level -- */
.sidebar-hint {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
}
.sidebar-level {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  font-size: var(--fs-xs);
  text-transform: none;
  letter-spacing: 0;
}
.sidebar-xp {
  position: relative;
  height: 7px;
  overflow: hidden;
  border: var(--border-w-thin) solid var(--line);
  border-radius: 999px;
  background: var(--surface-3);
}
.sidebar-xp > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-right: 1px solid var(--ink);
  transition: width 520ms var(--studio-ease);
}

/* ------------------------------------------------------------------- boot -- */
/* The first paint wears the exact same brand header as the sidebar, so the
   loading card and the app never look like two different products. */
.boot-card .boot-brand {
  position: relative;
  z-index: 1;
  padding: 0 0 2px;
  text-align: center;
}
.boot-card .boot-brand .sidebar-brand {
  font-size: clamp(1.9rem, 5vw, 2.5rem);
}
.boot-card .boot-brand .ink-brand {
  display: block;
  width: min(210px, 58vw);
  height: 12px;
  margin: 8px auto 0;
  color: var(--accent);
  opacity: 1;
}
.boot-card .boot-brand .brand-tagline {
  margin-top: 8px;
  font-size: 10px;
}

/* A desk-top of hand-drawn study objects. The symbols live in index.html so
   the first paint and the account gate share one set of ink drawings. */
.boot,
.account-gate {
  position: relative;
  overflow: hidden;
}
.boot {
  isolation: isolate;
}
.boot-card {
  z-index: 1;
}
.boot-doodle-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
.boot-doodles {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.boot-doodle {
  position: absolute;
  display: block;
  width: var(--size, 64px);
  color: var(--ink);
  opacity: var(--op, 0.5);
  transform: rotate(var(--r, 0deg));
  transform-origin: 50% 55%;
  filter: drop-shadow(0 3px 0 rgb(42 36 32 / 0.07));
}
.boot-doodle > svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.doodle-book {
  top: 9%;
  left: 7%;
  --size: 88px;
  --r: -10deg;
  --d: -1.2s;
  --dur: 8s;
  --op: 0.62;
  color: var(--accent);
}
.doodle-pencil {
  top: 15%;
  right: 9%;
  --size: 72px;
  --r: 18deg;
  --d: -3s;
  --dur: 7.5s;
  --op: 0.48;
}
.doodle-notebook {
  bottom: 12%;
  left: 9%;
  --size: 86px;
  --r: 7deg;
  --d: -2s;
  --dur: 9s;
  --op: 0.48;
}
.doodle-sticky {
  bottom: 17%;
  right: 11%;
  --size: 74px;
  --r: -14deg;
  --d: -4s;
  --dur: 8.5s;
  --op: 0.6;
  color: var(--studio-ink-fixed, #2a2420);
}
.doodle-ruler {
  bottom: 6%;
  left: 43%;
  --size: 106px;
  --r: -5deg;
  --d: -1.6s;
  --dur: 8.8s;
  --op: 0.56;
}
.doodle-clip {
  top: 7%;
  left: 39%;
  --size: 44px;
  --r: 20deg;
  --d: -2.6s;
  --dur: 7s;
  --op: 0.55;
  color: var(--muted);
}
.doodle-calc {
  top: 44%;
  right: 4%;
  --size: 64px;
  --r: 6deg;
  --d: -3.4s;
  --dur: 9.2s;
  --op: 0.46;
}
.doodle-bulb {
  top: 8%;
  right: 29%;
  --size: 56px;
  --r: -10deg;
  --d: -0.8s;
  --dur: 7.8s;
  --op: 0.62;
  color: var(--accent);
}
.doodle-books {
  bottom: 8%;
  right: 34%;
  --size: 82px;
  --r: 8deg;
  --d: -5s;
  --dur: 9.4s;
  --op: 0.58;
}

@media (prefers-reduced-motion: no-preference) {
  .boot-doodle > svg {
    animation: boot-doodle-float var(--dur, 7s) ease-in-out var(--d, 0s) infinite;
  }
}
@media (prefers-reduced-motion: reduce) {
  .boot-doodle > svg {
    animation: none;
  }
}
[data-reduce-motion="true"] .boot-doodle > svg {
  animation: none;
}
@keyframes boot-doodle-float {
  0%,
  100% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  33% {
    transform: translate3d(2px, -8px, 0) rotate(1.6deg);
  }
  66% {
    transform: translate3d(-2px, -4px, 0) rotate(-1.2deg);
  }
}

@media (max-width: 640px) {
  .boot-doodle {
    --op: 0.34;
  }
  .doodle-book {
    top: 6%;
    left: 3%;
    --size: 62px;
  }
  .doodle-pencil {
    top: 11%;
    right: 4%;
    --size: 50px;
  }
  .doodle-notebook {
    bottom: 7%;
    left: 4%;
    --size: 58px;
  }
  .doodle-sticky {
    bottom: 10%;
    right: 4%;
    --size: 52px;
  }
  .doodle-bulb {
    top: 4%;
    right: 24%;
    --size: 40px;
  }
  .doodle-ruler,
  .doodle-clip,
  .doodle-calc,
  .doodle-books {
    display: none;
  }
}

/* ---------------------------------------------- 23. small aliveness details -- */
@media (prefers-reduced-motion: no-preference) {
  .toast.ok .toast-ico {
    animation: studio-tick 420ms var(--studio-ease-spring);
  }
  .avatar-dot {
    animation: studio-flame 2.6s ease-in-out infinite;
  }
}
@media (hover: hover) {
  .topbar-streak {
    transition: transform 160ms var(--studio-ease), box-shadow 160ms var(--studio-ease);
  }
  .topbar-streak:hover {
    transform: translateY(-1px) rotate(-1deg);
    box-shadow: var(--shadow-sm);
  }
}
.sidebar-cta {
  transition: transform 160ms var(--studio-ease), box-shadow 160ms var(--studio-ease), background-color 160ms var(--studio-ease);
}
.sidebar-cta:active {
  transform: translateY(1px);
}

/* --------------------------------------------------------- syllabus next -- */
.syllabus-next {
  position: relative;
  overflow: hidden;
  background: color-mix(in srgb, var(--ll-sticky-blue) 20%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 45%, var(--ink));
}
.syllabus-next::after {
  content: "";
  position: absolute;
  right: -30px;
  top: -44px;
  width: 130px;
  height: 130px;
  border: var(--border-dash);
  border-radius: 50%;
  opacity: 0.4;
  pointer-events: none;
}

/* Metric rows that don't divide by four still read as one band. */
@media (min-width: 1100px) {
  .metrics:has(> :nth-child(3):last-child) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .metrics:has(> :nth-child(5):last-child) {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .metrics:has(> :nth-child(6):last-child) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ------------------------------------------------- 24. pointer & heat details -- */
.chotu-moment-close {
  width: 24px;
  height: 24px;
  font-size: 12px;
}
@media (hover: hover) {
  .cal-cell {
    transition: transform 150ms var(--studio-ease), box-shadow 150ms var(--studio-ease);
  }
  .cal-cell:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
  }
  .hm-cell {
    transition: transform 120ms var(--studio-ease);
  }
  .hm-cell:hover {
    transform: scale(1.35);
    position: relative;
    z-index: 2;
  }
  details.disclosure > summary:hover {
    color: var(--text);
  }
}
.timer-face:has(.timer-state.pulse) .timer-dial {
  box-shadow: var(--shadow-lg), 0 0 0 4px color-mix(in srgb, var(--ok) 22%, transparent);
}
@media (max-width: 560px) {
  .empty-mascot {
    width: 78px;
    height: 78px;
  }
  .timer-dial {
    --dial: 216px;
  }
}

/* ------------------------------------------------- 25. reading & hit targets -- */
.view h2,
.view h3 {
  text-wrap: balance;
}
.view p,
.view li {
  text-wrap: pretty;
}
/* The close control is visually 24px; this extends its touch target to 44px. */
.chotu-moment-close::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
}
