/* UltraHosting — shared styles */

:root {
  --paper: #faf7f2;
  --paper-2: #f1ece3;
  --ink: #211e1a;
  --ink-soft: #5c564d;
  --line: #ddd5c8;
  --accent: #c0533e;
  --accent-ink: #ffffff;
  --card: #ffffff;
  --good: #2e7d4f;
  --shadow: 0 1px 3px rgba(33, 30, 26, 0.08), 0 6px 20px rgba(33, 30, 26, 0.06);
  --radius: 10px;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #191713;
    --paper-2: #211e19;
    --ink: #e9e4da;
    --ink-soft: #a89f92;
    --line: #383329;
    --accent: #d96a54;
    --accent-ink: #1c1a16;
    --card: #232019;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.2;
  margin: 0 0 0.5em;
  font-weight: 600;
}

h1 { font-size: 2.4rem; letter-spacing: -0.01em; }
h2 { font-size: 1.6rem; margin-top: 2em; }
h3 { font-size: 1.2rem; margin-top: 1.5em; }

p { margin: 0 0 1em; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

.wrap { max-width: 62rem; margin: 0 auto; padding: 0 1.25rem; }
.wrap-narrow { max-width: 46rem; margin: 0 auto; padding: 0 1.25rem; }

/* Header */
.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header .bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.7rem 1.25rem;
  max-width: 62rem;
  margin: 0 auto;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.brand .ultra { color: var(--accent); }

/* Main menu (tabs) over submenu (pills): the active tab shares the shaded
   strip below it, so the pills read as living inside the selected tab. */
.nav-tabbed { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; flex: 1; }
.nav-tabs { display: flex; gap: 0.15rem; align-items: flex-end; flex: 0 0 auto; }
.nav-tab {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 0.25rem 0.85rem;
  border-radius: 8px 8px 0 0;
}
.nav-tab:hover { color: var(--ink); }
.nav-tab.active { background: var(--paper-2); color: var(--ink); }
.site-nav { display: flex; gap: 0.2rem; flex-wrap: wrap; min-width: 0; }
.site-nav.active { background: var(--paper-2); border-radius: 0 8px 8px 8px; padding: 0.25rem 0.5rem; }
.site-nav:not(.active) { display: none; }

.site-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.88rem;
}

.site-nav a:hover { background: var(--paper-2); color: var(--ink); }
.site-nav a.active { background: var(--ink); color: var(--paper); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 4rem;
  padding: 2rem 0 3rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* Hero */
.hero { padding: 3.5rem 0 1rem; }
.hero .kicker {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 0.75rem;
}
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); max-width: 24ch; }
.hero .lede { font-size: 1.2rem; color: var(--ink-soft); max-width: 56ch; }

/* Cards */
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(16rem, 100%), 1fr)); margin: 1.5rem 0; }
.grid-wide { grid-template-columns: repeat(auto-fill, minmax(min(20rem, 100%), 1fr)); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}

.card h3 { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }

a.card { text-decoration: none; color: inherit; display: block; transition: transform 0.12s ease, border-color 0.12s ease; }
a.card:hover { transform: translateY(-2px); border-color: var(--accent); }

