/* opus48dev — interactive terminal. Anthropic palette, oldschool CRT vibe. */
:root {
  --orange: #d97757;
  --orange-soft: #e89478;
  --cream: #f5f0e8;
  --brown: #8b7355;
  --green: #6db877;
  --cyan: #7fb4c4;
  --red: #d96b5c;
  --yellow: #d9b85c;
  --bg: #141312;
  --bg-2: #1b1a18;
  --line: #322f2b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  background:
    radial-gradient(70% 45% at 50% 0%, rgba(217,119,87,0.12), transparent 70%),
    #0d0c0b;
  color: var(--cream);
  height: 100dvh;
  overflow: hidden;               /* page never scrolls */
  display: flex;
  flex-direction: column;
  font-size: 15px;
  line-height: 1.55;
}

/* CRT overlays */
.scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 9;
  background: repeating-linear-gradient(
    to bottom, rgba(0,0,0,0) 0px, rgba(0,0,0,0) 2px, rgba(0,0,0,0.16) 3px, rgba(0,0,0,0) 4px);
  mix-blend-mode: multiply;
}
.flicker {
  position: fixed; inset: 0; pointer-events: none; z-index: 8;
  background: rgba(217,119,87,0.015);
  animation: flick 6s infinite steps(60);
}
@keyframes flick { 0%,97%{opacity:.6} 98%{opacity:.2} 99%{opacity:.8} 100%{opacity:.5} }

