/* glitch.daemons.art: phone first, dark only. Tablet and desktop layouts at the end. */
@font-face { font-family: "DAEMONS Display"; src: url("/fonts/heading.ttf") format("truetype"); font-display: swap; }
:root {
  color-scheme: dark;
  --bg: #090b0a;
  --bg2: #0f1210;
  --card: #151916;
  --card2: #1c211d;
  --line: #262d27;
  --line2: #3a443b;
  --ink: #f1f5ee;
  --mute: #a3ad9f;
  --lime: #c3ff5c;
  --lime-ink: #0d1406;
  --lime-soft: #c3ff5c1f;
  --coral: #ff7a5c;
  --lav: #b9a6ff;
  --cyan: #4df3ff;
  --r: 14px;
  --pad: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "DAEMONS Display", ui-sans-serif, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); height: 100%; }
body { margin: 0; height: 100%; color: var(--ink); font: 15px/1.4 var(--font); background: var(--bg); overflow: hidden; overscroll-behavior: none; }
.defs { position: absolute; }
svg { width: 20px; height: 20px; flex: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--lav); outline-offset: 2px; }
a { color: var(--lime); }
h1, h2, h3, p { margin: 0; }

/* ---------- Shell ---------- */
.app {
  height: 100%; height: 100dvh;
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  background:
    radial-gradient(120% 60% at 50% 38%, #c3ff5c10, transparent 60%),
    linear-gradient(180deg, #0b0e0c, var(--bg) 40%);
}
.top { display: flex; align-items: center; gap: 10px; padding: 8px var(--pad) 4px; min-height: 52px; }
.brand { text-decoration: none; color: var(--ink); line-height: 1; }
.word { position: relative; display: inline-block; font: 700 27px/1 var(--display); letter-spacing: .06em; }
.word::before, .word::after { content: attr(data-text); position: absolute; inset: 0; mix-blend-mode: screen; pointer-events: none; }
.word::before { color: var(--coral); transform: translate(-1.5px, 0); opacity: .8; clip-path: inset(0 0 55% 0); animation: tearA 3.2s steps(1) infinite; }
.word::after { color: var(--cyan); transform: translate(1.5px, 0); opacity: .8; clip-path: inset(55% 0 0 0); animation: tearB 2.7s steps(1) infinite; }
@keyframes tearA { 0%, 86%, 100% { transform: translate(-1.5px, 0); } 88% { transform: translate(-5px, 0); } 92% { transform: translate(2px, 0); } }
@keyframes tearB { 0%, 78%, 100% { transform: translate(1.5px, 0); } 80% { transform: translate(6px, 0); } 84% { transform: translate(-2px, 0); } }
.by { color: var(--mute); font-size: 12px; text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; margin-top: 4px; }
.by:hover { color: var(--lime); }
.chip { display: inline-flex; align-items: center; gap: 7px; height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line2); background: var(--card); font-size: 14px; font-weight: 600; }
.wallet { margin-left: auto; max-width: 48vw; }
.wallet span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wallet.on { border-color: #c3ff5c55; color: var(--lime); }

.bar { display: flex; align-items: center; gap: 8px; padding: 2px var(--pad) 6px; min-width: 0; }
.pick { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 10px 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); min-width: 0; max-width: 100%; }
.pick-id { font: 600 13px var(--mono); color: var(--lime); }
.pick-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pick svg { color: var(--mute); width: 18px; height: 18px; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; border: 1px solid var(--line2); color: var(--mute); margin-left: auto; }
.pill svg { width: 16px; height: 16px; }
.pill.sigil { color: var(--lime); border-color: #c3ff5c55; background: var(--lime-soft); }
.pill.grave { color: var(--coral); border-color: #ff7a5c55; background: #ff7a5c14; }
.pill.lav { color: var(--lav); border-color: #b9a6ff55; }

/* ---------- Stage ---------- */
.stage { position: relative; min-height: 0; display: grid; place-items: center; padding: 4px var(--pad); }
.frame {
  position: relative; aspect-ratio: 1; height: 100%; max-height: 100%; max-width: 100%;
  border-radius: 18px; overflow: hidden; background: #050508; border: 1px solid var(--line);
  box-shadow: 0 0 0 1px #000, 0 20px 60px -20px #c3ff5c33;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
@supports not (aspect-ratio: 1) { .frame { width: min(100%, 60vh); height: auto; } }
.frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; }
#ghost { opacity: 0; pointer-events: none; }
.frame.flick #ghost { animation: flick 220ms var(--ease); }
@keyframes flick { 0% { opacity: .9; transform: translateX(-3%); } 40% { opacity: .6; transform: translateX(2%); } 100% { opacity: 0; transform: none; } }
.scan {
  position: absolute; inset: -10% 0; pointer-events: none; opacity: .5;
  background: repeating-linear-gradient(0deg, transparent 0 3px, #00000038 3px 4px);
  animation: scan 6s linear infinite;
}
@keyframes scan { from { transform: translateY(0); } to { transform: translateY(8%); } }
.frame.comparing .scan { opacity: 0; }
.skeleton { position: absolute; inset: 0; background: linear-gradient(100deg, #101411 30%, #1a201b 50%, #101411 70%); background-size: 300% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -200% 0; } }
.tag { position: absolute; font: 600 12px var(--mono); letter-spacing: .04em; color: #e9f2e2; background: #000000a8; padding: 5px 8px; border-radius: 8px; pointer-events: none; transition: opacity .2s var(--ease); }
.tl { top: 10px; left: 10px; color: var(--mute); }
.bl { bottom: 10px; left: 10px; }
.br { bottom: 10px; right: 10px; color: var(--lime); }
.frame.comparing .tl { color: var(--lime); }
.hint { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: #000000d0; color: var(--ink); padding: 10px 14px; border-radius: 12px; font-size: 14px; font-weight: 600; white-space: nowrap; animation: fadeInOut 3s var(--ease) forwards; pointer-events: none; }
@keyframes fadeInOut { 0% { opacity: 0; } 12%, 80% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- Panel (phone: bottom toolbar) ---------- */
.panel { padding: 6px var(--pad) calc(10px + env(safe-area-inset-bottom)); display: grid; gap: 8px; }
.panel-title, .program-line, .keys, .desk-history { display: none; }
.programs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.prog {
  display: grid; justify-items: center; gap: 3px; min-height: 56px; padding: 7px 2px 6px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--mute); font-size: 12px; font-weight: 700; letter-spacing: .01em;
  transition: transform .15s var(--ease), background-color .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.prog svg { width: 22px; height: 22px; }
.prog span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.prog:active { transform: scale(.96); }
.prog[aria-selected="true"] { color: var(--ink); border-color: #c3ff5c66; background: linear-gradient(180deg, #c3ff5c1c, #c3ff5c08); }
.prog[aria-selected="true"] svg { color: var(--lime); }
.prog .desc { display: none; }
.row { display: flex; align-items: center; gap: 6px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); padding: 3px; gap: 3px; }
.seg button { min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--mute); font-weight: 700; font-size: 13px; transition: background-color .15s var(--ease), color .15s var(--ease); }
.seg button[aria-checked="true"] { background: var(--card2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line2); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); font-size: 13px; font-weight: 700; transition: transform .15s var(--ease); }
.icon-btn:active { transform: scale(.95); }
.icon-btn span { display: none; }
.action { display: flex; gap: 8px; }
.primary {
  flex: 1; min-width: 0; min-height: 54px; display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  border: 0; border-radius: 16px; background: var(--lime); color: var(--lime-ink); font-size: 16px; font-weight: 800; letter-spacing: .01em;
  box-shadow: 0 10px 30px -12px #c3ff5c99; transition: transform .15s var(--ease), filter .15s var(--ease), opacity .15s var(--ease);
}
.primary span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.primary:active { transform: scale(.98); }
.primary.quiet { background: var(--card2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line2); }
.primary.grave { background: #2a1813; color: var(--coral); box-shadow: inset 0 0 0 1px #ff7a5c55; }
.primary:disabled { opacity: .55; }
.square { width: 54px; min-height: 54px; border-radius: 16px; border: 1px solid var(--line2); background: var(--card); display: grid; place-items: center; }
.note { font-size: 12px; color: var(--mute); text-align: center; min-height: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note b { color: var(--ink); font-weight: 700; }
.note .ok { color: var(--lime); }
.note .warn { color: var(--coral); }

/* ---------- Sheets ---------- */
.scrim { position: fixed; inset: 0; background: #000000a6; z-index: 40; animation: fade .2s var(--ease); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; max-height: min(88dvh, 720px); display: flex; flex-direction: column;
  background: var(--bg2); border: 1px solid var(--line2); border-bottom: 0; border-radius: 22px 22px 0 0;
  padding: 0 0 env(safe-area-inset-bottom); animation: up .22s var(--ease);
}
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line2); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px 4px 18px; }
.sheet-head h2 { font: 700 22px/1.1 var(--display); letter-spacing: .03em; flex: 1; }
.icon-only { width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; display: grid; place-items: center; color: var(--mute); }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 4px 18px 18px; display: grid; gap: 12px; -webkit-overflow-scrolling: touch; }
.sheet-body p { color: var(--mute); font-size: 14px; }
.sheet-body .big { min-height: 54px; }
.btn { min-height: 48px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--line2); background: var(--card); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--ink); font-size: 15px; }
.btn.lime { background: var(--lime); color: var(--lime-ink); border: 0; }
.btn.block { width: 100%; }
.btn img { width: 24px; height: 24px; border-radius: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.daemons { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.dm { position: relative; border: 1px solid var(--line); border-radius: 12px; background: #050508; padding: 0; aspect-ratio: 1; overflow: hidden; }
.dm img, .dm canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.dm .n { position: absolute; left: 4px; bottom: 4px; font: 600 12px var(--mono); background: #000000b0; padding: 2px 5px; border-radius: 6px; }
.dm .s { position: absolute; right: 4px; top: 4px; color: var(--lime); background: #000000b0; border-radius: 6px; padding: 2px; display: grid; }
.dm .s svg { width: 16px; height: 16px; }
.dm[aria-current="true"] { border-color: var(--lime); }
.search { display: flex; gap: 8px; }
.search input { flex: 1; min-width: 0; height: 48px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line2); background: var(--bg); font: 600 16px var(--mono); }
.label { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.compare { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.compare canvas { width: 100%; aspect-ratio: 1; image-rendering: pixelated; border-radius: 12px; border: 1px solid var(--line); background: #050508; }
.compare svg { color: var(--lime); }
.facts { display: grid; gap: 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.facts div { display: flex; justify-content: space-between; gap: 10px; padding: 11px 14px; font-size: 14px; border-top: 1px solid var(--line); }
.facts div:first-child { border-top: 0; }
.facts dt, .facts span:first-child { color: var(--mute); }
.facts b { font-family: var(--mono); font-weight: 700; text-align: right; }
.facts .ok { color: var(--lime); }
.facts .warn { color: var(--coral); }
.steps { display: grid; gap: 8px; }
.step { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--mute); }
.step i { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line2); display: grid; place-items: center; flex: none; }
.step i svg { width: 14px; height: 14px; }
.step.now { color: var(--ink); }
.step.now i { border-color: var(--lime); border-top-color: transparent; animation: spin .8s linear infinite; }
.step.done { color: var(--ink); }
.step.done i { border-color: var(--lime); background: var(--lime); color: var(--lime-ink); }
@keyframes spin { to { transform: rotate(360deg); } }
.verified { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--lime-soft); border: 1px solid #c3ff5c55; color: var(--lime); font-weight: 700; font-size: 14px; }
.err { padding: 12px 14px; border-radius: 14px; background: #ff7a5c14; border: 1px solid #ff7a5c55; color: #ffb3a1; font-size: 14px; }
.sigil-art { width: 140px; height: 140px; margin: 0 auto; border-radius: 16px; overflow: hidden; border: 1px solid var(--line2); background: #090b0a; display: grid; place-items: center; }
.sigil-art img { width: 100%; height: 100%; image-rendering: pixelated; }
.versions { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 8px; }
.ver { display: grid; gap: 4px; text-decoration: none; color: var(--mute); font: 600 12px var(--mono); }
.ver canvas { width: 100%; aspect-ratio: 1; image-rendering: pixelated; border-radius: 10px; border: 1px solid var(--line); background: #050508; }
.ver.cur canvas { border-color: var(--lime); }
.empty { color: var(--mute); font-size: 14px; padding: 8px 0; }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; background: #1d241e; border: 1px solid var(--line2); color: var(--ink); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; max-width: calc(100vw - 32px); animation: up .2s var(--ease); }

/* ---------- Small phones ---------- */
@media (max-width: 359px) {
  :root { --pad: 10px; }
  .word { font-size: 23px; }
  .by { display: none; }
  .prog { font-size: 12px; min-height: 52px; }
  .prog span { font-size: 11.5px; letter-spacing: -.01em; }
  .primary { font-size: 15px; }
}
@media (max-height: 620px) and (orientation: portrait) {
  .note { display: none; }
  .prog { min-height: 48px; padding: 5px 2px; }
  .prog svg { width: 20px; height: 20px; }
  .primary, .square { min-height: 50px; }
}

/* ---------- Phone landscape and tablet/desktop: side panel ---------- */
@media (orientation: landscape) and (max-height: 560px) {
  .app { grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); grid-template-rows: auto auto minmax(0, 1fr); padding-bottom: env(safe-area-inset-bottom); }
  .top { grid-column: 1 / -1; min-height: 46px; padding-top: 4px; }
  .bar { grid-column: 2; grid-row: 2; padding-top: 0; }
  .stage { grid-column: 1; grid-row: 2 / 4; padding-bottom: 10px; }
  .panel { grid-column: 2; grid-row: 3; align-content: end; overflow-y: auto; padding-bottom: 10px; }
  .note { display: none; }
}
@media (min-width: 768px) and (min-height: 561px) {
  :root { --pad: 20px; }
  .app { grid-template-columns: minmax(0, 1fr) clamp(320px, 34vw, 420px); grid-template-rows: auto auto minmax(0, 1fr); column-gap: 8px; }
  .top { grid-column: 1 / -1; padding-top: 14px; min-height: 64px; }
  .word { font-size: 32px; }
  .stage { grid-column: 1; grid-row: 2 / 4; padding: 10px 10px 24px 24px; }
  .bar { grid-column: 2; grid-row: 2; padding: 6px 20px 4px 0; }
  .panel {
    grid-column: 2; grid-row: 3; align-content: start; gap: 12px; overflow-y: auto; margin: 6px 20px 20px 0; padding: 16px;
    border: 1px solid var(--line); border-radius: 20px; background: #0f1210d9;
  }
  .panel-title { display: block; font: 700 14px var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
  .programs { grid-template-columns: 1fr 1fr; gap: 8px; }
  .prog { justify-items: start; text-align: left; padding: 12px; gap: 6px; min-height: 0; grid-template-columns: auto 1fr; align-items: center; column-gap: 10px; }
  .prog span { font-size: 14px; }
  .program-line { display: block; color: var(--mute); font-size: 14px; min-height: 20px; }
  .icon-btn span { display: inline; }
  .desk-history { display: grid; gap: 8px; }
  .desk-history h3 { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
  .desk-history .versions { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); }
  #historyBtn { display: none; }
  .keys { display: block; font-size: 12px; color: var(--mute); text-align: center; }
  .sheet { left: 50%; right: auto; bottom: 50%; width: min(480px, calc(100vw - 40px)); transform: translate(-50%, 50%); border-radius: 22px; border-bottom: 1px solid var(--line2); animation: pop .2s var(--ease); }
  @keyframes pop { from { opacity: 0; transform: translate(-50%, 50%) scale(.97); } to { opacity: 1; transform: translate(-50%, 50%); } }
  .grab { display: none; }
  .sheet-head { padding-top: 14px; }
  .toast { bottom: 28px; }
}
@media (min-width: 1280px) {
  .prog { grid-template-columns: auto 1fr; }
  .prog .desc { display: block; grid-column: 1 / -1; font-size: 12px; font-weight: 500; color: var(--mute); white-space: normal; }
}
@media (hover: hover) {
  .prog:hover, .icon-btn:hover, .chip:hover, .pick:hover, .btn:hover { border-color: var(--line2); background-color: var(--card2); }
  .primary:hover { filter: brightness(1.05); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .word::before, .word::after { animation: none; }
  .scan { animation: none; }
  .frame.flick #ghost { animation: fadeOnly .2s linear; }
  @keyframes fadeOnly { from { opacity: .5; } to { opacity: 0; } }
  .sheet, .toast, .scrim { animation: fade .15s linear !important; animation-duration: .15s !important; }
  .step.now i { animation: none; border-top-color: var(--lime); }
  .skeleton { animation: none; }
}
@media (display-mode: standalone) {
  .top { padding-top: max(8px, env(safe-area-inset-top)); }
}