.card .tag {
  display: inline-block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.card .meta { color: var(--ink-soft); font-size: 0.92rem; }

/* Palette move cards */
.move-card { border-top: 4px solid var(--move-color, var(--accent)); }
.move-card .stems { margin: 0.6rem 0 0; padding-left: 1.1rem; color: var(--ink-soft); font-size: 0.95rem; }
.move-card .stems li { margin-bottom: 0.3rem; font-style: italic; }

.chip {
  display: inline-block;
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--paper-2);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

.chip.move { color: #fff; border: none; background: var(--move-color, var(--accent)); }

button.chip { cursor: pointer; font: inherit; font-size: 0.85rem; font-weight: 600; padding: 0.3rem 0.8rem; }
button.chip:not(.move):hover { border-color: var(--accent); }
.focus-chips, .group-tabs { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.75rem 0 0.5rem; }
@media (prefers-color-scheme: dark) {
  .chip.move { color: #fff; }
}

/* Tables */
table { width: 100%; border-collapse: collapse; margin: 1rem 0 2rem; font-size: 0.96rem; }
.table-scroll { overflow-x: auto; }
th, td { text-align: left; padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); }
td em { color: var(--ink-soft); }

/* Buttons */
.btn {
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.big { font-size: 1.15rem; padding: 0.7rem 1.6rem; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin: 1rem 0; }

/* Forms */
input[type="text"], input[type="number"], textarea, select {
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  width: 100%;
}
textarea { min-height: 5.5rem; resize: vertical; }
label { font-weight: 600; font-size: 0.92rem; display: block; margin: 0.9rem 0 0.3rem; }
.field-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.field-row > div { flex: 1; min-width: 8rem; }

/* Drill stage */
.stage {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1.5rem;
  margin: 1.5rem 0;
  min-height: 20rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stage .prompt {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 2.8vw, 1.9rem);
  line-height: 1.35;
  flex: 1;
}

.stage .prompt .sub { font-family: var(--font-body); font-size: 1rem; color: var(--ink-soft); margin-top: 0.8rem; }

.stage .round-label { font-size: 0.85rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; }

.timebar { height: 8px; border-radius: 999px; background: var(--paper-2); overflow: hidden; }
.timebar .fill { height: 100%; background: var(--accent); border-radius: 999px; width: 100%; }

.reveal {
  border-left: 3px solid var(--good);
  padding: 0.5rem 1rem;
  background: var(--paper-2);
  border-radius: 0 8px 8px 0;
  font-size: 0.98rem;
}

.reveal.hintbox { border-left-color: var(--ink-soft); font-size: 0.92rem; }

.reflection { max-width: 40rem; }

.done-check { color: var(--good); font-weight: 700; }

/* Big deal cards (Palette Draw) */
.deal-row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr)); margin: 1.5rem 0; }
.deal-card {
  border-radius: var(--radius);
  padding: 1.3rem 1.2rem 1.1rem;
  color: #fff;
  background: var(--move-color, var(--accent));
  box-shadow: var(--shadow);
  min-height: 11rem;
  display: flex;
  flex-direction: column;
}
.deal-card h3 { color: #fff; margin: 0 0 0.4rem; }
.deal-card p { font-size: 0.92rem; margin: 0 0 0.6rem; opacity: 0.94; }
.deal-card .stem { font-style: italic; font-size: 0.9rem; opacity: 0.88; margin-top: auto; }
.deal-card.used { outline: 3px solid var(--ink); outline-offset: 2px; }

/* Timer tool */
.timer-total {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 7vw, 4rem);
  font-variant-numeric: tabular-nums;
  text-align: center;
  margin: 0.5rem 0;
}

