/* Lamplight theme for Emeraldz: a lamp-lit room at night.
   Generated from lamplight.design.md. Change the two colours below to re-tint everything. */
:root {
  --ink: #0e0a08;
  --paper: #f3e7d2;
  --paper-dim: rgba(243,231,210,.72);
  --accent: #f0a64a;
  --night: #3fae8c;
  --line: rgba(243,231,210,.2);
  --field: rgba(243,231,210,.06);
  --alert: #ff9a86;
  --serif: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --sans: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  --gut: clamp(16px, 3.4vw, 52px);
  --ease-out: cubic-bezier(.2, .7, .2, 1);
  --spark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 0C12.7 7.6 16.4 11.3 24 12C16.4 12.7 12.7 16.4 12 24C11.3 16.4 7.6 12.7 0 12C7.6 11.3 11.3 7.6 12 0Z'/%3E%3C/svg%3E");
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--ink); }
html, body { overscroll-behavior: none; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; isolation: isolate;
  background: var(--ink); color: var(--paper); font: 400 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
h1 { margin: 40px 0 6px; font: 800 clamp(40px, 9vw, 60px)/1.05 var(--serif); letter-spacing: .01em; }
h2 { margin: 32px 0 6px; font: 800 clamp(28px, 6vw, 38px)/1.15 var(--serif); }
h3 { margin: 0; font: 800 20px/1.2 var(--serif); }
.lede { margin: 0; max-width: 60ch; color: var(--paper-dim); }
.meta { margin: 6px 0 0; font-size: 13px; color: var(--accent); }
.empty { padding: 20px 0; color: var(--paper-dim); }

.wrap { position: relative; width: 100%; max-width: 620px; margin: 0 auto;
  padding: calc(30px + env(safe-area-inset-top, 0px)) 16px calc(56px + env(safe-area-inset-bottom, 0px)); }
.wrap.wide { max-width: 720px; }
@media (min-width: 1000px) { .wrap { margin-left: 9vw; } }

/* ---------- backdrop ---------- */
.ambient { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background: var(--ink); }
.ambient::before, .ambient::after { content: ""; position: absolute; border-radius: 50%; will-change: transform; }
.ambient::before { /* lamp light, top right */
  width: 95vmax; height: 95vmax; right: -40vmax; top: -50vmax;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 36%, transparent),
    color-mix(in srgb, var(--accent) 13%, transparent) 45%, transparent);
  animation: drift-lamp 46s ease-in-out infinite alternate;
}
.ambient::after { /* night light, bottom left */
  width: 85vmax; height: 85vmax; left: -38vmax; bottom: -48vmax;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--night) 26%, transparent),
    color-mix(in srgb, var(--night) 9%, transparent) 50%, transparent);
  animation: drift-night 58s ease-in-out infinite alternate;
}
@keyframes drift-lamp { to { transform: translate(-7vmax, 6vmax) scale(1.08); } }
@keyframes drift-night { to { transform: translate(8vmax, -5vmax) scale(1.1); } }

.ambient .sketch {
  position: absolute; right: -4vmin; top: 50%; height: min(116vh, 980px); width: auto;
  transform: translateY(-50%) rotate(-9deg); color: var(--paper); opacity: .17;
}
.ambient .sketch path {
  fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; vector-effect: non-scaling-stroke;
  stroke-dasharray: 1; stroke-dashoffset: 1; animation: sketch 2.2s var(--ease-out) forwards;
}
.ambient .sketch .outer2, .ambient .sketch .table2 { opacity: .5; animation-delay: .35s; }
.ambient .sketch .mid { animation-delay: .5s; }
.ambient .sketch .table { animation-delay: .7s; }
.ambient .sketch .facets { stroke: var(--night); opacity: .9; animation-delay: 1s; }
@keyframes sketch { to { stroke-dashoffset: 0; } }