/* ── TOPBAR (always visible) ─────────────────────────────────────── */
.topbar {
  flex: none; z-index: 5;
  background: linear-gradient(180deg, var(--bg-2), rgba(27,26,24,0.92));
  border-bottom: 1px solid var(--line);
  padding: 12px 20px 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "left right" "bar2 bar2";
  gap: 8px 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
}
.tb-left { grid-area: left; display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-bot { font-size: 20px; }
.tb-logo { height: 60px; width: auto; max-width: 76px; object-fit: contain; display: block; margin: -10px 0; }
.tb-brand { color: var(--orange); font-weight: 800; letter-spacing: 1px; white-space: nowrap; }
.tb-brand .dim { color: var(--brown); }
.tb-tag { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tb-right { grid-area: right; display: flex; align-items: center; gap: 10px; }
.tb-link {
  color: var(--cream); text-decoration: none; font-size: 13px;
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px;
  transition: border-color .2s, color .2s, background .2s, transform .1s;
}
.tb-link:hover { border-color: var(--orange); color: var(--orange); transform: translateY(-1px); }
.tb-buy { background: var(--orange); color: #141312; border-color: var(--orange); font-weight: 700; }
.tb-buy:hover { background: var(--orange-soft); color: #141312; }
.tb-sound {
  cursor: pointer; background: transparent; border: 0; padding: 6px;
  color: var(--brown); display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; transition: color .15s, background .15s;
}
.tb-sound:hover { color: var(--cream); background: rgba(245,240,232,0.06); }
.tb-sound.on { color: var(--orange); }
.tb-sound svg { display: block; }
.tb-level {
  font-size: 11px; font-weight: 700; letter-spacing: .5px; white-space: nowrap;
  color: var(--orange); border: 1px solid var(--orange); border-radius: 999px;
  padding: 2px 9px; background: rgba(217,119,87,0.10); text-shadow: 0 0 10px rgba(217,119,87,0.4);
}
.levelup { color: var(--orange); font-weight: 700; text-shadow: 0 0 16px rgba(217,119,87,0.6); }

.tb-bar2 {
  grid-area: bar2; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  border-top: 1px dashed var(--line); padding-top: 9px; margin-top: 2px;
}
.tb-ca { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.tb-ca code { color: var(--orange); word-break: break-all; }
.tb-copy {
  font: inherit; font-size: 11px; cursor: pointer;
  background: transparent; color: var(--brown);
  border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px;
  transition: all .15s;
}
.tb-copy:hover { color: var(--orange); border-color: var(--orange); }
.tb-copy.copied { color: var(--green); border-color: var(--green); }

.tb-stats { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--brown); flex-wrap: wrap; }
.tb-stats b { color: var(--cream); }
.tb-stats .sep { color: var(--line); }
.tb-stats .st.live { color: var(--green); }
.tb-stats .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 5px; box-shadow: 0 0 8px var(--green); animation: blink 1.6s steps(1) infinite; }
.tb-stats .st.live.off { color: var(--brown); }
.tb-stats .st.live.off .dot { background: var(--brown); box-shadow: none; animation: none; }

/* ── SCREEN (the only scroller) ──────────────────────────────────── */
.screen {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  padding: 18px 22px 28px;
  white-space: pre-wrap; word-break: break-word;
  outline: none;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.screen::-webkit-scrollbar { width: 9px; }
.screen::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }
.screen::selection, .screen *::selection { background: rgba(217,119,87,0.35); }

/* Lines */
.ln { white-space: pre-wrap; }
.ln.gap { height: .7em; }

.orange { color: var(--orange); }
.orange-b { color: var(--orange); font-weight: 700; text-shadow: 0 0 14px rgba(217,119,87,0.35); }
.cream { color: var(--cream); }
.brown { color: var(--brown); }
.green { color: var(--green); }
.cyan { color: var(--cyan); }
.red { color: var(--red); }
.yellow { color: var(--yellow); }
.dim { color: #6a625a; }
.italic { font-style: italic; }
.h { color: var(--orange); font-weight: 700; }

.banner { color: var(--orange); line-height: 1.05; text-shadow: 0 0 18px rgba(217,119,87,0.35); font-size: clamp(6.5px, 1.85vw, 15px); }

.prompt .user { color: var(--green); }
.prompt .path { color: var(--cyan); }
.prompt .sym { color: var(--cream); }

.row:hover { background: rgba(217,119,87,0.06); }

a.tlink { color: var(--orange); text-decoration: none; border-bottom: 1px dotted rgba(217,119,87,0.5); }
a.tlink:hover { color: var(--orange-soft); background: rgba(217,119,87,0.12); }

/* interactive prompt + ghost suggestion */
.inputline { white-space: pre-wrap; }
.cmdtext { color: var(--cream); white-space: pre-wrap; }
.ghost { color: #57514a; white-space: pre-wrap; }
.cursor {
  display: inline-block; width: 9px; height: 1.05em; background: var(--orange);
  vertical-align: -2px; margin-left: 1px;
  animation: blink 1s steps(1) infinite; box-shadow: 0 0 10px rgba(217,119,87,0.6);
}
@keyframes blink { 50% { opacity: 0; } }

/* hidden input that captures keystrokes (incl. mobile) */
.stdin-hidden {
  position: fixed; bottom: 0; left: 0; width: 1px; height: 1px;
  padding: 0; margin: 0; border: 0; opacity: 0; background: transparent;
  color: transparent; font-size: 16px; z-index: -1;
}

@media (max-width: 720px) {
  body { font-size: 13px; }
  .tb-tag { display: none; }
  .topbar { padding: 10px 12px 8px; }
  .tb-right .tb-link:not(.tb-buy) { padding: 5px 9px; }
  .screen { padding: 14px 12px 22px; }
}

/* ── ADMIN PANEL ─────────────────────────────────────────────────── */
body.admin { overflow: auto; display: block; padding: 0; }
.admin-wrap { max-width: 760px; margin: 0 auto; padding: 28px 20px 60px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; flex-wrap: wrap; }
.admin-head h1 { font-size: 20px; color: var(--orange); letter-spacing: 1px; }
.admin-head .bot { font-size: 22px; }
.admin-sub { color: var(--brown); font-size: 13px; margin-bottom: 22px; }
.admin-sub a { color: var(--orange); text-decoration: none; }

.admin-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; margin-bottom: 18px; box-shadow: 0 12px 40px rgba(0,0,0,0.35); }
.admin-card h2 { font-size: 13px; letter-spacing: 1.5px; color: var(--orange); text-transform: uppercase; margin-bottom: 16px; border-bottom: 1px dashed var(--line); padding-bottom: 10px; }

.field { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px 16px; padding: 10px 0; border-bottom: 1px solid rgba(50,47,43,0.5); }
.field:last-child { border-bottom: 0; }
.field .f-label { color: var(--cream); font-size: 14px; }
.field .f-help { color: var(--brown); font-size: 12px; grid-column: 1; }
.field .f-control { grid-row: 1 / span 2; grid-column: 2; justify-self: end; }

.field input[type="number"], .field input[type="text"], .field select {
  font: inherit; font-size: 14px;
  background: var(--bg); color: var(--cream);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  min-width: 160px; text-align: right;
}
.field input[type="text"] { text-align: left; min-width: 280px; max-width: 100%; }
.field input:focus, .field select:focus { outline: none; border-color: var(--orange); }
.field select { text-align: left; }

/* toggle */
.toggle { position: relative; display: inline-block; width: 52px; height: 28px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }
.toggle .slider { position: absolute; inset: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; transition: .2s; }
.toggle .slider::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: var(--brown); border-radius: 50%; transition: .2s; }
.toggle input:checked + .slider { background: var(--orange); border-color: var(--orange); }
.toggle input:checked + .slider::before { transform: translateX(24px); background: #141312; }

.admin-actions { position: sticky; bottom: 0; display: flex; align-items: center; gap: 14px; padding: 16px 0 6px; background: linear-gradient(0deg, var(--bg) 60%, transparent); }
.btn-save { font: inherit; font-weight: 700; cursor: pointer; background: var(--orange); color: #141312; border: 0; border-radius: 10px; padding: 12px 26px; transition: .15s; }
.btn-save:hover { background: var(--orange-soft); }
.btn-save:disabled { opacity: .5; cursor: default; }
.btn-ghost2 { font: inherit; cursor: pointer; background: transparent; color: var(--brown); border: 1px solid var(--line); border-radius: 10px; padding: 11px 18px; }
.btn-ghost2:hover { color: var(--orange); border-color: var(--orange); }
.save-msg { font-size: 13px; }
.save-msg.ok { color: var(--green); }
.save-msg.err { color: var(--red); }

/* operations card */
.ops-wallet { font-size: 14px; padding: 6px 0 14px; border-bottom: 1px solid rgba(50,47,43,0.5); word-break: break-all; }
.ops-sub { color: var(--orange); font-size: 12px; letter-spacing: 1px; text-transform: uppercase; margin: 16px 0 8px; }
.ops-open { display: flex; flex-direction: column; gap: 8px; }
.ops-row { display: flex; align-items: center; gap: 12px; }
.ops-row .btn-ghost2 { margin-left: auto; padding: 6px 14px; }
.ops-launch { display: flex; flex-wrap: wrap; gap: 8px; }
.ops-launch input { font: inherit; background: var(--bg); color: var(--cream); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }
.ops-launch #ml-name { flex: 2; min-width: 160px; }
.ops-launch #ml-ticker { width: 120px; }
.ops-launch #ml-img, .ops-launch #ml-desc { flex: 1; min-width: 200px; }
.ops-launch .btn-save { padding: 9px 18px; }

/* login overlay */
.login { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: rgba(13,12,11,0.96); }
.login-box { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 30px; width: min(380px, 92vw); text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.login-box .bot { font-size: 34px; }
.login-box h2 { color: var(--orange); margin: 10px 0 4px; letter-spacing: 1px; }
.login-box p { color: var(--brown); font-size: 13px; margin-bottom: 18px; }
.login-box input { font: inherit; width: 100%; background: var(--bg); color: var(--cream); border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; margin-bottom: 12px; }
.login-box input:focus { outline: none; border-color: var(--orange); }
.login-box .err { color: var(--red); font-size: 13px; min-height: 18px; margin-bottom: 8px; }