.person-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  margin-bottom: 0.6rem;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}
.person-row.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.person-row .name { font-weight: 700; flex: 0 1 7rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-row .hotkey {
  flex: 0 0 auto;
  min-width: 1.3rem;
  text-align: center;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.05rem 0.25rem;
}
.person-row .clock { font-variant-numeric: tabular-nums; font-size: 1.2rem; min-width: 5.2rem; }
.person-row .share-track { flex: 1; height: 10px; border-radius: 999px; background: var(--paper-2); overflow: hidden; }
.person-row .share-fill { height: 100%; background: var(--accent); border-radius: 999px; width: 0; transition: width 0.3s linear; }
.person-row .pct { min-width: 3.2rem; text-align: right; color: var(--ink-soft); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.person-row .remove { background: none; border: none; color: var(--ink-soft); cursor: pointer; font-size: 1.1rem; padding: 0.2rem; }
.person-row .remove:hover { color: var(--accent); }
.person-row.over .share-fill { background: var(--move-color, #b3261e); }

/* Silence ring */
.ring-wrap { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 1rem 0; }
.ring { transform: rotate(-90deg); }
.ring .track { stroke: var(--paper-2); }
.ring .arc { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 0.1s linear; }
.ring-label {
  font-family: var(--font-display);
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
}

/* Learn pages */
.learn-body h2 { border-bottom: 1px solid var(--line); padding-bottom: 0.3rem; }
.standard {
  border-left: 3px solid var(--accent);
  padding: 0.7rem 1.1rem;
  background: var(--paper-2);
  border-radius: 0 8px 8px 0;
  font-family: var(--font-display);
  font-size: 1.08rem;
  margin: 1.5rem 0;
}
.crosslink { font-size: 0.92rem; color: var(--ink-soft); }

/* Utility */
.muted { color: var(--ink-soft); }
.small { font-size: 0.9rem; }
.mt-0 { margin-top: 0; }
.center { text-align: center; }
hr { border: none; border-top: 1px solid var(--line); margin: 2.5rem 0; }

details { border: 1px solid var(--line); border-radius: 8px; padding: 0.6rem 1rem; margin: 0.6rem 0; background: var(--card); }
details summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: 0.5rem; }

details.fold { padding: 0.8rem 1.2rem; box-shadow: var(--shadow); }
details.fold > summary { font-family: var(--font-display); font-size: 1.15rem; }

.flash { animation: bt-flash 0.4s steps(2) 8; }
@keyframes bt-flash { 50% { color: var(--accent); } }

.notice {
  padding: 0.6rem 1rem;
  border-radius: 8px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  font-size: 0.95rem;
}
.notice.ok { border-color: var(--good); }

@media (max-width: 40rem) {
  .person-row .name { flex-basis: 5rem; }
  .person-row .pct { display: none; }
  .btn { padding: 0.45rem 0.85rem; font-size: 0.98rem; }
  .btn-row { gap: 0.5rem; }
}

/* Touch ergonomics: denser desktop targets grow on coarse pointers. */
@media (pointer: coarse) {
  button.chip { min-height: 2.75rem; padding: 0.45rem 0.9rem; }
  .btn { min-height: 2.75rem; }
  .person-row .remove { padding: 0.7rem 1.05rem; margin: -0.7rem -0.65rem; font-size: 1.2rem; }
}

/* Phone header: brand on its own line, nav as one horizontally scrollable row. */
@media (max-width: 48rem) {
  .site-header .bar { display: block; padding: 0.55rem 0 0; }
  .site-header .brand { display: block; padding: 0 1.25rem 0.15rem; }
  .nav-search { position: absolute; top: calc(0.45rem + env(safe-area-inset-top)); right: 1rem; }
  .nav-help { position: absolute; top: calc(0.45rem + env(safe-area-inset-top)); right: 1rem; }
  .nav-search { right: 3.6rem; }
  .nav-dash { position: absolute; top: calc(0.45rem + env(safe-area-inset-top)); right: 6.2rem; margin-left: 0; }
  .nav-tabbed { display: block; }
  .nav-tabs { padding: 0 1.25rem; }
  .site-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0.25rem 1.25rem;
  }
  .site-nav.active { border-radius: 0; margin-bottom: 0; }
  .nav-tabbed { padding-bottom: 0; }
  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav a { flex: 0 0 auto; white-space: nowrap; }
}

/* Safe areas for notched phones in standalone (PWA) mode. */
.site-header {
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
.site-footer { padding-bottom: calc(3rem + env(safe-area-inset-bottom)); }

/* Deep-linked move card highlight */
.move-card.spotlit {
  outline: 3px solid var(--move-color, var(--accent));
  outline-offset: 3px;
  animation: spotlit-fade 2.4s ease forwards;
}
@keyframes spotlit-fade {
  0%, 60% { outline-color: var(--move-color, var(--accent)); }
  100% { outline-color: transparent; }
}

/* Dashboard: an open tool docks right of the move cards on wide screens. */
@media (min-width: 64rem) {
  #db-body.docked { display: grid; grid-template-columns: minmax(0, 1fr) 26rem; gap: 1.5rem; align-items: start; }
  #db-body.docked #db-side { position: sticky; top: 4.5rem; margin-top: 1.5rem; }
}

/* Palette tree */
.tree-group {
  border-left: 4px solid var(--move-color, var(--line));
  margin: 0.7rem 0;
  padding: 0.7rem 1rem;
}
.tree-group > summary { display: flex; align-items: baseline; gap: 0.7rem; flex-wrap: wrap; }
.tree-trained { margin: 0.5rem 0 0.3rem; }
.tree-move {
  border: none;
  border-left: 2px solid var(--line);
  border-radius: 0;
  background: none;
  margin: 0.15rem 0 0.15rem 0.4rem;
  padding: 0.35rem 0.9rem;
}
.tree-move > summary strong { color: var(--move-color, inherit); }
.tree-move .stems { margin: 0.4rem 0 0.2rem; padding-left: 1.2rem; color: var(--ink-soft); font-size: 0.95rem; }
.tree-move .stems li { margin-bottom: 0.25rem; font-style: italic; }
.tree-move.spotlight { animation: spotlight 0.8s ease 3; }
@keyframes spotlight { 50% { background: var(--paper-2); border-left-color: var(--move-color); } }
.spotlight-row { animation: spotlight-row 0.8s ease 3; }
@keyframes spotlight-row { 50% { background: var(--paper-2); } }
@media (pointer: coarse) {
  .tree-group > summary, .tree-move > summary { min-height: 2.5rem; }
}

/* Send to phone: a quiet transfer row, visually apart from the tool panels. */
.handoff-row { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin: 0.9rem 0 0; }

/* Dashboard screen-use toggle: moves / both / tools. */
.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.view-toggle button {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.35rem 0.95rem;
  background: var(--card);
  border: none;
  cursor: pointer;
  color: var(--ink-soft);
}
.view-toggle button + button { border-left: 1px solid var(--line); }
.view-toggle button.active { background: var(--ink); color: var(--paper); }
#db-body.view-moves #db-side { display: none; }
#db-body.view-tools #db-main { display: none; }
#db-body.view-moves.docked, #db-body.view-tools.docked { display: block; }
#db-body.view-tools #db-side { position: static; }
.handoff-toggle {
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink-soft);
  background: none;
  border: 1.5px dashed var(--line);
  border-radius: 999px;
  padding: 0.35rem 1rem;
  cursor: pointer;
}
.handoff-toggle:hover { color: var(--accent); border-color: var(--accent); }
.handoff-panel {
  border: 1.5px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--paper-2);
  padding: 1rem 1.2rem;
  margin-top: 0.6rem;
}
.handoff-panel textarea { background: var(--card); }

/* Quick search overlay */
.nav-search, .nav-dash, .nav-help {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  width: 2.1rem;
  height: 2.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  padding: 0;
  color: var(--ink-soft);
}
.nav-dash { margin-left: auto; }
.nav-help { font-weight: 700; }
.nav-search:hover, .nav-dash:hover, .nav-help:hover { background: var(--paper-2); color: var(--ink); }

/* Tool + help overlays (hotkeys; Esc dismisses) */
.overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 17, 12, 0.45);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 1rem 1rem;
}
.overlay-panel {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(20, 17, 12, 0.35);
  width: 100%;
  max-width: 36rem;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
}
.overlay-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.overlay-close {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  color: var(--ink-soft);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}
.overlay-close:hover { background: var(--paper-2); color: var(--ink); }
.overlay-body { padding: 1rem 1.1rem; overflow-y: auto; }
.overlay-body kbd {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
  font-family: inherit;
  font-size: 0.85em;
}

