/* ============================================================
   ASCII LAB — 字符艺术实验室
   复古终端 / CRT 美学  · 纯 CSS 无依赖
   ============================================================ */

:root {
  --bg: #05070a;
  --bg-soft: #0b0f16;
  --panel: #0e131c;
  --line: #1c2634;
  --ink: #d7e3ee;
  --dim: #6b7d90;
  --accent: #35ff9e;
  --accent-2: #1fb673;
  --glow: rgba(53, 255, 158, 0.55);
  --screen-fg: #35ff9e;
  --screen-bg: #030604;
  --font-mono: "SF Mono", "JetBrains Mono", "Fira Code", "Cascadia Code",
    "Consolas", "Menlo", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  /* Stop iOS/mobile browsers from auto-inflating text, which would
     break the monospace character grid of the ASCII screen. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-mono);
  background:
    radial-gradient(1200px 800px at 50% -10%, #0d1622 0%, var(--bg) 60%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  letter-spacing: 0.02em;
}

/* ---------- CRT overlays ---------- */
#scanlines {
  position: fixed; inset: 0; z-index: 9998; pointer-events: none;
  background: repeating-linear-gradient(
    to bottom, rgba(0,0,0,0) 0px, rgba(0,0,0,0) 2px,
    rgba(0,0,0,0.18) 3px, rgba(0,0,0,0.18) 4px);
  mix-blend-mode: multiply;
  animation: flicker 6s infinite steps(60);
}
#vignette {
  position: fixed; inset: 0; z-index: 9997; pointer-events: none;
  background: radial-gradient(120% 120% at 50% 50%,
    rgba(0,0,0,0) 55%, rgba(0,0,0,0.55) 100%);
}
@keyframes flicker {
  0%, 96%, 100% { opacity: 1; }
  97% { opacity: 0.82; }
  98% { opacity: 0.95; }
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 26px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  font-family: var(--font-mono);
  font-size: 20px; font-weight: 800; letter-spacing: 0.04em;
  color: var(--screen-bg);
  background: var(--accent);
  width: 46px; height: 46px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px;
  box-shadow: 0 0 18px var(--glow), inset 0 0 0 1px rgba(255,255,255,0.25);
  animation: logoPulse 3.2s ease-in-out infinite;
}
@keyframes logoPulse {
  0%, 100% { box-shadow: 0 0 12px var(--glow), inset 0 0 0 1px rgba(255,255,255,0.25); }
  50% { box-shadow: 0 0 26px var(--glow), inset 0 0 0 1px rgba(255,255,255,0.4); }
}
.brand-text h1 {
  font-size: 22px; font-weight: 700; letter-spacing: 0.18em;
  color: var(--ink);
}
.brand-text h1 em {
  font-style: normal; color: var(--accent);
  text-shadow: 0 0 12px var(--glow);
}
.tagline { font-size: 11px; color: var(--dim); margin-top: 2px; letter-spacing: 0.14em; }
.clock {
  font-size: 15px; color: var(--accent); letter-spacing: 0.2em;
  padding: 6px 14px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg-soft); text-shadow: 0 0 10px var(--glow);
}

/* ---------- Scene nav ---------- */
.scene-nav {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 12px 26px; border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}
.scene-tab {
  font-family: inherit; font-size: 12px; letter-spacing: 0.06em;
  color: var(--dim); background: transparent;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 15px; cursor: pointer;
  transition: all 0.18s ease;
}
.scene-tab:hover { color: var(--ink); border-color: var(--accent-2); }
.scene-tab.active {
  color: var(--screen-bg); background: var(--accent);
  border-color: var(--accent); font-weight: 700;
  box-shadow: 0 0 16px var(--glow);
}

/* ---------- Stage ---------- */
.stage {
  flex: 1; display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px; padding: 22px 26px;
  align-items: start;
}
.screen-wrap { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.bezel {
  background: linear-gradient(145deg, #10161f, #060a0f);
  border: 1px solid var(--line);
  border-radius: 14px; padding: 18px;
  box-shadow:
    inset 0 0 60px rgba(0,0,0,0.8),
    0 24px 60px rgba(0,0,0,0.5);
  position: relative; overflow: hidden;
}
.bezel::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 0%, rgba(53,255,158,0.06), transparent 60%);
}

