/* Day 4: Find the five lines that change the result.
   Art direction: the desk at night, two sheets of paper, a thread of light,
   and the real drawer. Gold is a thread, a pin and a drawer line, never a
   panel. Values are read from values/house.css. */

.hp-d4 {
  --d4-night: #05090f;
  --d4-deep: #071016;
  --d4-ink: var(--house-color-text-ink, #e9edf2);
  --d4-ink-2: var(--house-color-text-secondary, rgba(233, 237, 242, 0.76));
  --d4-ink-3: var(--house-color-text-tertiary, rgba(233, 237, 242, 0.56));
  --d4-gold: var(--house-color-gold-hi, #f3d9a0);
  --d4-gold-light: var(--house-color-gold-light, #fff3d6);
  --d4-gold-deep: var(--house-color-gold-deep, #b08a45);
  --d4-ice: var(--house-color-scene-ice, #8fcfff);
  --d4-pond: var(--house-color-scene-pond, #3fd0d9);
  --d4-paper-loose: #e9dfcc;
  --d4-paper-tight: #f8f3e8;
  --d4-paper-ink: #16101e;
  --d4-loose-ink: #3b3428;
  --d4-serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --d4-ease: var(--house-motion-easing-standard, cubic-bezier(0.2, 0.6, 0.2, 1));
  --d4-silk: var(--house-motion-easing-silk, cubic-bezier(0.25, 1, 0.5, 1));
  --d4-grace: var(--house-motion-easing-grace, cubic-bezier(0.65, 0, 0.35, 1));
  --d4-r: var(--house-radius-l, 20px);
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  isolation: isolate;
  overflow-x: clip;
  color: var(--d4-ink);
  font-family: var(--house-type-family-body, Inter, system-ui, sans-serif);
  background: var(--d4-night);
}

.hp-d4 * { box-sizing: border-box; }
.hp-d4 [hidden] { display: none !important; }
.hp-d4 .d4-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---- the House window, behind the ?window=1 flag --------------------------------------- */

#d4-window {
  position: relative;
  z-index: 2;
  width: min(100%, 1080px);
  margin: 0 auto;
  padding: 12px var(--house-space-gutter, 20px) 0;
}
#d4-window[hidden] { display: none; }
#d4-window house-window {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
}
#d4-window house-window .hw-stage { height: 100%; }
#d4-window house-window[data-hw-mode="live"] .hw-stage,
#d4-window house-window[data-hw-mode="slow"] .hw-stage { background: transparent; }

/* ---- night, window, drawer glow --------------------------------------------------------- */

.d4-sky {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(80% 60% at 4% 30%, rgba(63, 208, 217, 0.34) 0%, rgba(31, 140, 150, 0.16) 40%, transparent 68%),
    radial-gradient(90% 60% at 70% 106%, rgba(243, 217, 160, 0.3) 0%, rgba(176, 138, 69, 0.12) 40%, transparent 70%),
    linear-gradient(180deg, #03070c 0%, #071016 42%, #0a1a22 78%, #0b2028 100%);
}

.d4-window {
  position: absolute;
  left: -8%;
  top: 18%;
  width: 42vw;
  height: 46vh;
  border-radius: 40% 60% 50% 50%;
  background: radial-gradient(circle at 40% 40%, rgba(143, 207, 255, 0.42) 0%, rgba(63, 208, 217, 0.28) 34%, transparent 66%);
  filter: blur(30px);
  animation: d4-breathe 20s ease-in-out infinite alternate;
}
.d4-drawerglow {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -10%;
  height: 40%;
  background: radial-gradient(60% 70% at 50% 100%, rgba(243, 217, 160, 0.4) 0%, rgba(176, 138, 69, 0.14) 46%, transparent 74%);
  filter: blur(30px);
  animation: d4-breathe 16s ease-in-out infinite alternate;
}
.d4-spool {
  position: absolute;
  right: 9%;
  top: 13%;
  width: 76px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: none;
  background: radial-gradient(circle at 38% 32%, #172a30 0%, #0a1418 62%, #060d11 100%);
  border: 1px solid rgba(243, 217, 160, 0.55);
  box-shadow: inset 0 0 0 9px rgba(243, 217, 160, 0.08), 0 0 40px -12px rgba(243, 217, 160, 0.45);
}
.d4-spool::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 1px solid rgba(243, 217, 160, 0.42);
  box-shadow: inset 0 0 0 5px rgba(243, 217, 160, 0.07), 0 0 0 5px rgba(243, 217, 160, 0.07);
}
.d4-spool::after {
  content: "";
  position: absolute;
  left: -4px;
  top: 58px;
  width: 88px;
  height: 130px;
  border-left: 1px solid rgba(243, 217, 160, 0.42);
  border-bottom: 1px solid rgba(243, 217, 160, 0.42);
  border-bottom-left-radius: 70px;
  transform: rotate(14deg);
  transform-origin: top left;
}
@media (min-width: 720px) { .d4-spool { display: block; } }

.d4-motes { position: absolute; inset: 0; }
.d4-mote {
  position: absolute;
  width: var(--s, 2px);
  height: var(--s, 2px);
  margin: calc(var(--s, 2px) / -2);
  border-radius: 50%;
  background: #fff;
  opacity: var(--o, 0.3);
  box-shadow: 0 0 6px rgba(255, 243, 214, 0.5);
  animation: d4-drift var(--d, 18s) ease-in-out infinite alternate;
}

/* ---- top, head, foot ------------------------------------------------------------------- */

.d4-top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px var(--house-space-gutter, 20px) 0;
  min-height: 44px;
}
.d4-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--d4-ink-2);
  text-decoration: none;
  font-size: 13.5px;
}
.d4-back:hover { color: var(--d4-gold-light); }
.d4-back-arrow { font-size: 17px; line-height: 1; color: var(--d4-gold); }
.d4-back-quiet { pointer-events: none; }
.d4-kicker {
  margin: 0;
  font-size: 10.5px;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--d4-gold);
  text-align: right;
}

.d4-main {
  position: relative;
  z-index: 1;
  width: min(100%, 1080px);
  margin: 0 auto;
  padding: 10px var(--house-space-gutter, 20px) 40px;
  flex: 1;
}
.d4-head { margin: 4px 0 10px; max-width: 760px; }
.d4-eyebrow {
  display: block;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--d4-gold-deep);
  margin-bottom: 10px;
}
.d4-title {
  margin: 0;
  font-family: var(--house-type-family-display, Satoshi, Inter, system-ui, sans-serif);
  font-weight: 700;
  font-size: clamp(30px, 7.6vw, 54px);
  line-height: 1.03;
  letter-spacing: -0.028em;
  color: var(--house-color-text-strong, #fff);
  text-wrap: balance;
}
.d4-sub {
  margin: 8px 0 0;
  max-width: 38ch;
  font-size: 15.5px;
  line-height: 1.45;
  color: var(--d4-ink-2);
}
.d4-head-layer { margin: 0 0 14px; }
.d4-head-layer .d4-title { font-size: clamp(26px, 6vw, 40px); }
.d4-foot {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  padding: 0 var(--house-space-gutter, 20px) 22px;
  font-size: 11.5px;
  color: var(--d4-ink-3);
}

/* ---- console --------------------------------------------------------------------------- */

.d4-console {
  position: relative;
  z-index: 3;
  min-height: 170px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background:
    radial-gradient(120% 90% at 90% 0%, rgba(243, 217, 160, 0.08) 0%, transparent 56%),
    linear-gradient(180deg, rgba(12, 30, 40, 0.78), rgba(5, 14, 20, 0.9));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 24px 60px -50px rgba(0, 0, 0, 0.9);
}
.d4-intro-line {
  margin: 0 0 10px;
  max-width: 46ch;
  font-size: 15px;
  line-height: 1.45;
  color: var(--d4-ink-2);
}
.d4-intro-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.d4-hint {
  margin: 8px 0 0;
  max-width: 48ch;
  font-size: 11px;
  line-height: 1.4;
  color: var(--d4-ink-3);
}

.d4-console-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.d4-progress {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--d4-ink-3);
}
.d4-lights { display: flex; gap: 6px; }
.d4-light {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  transition: background 300ms var(--d4-ease), box-shadow 300ms var(--d4-ease);
}
.d4-light[data-state="lit"] { background: var(--d4-gold); box-shadow: 0 0 10px rgba(243, 217, 160, 0.9); }
.d4-light[data-state="now"] { background: var(--d4-ice); box-shadow: 0 0 10px rgba(143, 207, 255, 0.8); animation: d4-pulse 2.2s ease-in-out infinite; }
.d4-status {
  min-height: 40px;
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--d4-ink-2);
}
.d4-status[data-tone="good"] { color: var(--house-color-state-ok, #8fd9b0); }
.d4-status[data-tone="wait"] { color: var(--house-color-state-wait, #bfe3ff); }
.d4-hintbtn { margin-top: 2px; min-height: 40px; padding: 8px 16px; font-size: 12px; }
.d4-legend { margin: 8px 0 0; font-size: 10.5px; line-height: 1.4; color: var(--d4-ink-3); }

/* ---- desk and sheets ------------------------------------------------------------------- */

.d4-stage { position: relative; }
.d4-desk {
  position: relative;
  margin-top: 14px;
  padding: 16px 12px 0;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(80% 60% at 90% 0%, rgba(243, 217, 160, 0.08) 0%, transparent 56%),
    radial-gradient(70% 60% at 0% 100%, rgba(0, 63, 70, 0.18) 0%, transparent 62%),
    repeating-linear-gradient(92deg, rgba(255, 255, 255, 0.012) 0 2px, transparent 2px 7px),
    linear-gradient(180deg, #0a141a 0%, #081016 58%, #060b10 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 40px 90px -60px rgba(0, 0, 0, 0.95);
}
.d4-filament {
  position: absolute;
  left: 4%;
  right: 30%;
  top: 26px;
  height: 34px;
  border-top: 1px solid rgba(243, 217, 160, 0.28);
  border-radius: 50%;
  transform: rotate(-1.6deg);
  opacity: 0.7;
  pointer-events: none;
}
.d4-nav {
  position: sticky;
  top: 8px;
  z-index: 6;
  display: flex;
  gap: 6px;
  margin: 0 0 12px;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(5, 14, 20, 0.88);
  backdrop-filter: blur(10px);
}
.d4-nav-btn {
  flex: 1;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--d4-ink-2);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.d4-nav-btn:hover, .d4-nav-btn:focus-visible { color: var(--d4-gold-light); border-color: rgba(243, 217, 160, 0.4); }
.d4-sheet { scroll-margin-top: 72px; }
.d4-sheets { position: relative; z-index: 1; display: grid; gap: 14px; }

.d4-sheet {
  position: relative;
  padding: 14px 14px 8px;
  border-radius: 10px;
  color: var(--d4-paper-ink);
  box-shadow: 0 24px 44px -28px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.18);
  transition: transform 800ms var(--d4-grace), opacity 800ms var(--d4-grace), box-shadow 800ms var(--d4-grace);
}
.d4-sheet-left {
  background:
    linear-gradient(100deg, rgba(255, 255, 255, 0.24) 0%, transparent 30%),
    linear-gradient(168deg, #e6d6b8 0%, #d2c19f 100%);
  transform: rotate(-0.6deg);
}
.d4-sheet-right {
  background:
    linear-gradient(100deg, rgba(255, 255, 255, 0.45) 0%, transparent 32%),
    linear-gradient(168deg, #faf3e1 0%, #eadfc7 100%);
  transform: rotate(0.4deg);
}
.d4-sheet-head {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(22, 16, 30, 0.14);
}
.d4-pin {
  width: 9px;
  height: 9px;
  margin-top: 5px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #fff8e6, #d9b46a 70%, #8f6d31);
  box-shadow: 0 0 10px rgba(243, 217, 160, 0.6);
  flex: none;
}
.d4-sheet-left .d4-pin { opacity: 0.7; }
.d4-sheet-titles { min-width: 0; }
.d4-sheet-title {
  margin: 0;
  font-family: var(--house-type-family-display, Satoshi, Inter, system-ui, sans-serif);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.d4-sheet-sub {
  margin: 3px 0 0;
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(22, 16, 30, 0.55);
}
.d4-lines { list-style: none; margin: 0; padding: 0; }
.d4-line {
  position: relative;
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 9px 26px 9px 0;
  border: 0;
  border-bottom: 1px dashed rgba(22, 16, 30, 0.2);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 220ms var(--d4-ease), background 220ms var(--d4-ease), border-color 220ms var(--d4-ease);
}
.d4-sheet-right .d4-line { border-bottom-style: solid; border-bottom-color: rgba(22, 16, 30, 0.13); }
.d4-line:last-child { border-bottom: 0; }
.d4-line:hover { background: rgba(184, 134, 47, 0.07); transform: translateY(-1px); }
.d4-line:active { transform: translateY(1px); }
.d4-line:disabled { cursor: default; opacity: 0.78; }
.d4-line:disabled:hover { background: transparent; transform: none; }
.d4-line-key {
  display: block;
  font-family: var(--house-type-family-body, Inter, system-ui, sans-serif);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(122, 90, 28, 0.9);
  margin-bottom: 2px;
}
.d4-line-text {
  display: block;
  font-family: var(--d4-serif);
  font-size: 14.5px;
  line-height: 1.42;
}
.d4-sheet-left .d4-line-text { color: var(--d4-loose-ink); }
.d4-line-pin {
  position: absolute;
  right: 2px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-radius: 50%;
  border: 1px solid rgba(122, 90, 28, 0.5);
  opacity: 0.4;
  transition: background 300ms var(--d4-ease), box-shadow 300ms var(--d4-ease), opacity 300ms var(--d4-ease);
}
.d4-line.is-found {
  background: rgba(243, 217, 160, 0.18);
  border-bottom-color: rgba(184, 134, 47, 0.7);
}
.d4-line.is-found .d4-line-pin {
  background: radial-gradient(circle at 38% 32%, #fff8e6, #d9b46a 72%, #8f6d31);
  border-color: rgba(184, 134, 47, 0.9);
  opacity: 1;
  box-shadow: 0 0 10px rgba(243, 217, 160, 0.8);
}
.d4-line.is-wrong { animation: d4-cool 520ms var(--d4-ease); }

.d4-threads {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
.d4-thread {
  fill: none;
  stroke: var(--d4-gold);
  stroke-width: 1.6;
  stroke-linecap: round;
  filter: drop-shadow(0 0 3px rgba(243, 217, 160, 0.65));
  transition: stroke-dashoffset 520ms var(--d4-silk), stroke-width 500ms var(--d4-grace);
}
.d4-thread.is-taut { stroke-width: 2.2; }
.d4-pin-dot { fill: var(--d4-gold-light); filter: drop-shadow(0 0 4px rgba(243, 217, 160, 0.9)); }

/* ---- drawer ---------------------------------------------------------------------------- */

.d4-drawer {
  position: relative;
  height: 70px;
  margin: 14px -12px 0;
  border-top: 1px solid rgba(243, 217, 160, 0.55);
  border-radius: 0 0 24px 24px;
  background:
    linear-gradient(180deg, rgba(255, 243, 214, 0.3) 0%, rgba(243, 217, 160, 0.12) 20%, rgba(8, 14, 18, 0.94) 62%, rgba(4, 8, 12, 0.99) 100%);
  overflow: hidden;
  transition: height 800ms var(--d4-grace), opacity 800ms var(--d4-grace);
}
.d4-drawer-light {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 0;
  height: 30px;
  background: radial-gradient(60% 100% at 50% 0%, rgba(255, 248, 230, 0.7) 0%, rgba(243, 217, 160, 0.2) 50%, transparent 78%);
  filter: blur(8px);
}
.d4-drawer-handle {
  position: absolute;
  left: 42%;
  right: 42%;
  top: 16px;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(255, 243, 214, 0.2), rgba(255, 243, 214, 0.8), rgba(255, 243, 214, 0.2));
  box-shadow: 0 0 8px rgba(243, 217, 160, 0.5);
}
.d4-drawer-sheet {
  position: absolute;
  left: 30%;
  right: 30%;
  top: 8px;
  height: 6px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, #f8f3e8, #e2d7c1);
  opacity: 0.9;
}
.d4-desk.is-whole .d4-sheet-left { opacity: 0.18; transform: translateY(10px) rotate(-0.6deg) scale(0.985); }
.d4-desk.is-whole .d4-sheet-right { transform: rotate(0deg) scale(1.012); box-shadow: 0 34px 70px -34px rgba(243, 217, 160, 0.35), 0 0 0 1px rgba(243, 217, 160, 0.45); }
.d4-desk.is-whole .d4-drawer { height: 84px; }
.d4-drawer-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 7px;
  text-align: center;
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255, 243, 214, 0.68);
}
.d4-desk.is-whole .d4-filament { opacity: 1; }

/* ---- choose, sharpen, rest ------------------------------------------------------------- */

.d4-choose, .d4-sharpen, .d4-rest { animation: d4-rise 560ms var(--d4-silk); }
.d4-choose-kicker, .d4-rest-kicker {
  margin: 0 0 4px;
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--d4-gold-deep);
}
.d4-choose-title, .d4-rest-title, .d4-sharpen-title {
  margin: 0 0 4px;
  font-family: var(--house-type-family-display, Satoshi, Inter, system-ui, sans-serif);
  font-size: clamp(20px, 4.8vw, 27px);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--house-color-text-strong, #fff);
}
.d4-choose-hint, .d4-sharpen-hint, .d4-rest-body {
  margin: 0 0 10px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--d4-ink-3);
}
.d4-choose-list { display: grid; gap: 7px; }
.d4-choice {
  display: grid;
  gap: 2px;
  min-height: 50px;
  padding: 9px 14px;
  text-align: left;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: linear-gradient(150deg, rgba(18, 40, 52, 0.7), rgba(7, 18, 26, 0.86));
  color: var(--d4-ink);
  font: inherit;
  cursor: pointer;
  transition: border-color 220ms var(--d4-ease), transform 220ms var(--d4-ease), box-shadow 220ms var(--d4-ease);
}
.d4-choice:hover, .d4-choice:focus-visible {
  border-color: var(--d4-gold);
  transform: translateY(-1px);
  box-shadow: 0 16px 34px -24px rgba(243, 217, 160, 0.7);
}
.d4-choice-title { font-size: 13.5px; font-weight: 600; color: var(--d4-gold-light); }
.d4-choice-hint { font-size: 11px; color: var(--d4-ink-3); }
.d4-sharpen-list { display: grid; gap: 6px; max-height: 320px; overflow: auto; }
.d4-sharpen-choice {
  display: grid;
  gap: 1px;
  min-height: 46px;
  padding: 7px 12px;
  text-align: left;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  color: var(--d4-ink);
  font: inherit;
  cursor: pointer;
}
.d4-sharpen-choice:hover, .d4-sharpen-choice:focus-visible { border-color: var(--d4-gold); }
.d4-sharpen-key {
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--d4-gold-deep);
}
.d4-sharpen-text { font-family: var(--d4-serif); font-size: 13px; line-height: 1.35; }

/* ---- card ------------------------------------------------------------------------------ */

.d4-card-wrap { position: relative; z-index: 2; }
.d4-stage.is-closed { display: none; }
.d4-card {
  position: relative;
  margin: 18px auto 0;
  max-width: 760px;
  padding: 26px 18px 18px;
  border-radius: 12px;
  border: 1px solid rgba(255, 243, 214, 0.5);
  background:
    linear-gradient(100deg, rgba(255, 255, 255, 0.5) 0%, transparent 30%),
    linear-gradient(168deg, #faf3e1 0%, #eadfc7 100%);
  color: var(--d4-paper-ink);
  box-shadow: 0 30px 70px -40px rgba(0, 0, 0, 0.9), inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  animation: d4-card-rise 680ms var(--d4-silk);
}
.d4-card::before {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 12px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(184, 134, 47, 0.75), transparent);
}
.d4-card-kicker {
  margin: 0 0 8px;
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #6b4d14;
}
.d4-card-title {
  margin: 0 0 3px;
  font-family: var(--house-type-family-display, Satoshi, Inter, system-ui, sans-serif);
  font-size: clamp(26px, 6vw, 36px);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.026em;
}
.d4-card-lead { margin: 0 0 4px; font-size: 14px; color: rgba(22, 16, 30, 0.68); }
.d4-card-hint { margin: 0 0 6px; font-size: 11.5px; line-height: 1.4; color: rgba(22, 16, 30, 0.62); }
.d4-card-note { margin: 0 0 14px; font-size: 12px; line-height: 1.45; color: var(--d4-paper-ink); }
.d4-firstchange {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-left: 2px solid #b8862f;
  background: rgba(184, 134, 47, 0.08);
}
.d4-firstchange-label, .d4-card-notes-label, .d4-card-loose-label, .d4-copy-label {
  margin: 0 0 4px;
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #6b4d14;
}
.d4-firstchange-text { margin: 0 0 4px; font-family: var(--d4-serif); font-size: 14.5px; line-height: 1.4; }
.d4-firstchange-note { margin: 0; font-size: 11.5px; line-height: 1.4; color: rgba(22, 16, 30, 0.66); }

.d4-card-lines { display: grid; gap: 10px; }
.d4-card-row { display: grid; gap: 2px; }
.d4-card-row.is-first .d4-card-key { color: #8a5a12; }
.d4-card-row.is-first .d4-card-input { border-bottom-color: #b8862f; }
.d4-card-key {
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(122, 90, 28, 0.95);
}
.d4-card-input {
  width: 100%;
  min-height: 44px;
  resize: none;
  padding: 2px 0 6px;
  border: 0;
  border-bottom: 1px solid rgba(22, 16, 30, 0.22);
  background: transparent;
  color: var(--d4-paper-ink);
  font-family: var(--d4-serif);
  font-size: 14.5px;
  line-height: 1.42;
  overflow: hidden;
}
.d4-card-input:focus {
  outline: none;
  border-bottom-color: #b8862f;
  box-shadow: 0 1px 0 0 #b8862f;
}
.d4-card-value { display: none; font-family: var(--d4-serif); font-size: 14.5px; line-height: 1.42; }

.d4-card-notes {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(22, 16, 30, 0.14);
}
.d4-card-note-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.d4-card-note-list li { display: grid; gap: 1px; }
.d4-card-note-key { font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: #6b4d14; }
.d4-card-note-text { font-size: 12px; line-height: 1.4; color: rgba(22, 16, 30, 0.8); }

.d4-card-loose {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(22, 16, 30, 0.14);
}
.d4-card-loose-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 5px; }
.d4-card-loose-list li { display: grid; grid-template-columns: 110px 1fr; gap: 8px; }
.d4-card-loose-key { font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(22, 16, 30, 0.5); padding-top: 2px; }
.d4-card-loose-text { font-family: var(--d4-serif); font-size: 13px; line-height: 1.4; color: rgba(22, 16, 30, 0.72); }

.d4-copy { margin-top: 16px; }
.d4-copy-pre {
  margin: 0;
  max-height: 240px;
  overflow: auto;
  padding: 12px;
  border-radius: 10px;
  background: rgba(22, 16, 30, 0.06);
  border: 1px solid rgba(22, 16, 30, 0.1);
  font-family: var(--house-type-family-mono, ui-monospace, Menlo, monospace);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  color: var(--d4-paper-ink);
}
.d4-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.d4-card-world {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid rgba(22, 16, 30, 0.12);
  font-size: 11.5px;
  line-height: 1.45;
  color: rgba(22, 16, 30, 0.62);
}
.d4-card-tomorrow { margin: 6px 0 0; font-size: 11.5px; line-height: 1.45; color: rgba(22, 16, 30, 0.62); }
.d4-card-smile {
  margin: 10px 0 0;
  font-family: var(--d4-serif);
  font-style: italic;
  font-size: 12.5px;
  line-height: 1.45;
  color: rgba(22, 16, 30, 0.7);
}

/* ---- buttons --------------------------------------------------------------------------- */

.d4-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 220ms var(--d4-ease), box-shadow 220ms var(--d4-ease), background 220ms var(--d4-ease), border-color 220ms var(--d4-ease), color 220ms var(--d4-ease);
}
.d4-btn:active { transform: translateY(1px); }
.d4-btn-primary {
  color: var(--d4-gold-light);
  border-color: rgba(243, 217, 160, 0.72);
  background: linear-gradient(140deg, rgba(34, 44, 42, 0.9) 0%, rgba(12, 22, 26, 0.94) 100%);
  box-shadow: 0 0 0 1px rgba(243, 217, 160, 0.12), 0 14px 32px -22px rgba(243, 217, 160, 0.8), inset 0 1px 0 rgba(255, 243, 214, 0.18);
}
.d4-btn-primary:hover {
  border-color: var(--d4-gold-light);
  box-shadow: 0 0 30px -12px rgba(243, 217, 160, 0.6), inset 0 1px 0 rgba(255, 243, 214, 0.24);
}
.d4-btn-quiet {
  color: var(--d4-ink-2);
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.03);
}
.d4-btn-quiet:hover { color: var(--d4-gold-light); border-color: rgba(243, 217, 160, 0.4); }
.d4-btn-ghost {
  color: var(--d4-paper-ink);
  border-color: rgba(22, 16, 30, 0.22);
  background: transparent;
}
.d4-btn-ghost:hover { border-color: #b8862f; }
.d4-card .d4-btn-primary {
  color: var(--d4-paper-ink);
  border-color: #b8862f;
  background: rgba(22, 16, 30, 0.04);
  box-shadow: none;
}

/* ---- focus, reduced, print ------------------------------------------------------------- */

.hp-d4 :focus-visible {
  outline: var(--house-light-focus-width, 2px) solid var(--d4-gold);
  outline-offset: var(--house-light-focus-offset, 3px);
}
.d4-card :focus-visible { outline-color: #b8862f; }

.hp-d4[data-reduced="true"] .d4-mote,
.hp-d4[data-reduced="true"] .d4-window,
.hp-d4[data-reduced="true"] .d4-drawerglow,
.hp-d4[data-reduced="true"] .d4-light[data-state="now"] { animation: none; }
.hp-d4[data-reduced="true"] .d4-thread { transition: none; }
.hp-d4[data-reduced="true"] .d4-sheet,
.hp-d4[data-reduced="true"] .d4-drawer { transition: opacity 400ms linear; }
.hp-d4[data-reduced="true"] .d4-desk.is-whole .d4-sheet-left { transform: none; opacity: 0; }
.hp-d4[data-reduced="true"] .d4-desk.is-whole .d4-sheet-right { transform: none; }
.hp-d4[data-reduced="true"] .d4-choice,
.hp-d4[data-reduced="true"] .d4-card,
.hp-d4[data-reduced="true"] .d4-choose,
.hp-d4[data-reduced="true"] .d4-sharpen,
.hp-d4[data-reduced="true"] .d4-rest { animation: none; }

@keyframes d4-drift {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(8px, -14px, 0); }
}
@keyframes d4-breathe {
  0% { opacity: 0.55; transform: scale(0.98); }
  100% { opacity: 1; transform: scale(1.04); }
}
@keyframes d4-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}
@keyframes d4-cool {
  0% { box-shadow: inset 0 0 0 0 rgba(143, 207, 255, 0.5); }
  40% { box-shadow: inset 0 0 24px -6px rgba(143, 207, 255, 0.7); }
  100% { box-shadow: inset 0 0 0 0 rgba(143, 207, 255, 0); }
}
@keyframes d4-rise {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes d4-card-rise {
  0% { opacity: 0; transform: translateY(18px) scale(0.985); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 340px) { .d4-console { min-height: 246px; } }

/* ---- wider ----------------------------------------------------------------------------- */

@media (min-width: 720px) {
  .d4-main { padding-top: 24px; }
  .d4-head { margin-bottom: 18px; }
  .d4-sheet { padding: 18px 18px 10px; }
  .d4-sheet-title { font-size: 20px; }
  .d4-line-text { font-size: 15.5px; }
  .d4-line { min-height: 56px; }
  .d4-card { padding: 32px 30px 24px; }
  .d4-card-lines { grid-template-columns: 1fr 1fr; gap: 12px 22px; }
  .d4-choose-list { grid-template-columns: repeat(3, 1fr); }
  .d4-choice { min-height: 74px; }
}

@media (min-width: 900px) {
  .d4-nav { display: none; }
  .d4-sheets { grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
  .d4-sheet-left { transform: rotate(-0.4deg); }
  .d4-sheet-right { transform: rotate(0.3deg); }
  .d4-filament { right: 8%; }
}

/* ---- layer mode inside a lesson -------------------------------------------------------- */

.hp-layer { min-height: 0; background: transparent; }
.hp-layer .d4-main { padding: 0 0 8px; width: 100%; }
.hp-layer .d4-console { padding: 12px; border-radius: 14px; }
.hp-layer .d4-sheet { padding: 12px 12px 8px; }
.hp-layer .d4-card { margin-top: 12px; }

/* ---- print: the card only -------------------------------------------------------------- */

@media print {
  .hp-d4 { background: #fff; color: #16101e; min-height: 0; }
  .d4-sky, .d4-top, .d4-head, .d4-foot, .d4-console, .d4-desk, .d4-stage, .d4-sr,
  .d4-card-actions { display: none !important; }
  .d4-main, .d4-card-wrap { width: 100%; padding: 0; margin: 0; }
  .d4-card {
    margin: 0;
    max-width: none;
    border: 0;
    box-shadow: none;
    background: #fff;
    animation: none;
  }
  .d4-card-input { display: none; }
  .d4-card-value { display: block; }
  .d4-copy-pre { max-height: none; border: 1px solid #ccc; background: #faf8f2; }
  .d4-card-world, .d4-card-tomorrow { color: #333; }
}
