/* Nightfall. Component finishes are shared by the working controls and gallery specimens. */
.tm-express {
  --t-bg: #111820; --t-card-solid: #1d2932; --t-ink: #fff0d6; --t-muted: #c9c3ac;
  --t-accent: #ffd18a; --t-accent2: #fa977b; --t-accent-ink: #2b1c13; --t-line: #65594b;
  --t-input: #141e25; --t-theirs: #2c3b43; --t-mine: #694736; --t-radius: 5px; --t-btn-radius: 4px;
  --t-display: "Bebas Neue", Impact, sans-serif; --t-tech: "Space Grotesk",system-ui,sans-serif;
  --t-h1: 2.45rem; --t-display-weight: 400; --t-h1-track: .045em;
  --t-wall: repeating-linear-gradient(90deg,transparent 0 55px,#f3c78408 55px 56px),linear-gradient(155deg,#202732,#0e161d 60%);
  --t-btn: linear-gradient(105deg,#ffdc9c,#f3b771); --key-shadow: inset 0 0 0 2px #301b141a,0 2px 0 #080e14;
  --panel-shadow: inset 0 2px #eebd7d55,0 4px 14px #07090b55; --tile-shape: 4px;
  --tile-surface: #273943; --tile-edge: #bc9972;
}
.tm-halide {
  --t-bg: #14111c; --t-card-solid: #26212f; --t-ink: #f5edff; --t-muted: #c6bed4;
  --t-accent: #e6b7f5; --t-accent2: #a9e1ee; --t-accent-ink: #28172d; --t-line: #605570;
  --t-input: #191620; --t-theirs: #353041; --t-mine: #58446b; --t-radius: 14px; --t-btn-radius: 999px;
  --t-display: "Space Grotesk",system-ui,sans-serif; --t-tech: "Inter",system-ui,sans-serif;
  --t-h1: 1.95rem; --t-display-weight: 650; --t-h1-track: -.035em;
  --t-wall: radial-gradient(ellipse at 85% 15%,#41314650,transparent 50%),linear-gradient(150deg,#211d2a,#111018 70%);
  --t-btn: linear-gradient(165deg,#f6e5fa,#dab8e7 55%,#b8bfd7); --key-shadow: inset 0 1px #fff9,0 0 0 2px #15121c,0 0 0 3px #796e87;
  --panel-shadow: inset 0 1px #b3a8c144,0 10px 24px #09080d55; --tile-shape: 50%;
  --tile-surface: #302d3a; --tile-edge: #b2a7c7;
}
.tm-grove {
  --t-bg: #101d1c; --t-card-solid: #1b302c; --t-ink: #f1f5df; --t-muted: #b8cdbd;
  --t-accent: #d9ee99; --t-accent2: #8fd9bc; --t-accent-ink: #193025; --t-line: #506e5b;
  --t-input: #10251f; --t-theirs: #2c483e; --t-mine: #355747; --t-radius: 20px 6px 20px 6px; --t-btn-radius: 16px 4px 16px 4px;
  --t-display: "Fraunces",Georgia,serif; --t-tech: "Inter",system-ui,sans-serif;
  --t-h1: 1.95rem; --t-display-weight: 550; --t-h1-track: -.025em;
  --t-wall: radial-gradient(ellipse at 9% 80%,#24483a65,transparent 45%),linear-gradient(145deg,#192f2a,#101c1b 70%);
  --t-btn: linear-gradient(125deg,#e2eda6,#a7d9a8); --key-shadow: inset 0 1px #fbffce99,0 2px 0 #071911;
  --panel-shadow: inset 0 1px #bad8a12e,0 6px 16px #06100b55; --tile-shape: 52% 15% 52% 15%;
  --tile-surface: #29463b; --tile-edge: #99bc8d;
}
:is(.tm-express,.tm-halide,.tm-grove) {
  --t-card: var(--t-card-solid); --t-tabs: var(--t-bg); --t-sheet: var(--t-card-solid); --t-header: var(--t-card-solid);
  --t-body: "Inter",system-ui,sans-serif; --t-tabfont: var(--t-tech); --t-scheme: dark; --t-sec: var(--t-ink); --t-link: var(--t-accent);
  --t-title: linear-gradient(100deg,var(--t-ink),var(--t-accent)); --t-btn-ink: var(--t-accent-ink); --t-mine-ink: #fffaf0;
  --t-wall-wide: var(--t-wall); --t-veil: none; --t-veil-wide: none; --t-pattern: none; --t-blur: none;
  --t-card-shadow: var(--panel-shadow); --t-danger: #ffa8a1; --t-admin: #f6c47b;
}

/* Working surfaces. Preserve content artwork on media cards. */
html:is(.tm-express,.tm-halide,.tm-grove)
  :is(.card,.sheet,.toc,.th-bar,.th-lite,.sendbar,.mu-player,.fitem,#toast) {
  background-color: var(--t-card-solid); border: 1px solid var(--t-line); border-radius: var(--t-radius);
  box-shadow: var(--panel-shadow); backdrop-filter: none;
}
html:is(.tm-express,.tm-halide,.tm-grove) :is(.sheet h2,.section-title,.toc .toc-h,.th-ed h2) {
  font-family: var(--t-display); font-weight: var(--t-display-weight); letter-spacing: var(--t-h1-track);
}
html:is(.tm-express,.tm-halide,.tm-grove) :is(input[type=text],input[type=search],input[type=password],textarea,.select) {
  color: var(--t-ink); background-color: var(--t-input); border: 1px solid var(--t-line);
  border-radius: var(--t-radius); box-shadow: inset 0 2px 5px #0004; accent-color: var(--t-accent);
}
html:is(.tm-express,.tm-halide,.tm-grove) :is(input,textarea)::placeholder { color: var(--t-muted); opacity: .9; }
html:is(.tm-express,.tm-halide,.tm-grove) .msg { border-radius: var(--t-radius); border: 1px solid var(--t-line); }
html:is(.tm-express,.tm-halide,.tm-grove) .msg.mine { border-color: color-mix(in srgb,var(--t-accent) 38%,transparent); }
html:is(.tm-express,.tm-halide,.tm-grove) :is(header.top h1,.appban .ab-name,.appban .ab-tag) { text-shadow: none; filter: none; }
html:is(.tm-express,.tm-halide,.tm-grove) :is(a,button,input,textarea,select,summary,[role=button]):focus-visible,
.th-night .th-card:focus-visible { outline: 2px solid var(--t-accent2); outline-offset: 3px; }
html:is(.tm-express,.tm-halide,.tm-grove) .sheet-bg { background: #06070bb8; }
html.tm-express .sheet { border-top: 4px double var(--t-accent); }
html.tm-halide .sheet { border-top: 3px ridge #baaec6; }
html.tm-grove .sheet { border-radius: 28px 8px 0 0; border-top-color: var(--t-accent2); }
@media(min-width:720px) {
  html.tm-halide .sheet-bg { align-items: center; }
  html.tm-halide .sheet { width: min(90%,40rem); }
}

/* Pictograms stay identifiable while their enclosures and secondary ink change by theme. */
.night-icon { display: none; width: 1.3rem; height: 1.3rem; pointer-events: none; }
.night-preview .night-icon, html:is(.tm-express,.tm-halide,.tm-grove) .night-icon { display: block; }
.night-tile, html:is(.tm-express,.tm-halide,.tm-grove) :is(#tabs a .ic,.appban .ab-ic) {
  display: inline-grid; place-items: center; flex: none; position: relative; font-size: 0;
  width: 2.05rem; height: 2.05rem; margin: 0; border: 1px solid var(--tile-edge); border-radius: var(--tile-shape);
  background: var(--tile-surface); color: var(--t-ink); --icon-detail: var(--t-accent);
  opacity: 1; box-shadow: inset 0 1px #fff2; filter: none; transform: none;
}
html:is(.tm-express,.tm-halide,.tm-grove) .appban .ab-ic { width: 3.25rem; height: 3.25rem; }
html:is(.tm-express,.tm-halide,.tm-grove) .ab-ic .night-icon { width: 2rem; height: 2rem; }
html:is(.tm-express,.tm-halide,.tm-grove) #tabs {
  gap: 2px; padding: 4px 3px max(4px,env(safe-area-inset-bottom)); background: var(--t-bg);
  border-top: 1px solid var(--t-line); box-shadow: 0 -3px 16px #0005; backdrop-filter: none;
}
html:is(.tm-express,.tm-halide,.tm-grove) #tabs a {
  justify-content: center; gap: 3px; color: var(--t-muted); padding: 3px 1px; letter-spacing: 0;
}
html:is(.tm-express,.tm-halide,.tm-grove) #tabs a.on { color: var(--t-accent); }
html:is(.tm-express,.tm-halide,.tm-grove) #tabs a.on .ic {
  color: var(--t-accent-ink); --icon-detail: var(--t-accent-ink); border-color: var(--t-accent);
  background: var(--t-btn); box-shadow: 0 0 0 2px var(--t-bg),0 0 0 3px var(--tile-edge);
}
html:is(.tm-express,.tm-halide,.tm-grove) #tabs a.on::after { display:none; }
html.tm-express #tabs a + a { border-left: 1px solid #ffffff12; }
html.tm-halide #tabs a .ic,.th-card.tm-halide .night-tile { outline: 1px dashed #ac99bc75; outline-offset: 1px; }
html.tm-grove #tabs a .ic,.th-card.tm-grove .night-tile { background-image: linear-gradient(138deg,transparent 48%,#bce3a61f 49%,transparent 54%); }

html:is(.tm-express,.tm-halide,.tm-grove) cs-action-icon {
  display: inline-block; position: relative; width: 1rem; height: 1rem; overflow: hidden;
  font-size: 0; line-height: 0; margin-inline-end: .36rem; vertical-align: -.15rem;
}
html:is(.tm-express,.tm-halide,.tm-grove) cs-action-icon .night-icon {
  position: absolute; inset: 0; width: 100%; height: 100%; background: inherit; --icon-detail: currentColor;
}
/* Animated illustration across the banner; the page title and controls have their own opaque base. */
html:is(.tm-express,.tm-halide,.tm-grove) .appban {
  background: var(--t-bg); border: 1px solid var(--t-line); border-radius: var(--t-radius); box-shadow: var(--panel-shadow);
}
html:is(.tm-express,.tm-halide,.tm-grove) .appban:not(.slim) { min-height: 0; }
html:is(.tm-express,.tm-halide,.tm-grove) .appban:not(.slim) .ab-body {
  min-height: clamp(8rem,12vw,10.5rem); padding: 1rem clamp(.85rem,2.3vw,2.4rem); align-items: center;
}
html:is(.tm-express,.tm-halide,.tm-grove) .appban .ab-art { background: none; animation: none; }
.night-scene { display: block; width: 100%; height: 100%; pointer-events: none; }
html:is(.tm-express,.tm-halide,.tm-grove) .ab-art .night-scene {
  position: absolute; top: 0; right: 0; width: clamp(22rem,58%,52rem);
}
html:is(.tm-express,.tm-halide,.tm-grove) .appban::after {
  background: linear-gradient(90deg,var(--t-bg) 14%,color-mix(in srgb,var(--t-bg) 94%,transparent) 38%,transparent 72%);
}
html:is(.tm-express,.tm-halide,.tm-grove) .appban .ab-name {
  font-size: clamp(2.1rem,4.5vw,3.8rem); letter-spacing: var(--t-h1-track);
}
html:is(.tm-express,.tm-halide,.tm-grove) .appban .ab-text { flex: 0 1 auto; max-width: 57%; }
html:is(.tm-express,.tm-halide,.tm-grove) .appban .ab-tag {
  color: var(--t-ink); opacity: 1; font: .9375rem/1.45 var(--t-body);
}
html:is(.tm-express,.tm-halide,.tm-grove) .appban .ab-btns {
  margin-left: auto; align-self: start; padding: 3px;
}
html:is(.tm-express,.tm-halide,.tm-grove) .appban .ab-ticker { background: var(--t-input); color: var(--t-muted); border-color: var(--t-line); }
html:is(.tm-express,.tm-halide,.tm-grove) .appban.slim { min-height: 0; border-radius: 0; }
html:is(.tm-express,.tm-halide,.tm-grove) .appban.slim::after { display: none; }

/* Ticket punches, shutter releases, and leaf keys. Avoid clipping focus outlines. */
html:is(.tm-express,.tm-halide,.tm-grove) :is(.btn,.ab-work,.ab-theme,.actions button,.seg button),
.night-sample-key {
  position: relative; overflow: hidden; isolation: isolate;
  border: 1px solid var(--t-accent); border-radius: var(--t-btn-radius); background: var(--t-btn);
  color: var(--t-btn-ink); box-shadow: var(--key-shadow); font-family: var(--t-tech); font-weight: 700;
}
html:is(.tm-express,.tm-halide,.tm-grove) :is(.btn.ghost,.ab-work,.ab-theme,.actions button:not(.on),.seg button:not(.on)) {
  color: var(--t-ink); border-color: var(--t-line); background: var(--tile-surface); box-shadow: inset 0 1px #fff2;
}
html:is(.tm-express,.tm-halide,.tm-grove) .btn.danger { background: #7c3546; color: #fff4ee; border-color: #f1a5a9; }
html:is(.tm-express,.tm-halide,.tm-grove) :is(.btn,.ab-work,.ab-theme,.actions button,.seg button):not(:disabled):active {
  transform: translateY(2px); box-shadow: inset 0 2px 3px #0005;
}
html.tm-express :is(.btn,.ab-work,.ab-theme),.th-card.tm-express .night-sample-key {
  padding-inline-end: 1.55rem; border-right: 5px double currentColor; text-transform: uppercase; letter-spacing: .055em;
}
html.tm-express :is(.btn,.ab-work,.ab-theme)::after,.th-card.tm-express .night-sample-key::after {
  content: ""; position: absolute; right: .45rem; top: 17%; bottom: 17%; border-left: 1px dashed currentColor; opacity: .55;
}
html.tm-halide .btn:not(.ghost):not(.danger),.th-card.tm-halide .night-sample-key {
  border: 2px solid #c6bacf; box-shadow: var(--key-shadow); padding-inline: 1.2rem;
}
html.tm-grove .btn:not(.ghost):not(.danger),.th-card.tm-grove .night-sample-key {
  background: linear-gradient(143deg,transparent 62%,#6e99784a 63%,transparent 65%),var(--t-btn);
}
.night-sample-key { display: inline-flex; align-items: center; gap: .45rem; padding: .5rem .85rem; font-size: .9rem; margin-left: auto; }
.night-sample-key .night-icon { width: 1.05rem; height: 1.05rem; --icon-detail: currentColor; }
.night-feedback { position: absolute; z-index: 1; pointer-events: none; width: 12px; height: 12px; margin: -6px; }
.tm-express .night-feedback { border: 2px dashed currentColor; border-radius: 50%; }
.tm-halide .night-feedback {
  border-radius: 50%; background: repeating-conic-gradient(from 15deg,currentColor 0deg 4deg,transparent 5deg 60deg);
  border: 1px solid currentColor;
}
.tm-grove .night-feedback { border-radius: 75% 12%; box-shadow: 0 0 8px #fff3a0; border: 1px solid currentColor; }
.th-night .th-grid { grid-template-columns: repeat(auto-fit,minmax(min(100%,255px),1fr)); }
.th-night .th-card { background: var(--t-card-solid); border-radius: var(--t-radius); }
.th-night .th-meta { padding: .78rem 1rem 1rem; }
.th-night .th-meta b { font-family: var(--t-display); font-size: 1.6rem; }
.th-night .th-meta p { font: .9375rem/1.45 var(--t-body); }
.th-night .th-sw { display: none; }
.night-preview { background: var(--t-bg); }
.night-preview .night-scene { height: auto; aspect-ratio: 3/1; }
.night-tools { display: flex; align-items: center; gap: .55rem; background: var(--t-input); padding: .55rem .8rem; border-top: 1px solid var(--t-line); }
@media(max-width:600px) {
  html:is(.tm-express,.tm-halide,.tm-grove) #tabs { grid-template-columns: repeat(5,minmax(0,1fr)); }
  html:is(.tm-express,.tm-halide,.tm-grove) #tabs a { min-height: 44px; font-size: .75rem; line-height: 1.05; gap: 2px; }
  html:is(.tm-express,.tm-halide,.tm-grove) #tabs a .ic { width: 1.55rem; height: 1.55rem; }
  html:is(.tm-express,.tm-halide,.tm-grove) #tabs a .night-icon { width: 1.05rem; height: 1.05rem; }
  html:is(.tm-express,.tm-halide,.tm-grove) .mu-player { bottom: calc(154px + env(safe-area-inset-bottom)); }
  html:is(.tm-express,.tm-halide,.tm-grove) body.music-mode #app { padding-bottom: calc(325px + env(safe-area-inset-bottom)); }
  html:is(.tm-express,.tm-halide,.tm-grove) .appban:not(.slim) .ab-body { gap: .6rem; }
  html:is(.tm-express,.tm-halide,.tm-grove) .appban .ab-text { flex: 1; max-width: none; }
  html:is(.tm-express,.tm-halide,.tm-grove) .appban .ab-btns { flex-basis: 100%; margin: 0; justify-content: start; padding: 0; }
  html:is(.tm-express,.tm-halide,.tm-grove) .ab-art .night-scene { width: 100%; }
  html:is(.tm-express,.tm-halide,.tm-grove) .appban::after { background: linear-gradient(90deg,var(--t-bg),color-mix(in srgb,var(--t-bg) 90%,transparent) 40%,color-mix(in srgb,var(--t-bg) 25%,transparent)); }
}

@keyframes night-crossing { from { transform: translateX(-301px); } to { transform: translateX(383px); } }
@keyframes night-iris { 0%,100% { transform: rotate(-4deg); } 55%,68% { transform: rotate(18deg); } }
@keyframes night-glass { from { opacity: .45; } to { opacity: 1; transform: translate(2px,-1px); } }
@keyframes night-breeze { from { transform: rotate(-1.1deg); } to { transform: rotate(1.4deg); } }
@keyframes night-drift { 0%,100% { transform: translate(0,2px); opacity: .58; } 48% { transform: translate(9px,-8px); opacity: .98; } 74% { transform: translate(4px,-11px); opacity: .76; } }
@keyframes night-arrive { from { opacity: .4; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion:no-preference) {
  html.tm-halide:not(.lite) .btn:not(.ghost):not(.danger) {
    background: linear-gradient(110deg,transparent 35%,#fff8 48%,transparent 58%) 115% 0 / 275% 100% no-repeat,var(--t-btn);
    transition: background-position .36s ease-out,box-shadow .15s,transform .12s;
  }
  html.tm-halide:not(.lite) .btn:not(.ghost):not(.danger):is(:hover,:focus-visible) { background-position: 0% 0; }
  .night-train { animation: night-crossing 13s linear -5s infinite; }
  .night-blade { transform-origin: 302px 49px; animation: night-iris 6s ease-in-out -1s infinite; }
  .night-glint { animation: night-glass 4s ease-in-out infinite alternate; }
  .night-fronds { transform-origin: 68% 100%; animation: night-breeze 6s ease-in-out infinite alternate; }
  .night-flies { animation: night-drift 6s ease-in-out infinite; }
  .night-flies-far { animation-delay: -4s; animation-duration: 8s; }
  .th-night .th-card:not(:hover):not(:focus-visible) .night-scene use { animation-play-state: paused; }
  html:not(.lite):not(.idle):is(.tm-express,.tm-halide,.tm-grove) :is(.sheet,.msg:last-child) { animation: night-arrive .23s ease-out; }
  .th-night .th-card:is(:hover,:focus-visible) .night-sample-key { filter: brightness(1.1); }
  html:not(.lite):is(.tm-express,.tm-halide,.tm-grove) #tabs a .night-icon {
    transition: transform .22s ease-out;
  }
  html.tm-express:not(.lite) #tabs a:is(:hover,:focus-visible) .night-icon { transform: translateX(2px); }
  html.tm-halide:not(.lite) #tabs a:is(:hover,:focus-visible) .night-icon { transform: rotate(-9deg) scale(1.1); }
  html.tm-grove:not(.lite) #tabs a:is(:hover,:focus-visible) .night-icon { transform: translateY(-2px) rotate(5deg); }
  html:not(.lite):is(.tm-express,.tm-halide,.tm-grove) :is(.btn,.ab-work,.ab-theme):not(:disabled):hover { filter: brightness(1.13); }
}
html.lite .night-scene use { animation: none; }
html:is(.idle,[data-night-asleep]) .night-scene use { animation-play-state: paused; }
@media (prefers-reduced-motion:reduce) {
  html:is(.tm-express,.tm-halide,.tm-grove) :is(.btn,.actions button,.seg button,.ab-work,.ab-theme):active { transform: none; }
  html:is(.tm-express,.tm-halide,.tm-grove) :is(.btn,.ab-work,.ab-theme,#tabs a,.th-card) { transition: none; }
  .night-feedback { display: none; }
}