.screen {
  display: block; width: 100%;
  background: var(--screen-bg);
  color: var(--screen-fg);
  font-family: var(--font-mono);
  font-size: 11px; line-height: 1.0;
  letter-spacing: 0; white-space: pre;
  overflow: hidden; border-radius: 8px;
  padding: 14px;
  min-height: 420px;
  text-shadow: 0 0 6px currentColor;
  transition: color 0.3s ease;
}
.screen.rainbow { text-shadow: 0 0 4px rgba(255,255,255,0.35); }

/* HUD */
.hud {
  display: flex; gap: 18px; flex-wrap: wrap;
  font-size: 11px; color: var(--dim);
  padding: 4px 6px; letter-spacing: 0.08em;
}
.hud-item b { color: var(--accent); font-weight: 700; }

/* ---------- Panel ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 16px; position: sticky; top: 22px;
  display: flex; flex-direction: column; gap: 16px;
}
.panel-title {
  font-size: 13px; letter-spacing: 0.24em; color: var(--dim);
  text-transform: uppercase; padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}
.ctl-group { display: flex; flex-direction: column; gap: 8px; }
.ctl-label {
  font-size: 11px; color: var(--dim); letter-spacing: 0.1em;
  display: flex; justify-content: space-between; align-items: center;
}
.ctl-label span { color: var(--accent); }

.btn-row { display: flex; gap: 8px; }
.btn-row.wrap { flex-wrap: wrap; }

.btn {
  flex: 1; font-family: inherit; font-size: 12px;
  color: var(--ink); background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: 7px;
  padding: 9px 8px; cursor: pointer; white-space: nowrap;
  transition: all 0.15s ease;
}
.btn:hover { border-color: var(--accent-2); color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn-accent {
  color: var(--screen-bg); background: var(--accent);
  border-color: var(--accent); font-weight: 700;
}
.btn-accent:hover { color: var(--screen-bg); filter: brightness(1.1); }

.chip {
  font-family: inherit; font-size: 11px; color: var(--dim);
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 11px; cursor: pointer;
  transition: all 0.15s ease;
}
.chip:hover { color: var(--ink); }
.chip.active {
  color: var(--screen-bg); background: var(--accent);
  border-color: var(--accent); font-weight: 700;
}

select, input[type="text"], input[type="file"] {
  font-family: inherit; font-size: 12px; color: var(--ink);
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 7px; padding: 9px 10px; width: 100%;
}
input[type="file"] { padding: 7px; color: var(--dim); }

/* range slider */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 4px;
  background: var(--line); outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 10px var(--glow);
  border: none; cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); border: none; cursor: pointer;
}

.hint { font-size: 10px; color: var(--dim); line-height: 1.5; }
.kbd-hint {
  font-size: 10px; color: var(--dim); line-height: 1.7;
  border-top: 1px dashed var(--line); padding-top: 12px;
}
kbd {
  font-family: inherit; font-size: 10px;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 6px; color: var(--accent);
  margin: 0 1px;
}

/* ---------- Footer ---------- */
.footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 26px; border-top: 1px solid var(--line);
  font-size: 11px; color: var(--dim); letter-spacing: 0.08em;
}
.sig .heart { color: var(--accent); text-shadow: 0 0 8px var(--glow); }