.ambient .spark {
  position: absolute; width: var(--s, 14px); height: var(--s, 14px); fill: var(--paper); opacity: 0;
  animation: glint var(--d, 9s) ease-in-out var(--delay, 0s) infinite;
}
@keyframes glint {
  0%, 82%, 100% { opacity: 0; transform: scale(.3) rotate(0deg); }
  88% { opacity: .85; transform: scale(1) rotate(45deg); }
  94% { opacity: .35; transform: scale(.7) rotate(80deg); }
}
.ambient .grain {
  position: absolute; inset: 0; opacity: .075;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 .9 0 0 0 0 .8 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.ambient.quiet::before { opacity: .65; }
.ambient.quiet::after { opacity: .7; }
.ambient.quiet .sketch { opacity: .09; }
.ambient.over-video { z-index: 0; background: none; }
.ambient.over-video::before, .ambient.over-video::after { display: none; }
.ambient.over-video .grain { opacity: .06; }
@media (max-width: 760px) {
  .ambient .sketch { right: -38vw; height: 92vh; opacity: .12; }
  .ambient.quiet .sketch { opacity: .07; }
}

/* media background: <div class="film"><video …></video><div class="scrim"></div></div> */
.film { position: fixed; inset: 0; overflow: hidden; background: #000; }
.film video, .film img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: fade-in 1.6s ease-out both; }
.scrim { position: absolute; inset: 0; pointer-events: none; background:
  linear-gradient(to top, rgba(14,10,8,.94) 0%, rgba(14,10,8,.62) 24%, rgba(14,10,8,0) 52%),
  radial-gradient(ellipse 65% 50% at 0% 0%, rgba(14,10,8,.72), rgba(14,10,8,0)),
  linear-gradient(to left, rgba(14,10,8,.66) 0%, rgba(14,10,8,.3) 14%, rgba(14,10,8,0) 30%),
  linear-gradient(to bottom, rgba(14,10,8,.4) 0%, rgba(14,10,8,0) 24%),
  radial-gradient(ellipse at center, transparent 50%, rgba(14,10,8,.4) 100%); }

/* ---------- logo ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.logo { display: inline-block; font: 800 18px/1 var(--serif); letter-spacing: .14em; color: var(--paper); text-decoration: none; transition: color .2s; }
.logo small { margin-left: .5em; font: 500 13px/1 var(--sans); letter-spacing: .02em; color: var(--accent); }
a.logo:hover { color: var(--accent); }

/* vertical hero name, right side */
.side-mark { position: fixed; z-index: 0; top: calc(30px + env(safe-area-inset-top, 0px)); right: var(--gut);
  display: flex; flex-direction: row-reverse; align-items: flex-start; gap: 12px; pointer-events: none; }
.side-mark a, .side-mark button { pointer-events: auto; }
.vmark { margin: 0; writing-mode: vertical-rl; font: 800 clamp(40px, min(10.5vh, 13vw), 104px)/1 var(--serif);
  letter-spacing: .14em; color: var(--paper); text-shadow: 0 0 32px rgba(14,10,8,.55), 0 2px 3px rgba(14,10,8,.35); }
.vmark .ch { display: inline-block; animation: ink 1s var(--ease-out) calc(.35s + var(--i) * .11s) both; }
.vline { margin: 0; padding-top: .35em; writing-mode: vertical-rl; font: 500 12px/1 var(--sans); letter-spacing: .3em;
  color: var(--accent); text-shadow: 0 0 12px rgba(14,10,8,.7); animation: fade-in 1s ease-out 1.1s both; }
@keyframes ink { from { opacity: 0; filter: blur(10px); transform: translateY(-.12em); } to { opacity: 1; filter: none; transform: none; } }
@media (max-width: 999px) {
  .side-mark { position: absolute; top: calc(84px + env(safe-area-inset-top, 0px)); right: 16px; gap: 8px; }
  .side-mark .vmark { font-size: 24px; }
  .side-mark .vline { font-size: 10px; }
  .has-side-mark header h1, .has-side-mark header .lede { padding-right: 52px; }
  .has-side-mark header { min-height: 205px; }
}

/* sparkle hover mark: put class "mark" on the name inside a link */
.mark { position: relative; }
.mark::after {
  content: ""; position: absolute; width: .42em; height: .42em; background: var(--accent);
  -webkit-mask: var(--spark) center / contain no-repeat; mask: var(--spark) center / contain no-repeat;
  transform: translate(.28em, -.05em) scale(0) rotate(-90deg); opacity: 0;
  transition: transform .35s var(--ease-out), opacity .2s ease-out;
}
a:hover .mark::after, a:focus-visible .mark::after { transform: translate(.28em, -.05em) scale(1) rotate(0deg); opacity: 1; }

/* ---------- nav ---------- */
.site-nav { display: flex; align-items: center; gap: 6px; }
.site-nav a {
  display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 6px 13px;
  border-radius: 999px; border: 1px solid rgba(243,231,210,.22); background: rgba(14,10,8,.4);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: var(--paper); font: 500 13px/1 var(--sans); text-decoration: none;
  transition: border-color .2s, color .2s, transform .12s;
}
.site-nav a:hover { border-color: var(--accent); color: var(--accent); }
.site-nav a:active { transform: scale(.95); }
.site-nav a[aria-current="page"] { border-color: color-mix(in srgb, var(--accent) 60%, transparent); color: var(--accent); }
.site-nav .key-only { width: 34px; padding: 0; }
.site-nav svg { width: 16px; height: 16px; }

/* ---------- link rows ---------- */
.rows { list-style: none; margin: 32px 0 0; padding: 0; }
.rows > li { border-top: 1px solid var(--line); animation: rise .6s var(--ease-out) both; animation-delay: .54s; }
.rows > li:last-child { border-bottom: 1px solid var(--line); }
.rows > li:nth-child(1) { animation-delay: .24s; } .rows > li:nth-child(2) { animation-delay: .3s; }
.rows > li:nth-child(3) { animation-delay: .36s; } .rows > li:nth-child(4) { animation-delay: .42s; }
.rows > li:nth-child(5) { animation-delay: .48s; }
.rows a {
  position: relative; display: block; padding: 18px 12px 18px 0; color: inherit; text-decoration: none;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 13%, transparent), transparent 75%) no-repeat;
  background-size: 0% 100%; transition: background-size .45s var(--ease-out);
}
.rows a:hover, .rows a:focus-visible { background-size: 100% 100%; }
.rows a > span { display: block; transition: transform .35s var(--ease-out); }
.rows a:hover > span, .rows a:focus-visible > span { transform: translateX(10px); }
.rows a:active > span { transform: translateX(12px) scale(.99); }
.rows .title { font: 800 23px/1.25 var(--serif); transition: color .2s; }
.rows a:hover .title, .rows a:focus-visible .title { color: var(--accent); }
.rows .sub { display: block; margin-top: 4px; font-size: 13px; color: var(--accent); }
.rows .to { display: block; font-size: 13px; color: var(--paper-dim); }
.locked::before {
  content: ""; display: inline-block; width: 11px; height: 11px; margin-right: 6px; vertical-align: -1px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 7V5a4 4 0 0 1 8 0v2h1v8H3V7h1zm2 0h4V5a2 2 0 0 0-4 0v2z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 7V5a4 4 0 0 1 8 0v2h1v8H3V7h1zm2 0h4V5a2 2 0 0 0-4 0v2z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---------- title tiles (balanced by count) ---------- */
.tiles { --cols: 3; list-style: none; margin: 32px 0 0; padding: 0; display: grid; grid-template-columns: repeat(var(--cols), 1fr);
  gap: 22px clamp(20px, 3vw, 48px); max-width: calc(var(--cols) * 340px + (var(--cols) - 1) * clamp(20px, 3vw, 48px)); }
.tiles:not(:has(> li:nth-child(2))) { --cols: 1; }
.tiles:has(> li:nth-child(2)):not(:has(> li:nth-child(3))) { --cols: 2; }
@media (min-width: 1200px) { .tiles:has(> li:nth-child(4)):not(:has(> li:nth-child(5))), .tiles:has(> li:nth-child(7)) { --cols: 4; } }
@media (max-width: 1199px) { .tiles:has(> li:nth-child(4)):not(:has(> li:nth-child(5))) { --cols: 2; } }
@media (max-width: 760px) { .tiles, .tiles[class] { --cols: 1 !important; row-gap: 14px; max-width: none; } }
.tiles > li { animation: rise .7s var(--ease-out) .5s both; }
.tiles > li:nth-child(2) { animation-delay: .6s; } .tiles > li:nth-child(3) { animation-delay: .7s; }
.tiles > li:nth-child(4) { animation-delay: .8s; } .tiles > li:nth-child(n+5) { animation-delay: .9s; }
.tile a { position: relative; display: block; height: 100%; padding: 20px 0 6px; color: inherit; text-decoration: none; border-top: 1px solid var(--line); transition: opacity .3s; }
.tile a::before { content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 2px; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .5s var(--ease-out); }
.tile a:hover::before, .tile a:focus-visible::before { transform: scaleX(1); }
.tiles:hover .tile a:not(:hover) { opacity: .5; }
.tile .name { display: block; font: 800 clamp(28px, 3.2vw, 48px)/1.05 var(--serif); color: var(--paper); transition: color .25s; }
.tile a:hover .name, .tile a:focus-visible .name { color: var(--accent); }
.tile .what { display: block; margin-top: 12px; max-width: 36ch; font-size: 15px; line-height: 1.55; color: var(--paper-dim); }
.tile .host { display: block; margin-top: 14px; font-size: 13px; letter-spacing: .03em; color: var(--accent); }

/* quiet "see more" link: long thin arrow + small words */
.more-link { display: inline-flex; flex-direction: column; gap: 10px; color: var(--paper-dim); font: 500 14px/1.4 var(--sans); letter-spacing: .02em; text-decoration: none; transition: color .2s; }
.more-link svg { width: clamp(56px, 5vw, 76px); height: auto; transition: transform .4s var(--ease-out), color .2s; }
.more-link:hover, .more-link:focus-visible { color: var(--paper); }
.more-link:hover svg, .more-link:focus-visible svg { color: var(--accent); transform: translateX(10px); }

/* ---------- buttons ---------- */
.btn { appearance: none; -webkit-appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 14px; border-radius: 8px; border: 1px solid rgba(243,231,210,.3); background: rgba(14,10,8,.35);
  color: var(--paper); font: 500 14px/1.2 var(--sans); text-decoration: none; cursor: pointer;
  transition: border-color .2s, color .2s, background .2s, transform .12s; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--ink); font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: transparent; color: var(--accent); }