/* Phone thumb button for the dashboard; hidden on wide screens. */
.dash-fab {
  display: none;
  position: fixed;
  right: 1rem;
  bottom: calc(1.1rem + env(safe-area-inset-bottom));
  z-index: 40;
  width: 3rem;
  height: 3rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(20, 17, 12, 0.25);
}
@media (max-width: 48rem) {
  .dash-fab { display: flex; }
}

.search-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 17, 12, 0.45);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 10vh 1rem 0;
}
.search-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 34rem;
  padding: 0.9rem;
}
.search-results { max-height: 50vh; overflow-y: auto; margin-top: 0.5rem; }
.search-result {
  display: block;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
}
.search-result span { display: block; }
.search-result.sel, .search-result:hover { background: var(--paper-2); }

/* Print: a paper crib sheet — cards and content only. */
@media print {
  .site-header, .site-footer, .btn, .btn-row, button, input, select, textarea, label,
  .focus-chips, .group-tabs, .notice, .timebar, details.fold, .dash-fab,
  #db-tools, #db-tool-panel, #home-stats { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .hero { padding: 0 0 0.5rem; }
  .hero .lede, .kicker { display: none; }
  .card, .stage, .deal-card { box-shadow: none; border: 1px solid #888; break-inside: avoid; background: #fff; color: #000; }
  .card h3, .deal-card h3 { color: #000; }
  .move-card { border-top-width: 6px; }
  .chip, .chip.move { background: #fff !important; color: #000 !important; border: 1px solid #888 !important; }
  a { color: #000; text-decoration: none; }
  .grid, .grid-wide { grid-template-columns: repeat(2, 1fr); }
}