/* ---------- Themes ---------- */
body[data-theme="green"]  { --screen-fg: #35ff9e; --accent: #35ff9e; --glow: rgba(53,255,158,.55); }
body[data-theme="amber"]  { --screen-fg: #ffb64a; --accent: #ffb64a; --glow: rgba(255,182,74,.55); }
body[data-theme="ice"]    { --screen-fg: #58c6ff; --accent: #58c6ff; --glow: rgba(88,198,255,.55); }
body[data-theme="magma"]  { --screen-fg: #ff5a52; --accent: #ff7a52; --glow: rgba(255,90,82,.55); }
body[data-theme="mono"]   { --screen-fg: #eef3f8; --accent: #eef3f8; --glow: rgba(238,243,248,.4); }
body[data-theme="rainbow"]{ --screen-fg: #35ff9e; --accent: #ff5aa0; --glow: rgba(255,90,160,.5); }

/* ---------- Text Studio (主功能) ---------- */
.badge-main {
  font-size: 10px; letter-spacing: 0.1em; color: var(--screen-bg);
  background: var(--accent); border-radius: 999px; padding: 2px 9px;
  margin-left: 6px; vertical-align: middle; font-weight: 700;
  box-shadow: 0 0 12px var(--glow);
}
.text-input {
  font-family: var(--font-mono); font-size: 14px; line-height: 1.5;
  color: var(--ink); background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; width: 100%; resize: vertical; min-height: 84px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.text-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(53,255,158,0.15), 0 0 16px var(--glow);
}
.toggle {
  flex: 1; font-family: inherit; font-size: 12px; color: var(--dim);
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 7px; padding: 9px 8px; cursor: pointer;
  transition: all 0.15s ease;
}
.toggle:hover { color: var(--ink); }
.toggle.active {
  color: var(--screen-bg); background: var(--accent);
  border-color: var(--accent); font-weight: 700;
}

/* ---------- FX Drawer (次要: 创意特效) ---------- */
.fx-drawer {
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg-soft); overflow: hidden;
}
.fx-drawer > summary {
  list-style: none; cursor: pointer; user-select: none;
  padding: 12px 16px; font-size: 13px; letter-spacing: 0.08em;
  color: var(--ink); display: flex; align-items: center; gap: 10px;
}
.fx-drawer > summary::-webkit-details-marker { display: none; }
.fx-drawer > summary:hover { color: var(--accent); }
.fx-caret { color: var(--accent); transition: transform 0.2s ease; display: inline-block; }
.fx-drawer[open] .fx-caret { transform: rotate(90deg); }
.fx-sub { color: var(--dim); font-size: 11px; letter-spacing: 0.04em; }
.fx-body {
  padding: 4px 16px 16px; border-top: 1px dashed var(--line);
  display: flex; flex-direction: column; gap: 14px;
}
.fx-tabs { display: flex; gap: 7px; flex-wrap: wrap; padding-top: 12px; }
.fx-tab {
  font-family: inherit; font-size: 11px; letter-spacing: 0.04em;
  color: var(--dim); background: transparent;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; cursor: pointer; transition: all 0.15s ease;
}
.fx-tab:hover { color: var(--ink); border-color: var(--accent-2); }
.fx-tab.active {
  color: var(--screen-bg); background: var(--accent);
  border-color: var(--accent); font-weight: 700; box-shadow: 0 0 12px var(--glow);
}
.fx-controls {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.fx-controls .btn { flex: 0 0 auto; }
.mini-ctl {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 10px; color: var(--dim); min-width: 120px; flex: 1;
}
.mini-ctl span { color: var(--accent); }
.fx-extra { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .stage {
    grid-template-columns: 1fr;
    gap: 16px; padding: 16px;
  }
  .panel { position: static; }
  .screen { font-size: 10px; }
}

@media (max-width: 600px) {
  .topbar { padding: 12px 14px; gap: 10px; }
  .brand { gap: 10px; }
  .logo { width: 38px; height: 38px; font-size: 16px; border-radius: 10px; }
  .brand-text h1 { font-size: 17px; letter-spacing: 0.1em; }
  .tagline { font-size: 10px; }
  .clock { font-size: 12px; padding: 4px 9px; }
  .stage { padding: 12px; gap: 14px; }
  .bezel { padding: 10px; border-radius: 12px; }
  .screen {
    font-size: 9px; padding: 10px; min-height: 300px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  .panel { padding: 14px 12px; gap: 13px; }
  .footer { flex-direction: column; gap: 6px; text-align: center; padding: 16px; }
}

@media (max-width: 400px) {
  .screen { font-size: 8px; }
  .brand-text h1 { font-size: 15px; }
  .tagline { display: none; }
}

/* Fullscreen screen mode */
.screen:fullscreen {
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; padding: 30px;
}