.btn.small { min-height: 34px; padding: 6px 11px; font-size: 13px; }
.btn.round { width: 40px; height: 40px; min-height: 0; padding: 0; border-radius: 50%; border-color: rgba(243,231,210,.35);
  background: rgba(14,10,8,.4); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.btn.round:active:not(:disabled) { transform: scale(.92); }
.btn.round svg { width: 16px; height: 16px; }
.btn.busy:disabled, .btn.done:disabled { opacity: 1; }
.btn.busy::before { content: ""; width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn.done { border-color: var(--accent); color: var(--accent); }
.btn.primary.done { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.btn.done::before { content: ""; width: 14px; height: 14px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6.2 11.6 2.8 8.2l1.4-1.4 2 2 5.6-5.6 1.4 1.4z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6.2 11.6 2.8 8.2l1.4-1.4 2 2 5.6-5.6 1.4 1.4z'/%3E%3C/svg%3E") center / contain no-repeat;
  animation: tick-in .3s var(--ease-out) both; }

/* ---------- fields ---------- */
label { display: flex; justify-content: space-between; gap: 12px; margin: 14px 0 6px; font-size: 13px; color: var(--paper-dim); }
input:not([type=checkbox]):not([type=radio]):not([type=range]), textarea, select {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid rgba(243,231,210,.22); background: var(--field);
  color: var(--paper); font: 400 15px/1.5 var(--sans); transition: border-color .2s, background .2s; }
input:focus, textarea:focus, select:focus { border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: rgba(243,231,210,.09); }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input::placeholder, textarea::placeholder { color: rgba(243,231,210,.35); }
input[type=checkbox], input[type=radio], input[type=range] { accent-color: var(--accent); }
textarea { resize: vertical; min-height: 66px; }
[aria-invalid="true"] { border-color: var(--alert) !important; }
.err { margin: 6px 0 0; font-size: 13px; color: var(--alert); }
.err:empty { display: none; }
.hint { color: rgba(243,231,210,.45); }
input.code { font-size: 22px; letter-spacing: .3em; text-align: center; }

/* ---------- cards ---------- */
.cards { list-style: none; margin: 22px 0 0; padding: 0; display: grid; gap: 14px; }
.card { min-width: 0; padding: 16px 18px 18px; border: 1px solid var(--line); border-radius: 12px; background: rgba(20,15,12,.72); transition: border-color .25s; }
.card:hover, .card:focus-within { border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-title { margin: 0; min-width: 0; font: 800 20px/1.2 var(--serif); }
.badge { flex: none; padding: 3px 8px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent); color: var(--accent);
  font: 500 11px/1.2 var(--sans); letter-spacing: .02em; white-space: nowrap; animation: badge-in .25s var(--ease-out) both; }
.badge.changed { border-color: rgba(243,231,210,.3); color: var(--paper-dim); }
.badge:empty { display: none; }

/* ---------- glass gate (PIN / password) ---------- */
.gate { min-height: 70vh; display: grid; place-items: center; }
.gate form { width: 100%; max-width: 360px; padding: 28px 26px 26px; border: 1px solid rgba(243,231,210,.14); border-radius: 16px;
  background: rgba(14,10,8,.6); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); animation: rise .6s var(--ease-out) both; }
.gate h1 { margin: 0 0 6px; font-size: 30px; line-height: 1.15; }
.gate p { margin: 0 0 4px; color: var(--paper-dim); font-size: 14px; }
.gate .btn { width: 100%; margin-top: 14px; }

/* ---------- tabs ---------- */
.tabs { position: relative; display: flex; gap: 22px; margin-top: 14px; border-bottom: 1px solid var(--line); }
.tab { appearance: none; -webkit-appearance: none; margin: 0; padding: 10px 0 11px; border: 0; background: none; color: var(--paper-dim); font: 500 15px/1.2 var(--sans); cursor: pointer; transition: color .2s; }
.tab:hover, .tab[aria-selected="true"] { color: var(--paper); }
.tab-ink { position: absolute; left: 0; bottom: -1px; width: 0; height: 2px; border-radius: 2px; background: var(--accent); }
.tab-ink.ready { transition: transform .32s var(--ease-out), width .32s var(--ease-out); }
.panel-in { animation: fade-in .25s ease-out both; }

/* ---------- save bar ---------- */
.savebar { position: sticky; bottom: 0; margin-top: 28px; display: flex; align-items: center; gap: 14px;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(to top, var(--ink) 75%, rgba(14,10,8,0)); }
.status { flex: 1; margin: 0; min-height: 1.6em; font-size: 14px; color: var(--paper-dim); overflow-wrap: anywhere; }
.status.ok { color: var(--accent); }
.status.error { color: var(--alert); }
@media (max-width: 480px) { .savebar { flex-direction: column-reverse; align-items: stretch; gap: 8px; } }

/* ---------- motion ---------- */
.rise { animation: rise .6s var(--ease-out) both; }
.shake { animation: shake .45s ease-in-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes tick-in { from { transform: scale(0) rotate(-45deg); } to { transform: none; } }
@keyframes badge-in { from { opacity: 0; transform: scale(.85); } }
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .ambient::before, .ambient::after, .ambient .spark { animation: none !important; }
  .ambient .spark { opacity: .35; transform: none; }
  .ambient .sketch path { animation: none !important; stroke-dashoffset: 0; }
  .btn.busy::before { animation: spin 2s linear infinite !important; }
}
