:root {
  --bg: #060807;
  --panel: #0d1210;
  --panel2: #111815;
  --border: rgba(90, 200, 120, 0.18);
  --green: #33ff33;
  --cyan: #33ccff;
  --dim: #5a7a63;
  --text: #b8d8c0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app-root { position: relative; min-height: 100vh; overflow-x: hidden; }

.bg-grid {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(51,255,51,0.06), transparent 60%),
    repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(51,255,51,0.03) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(51,255,51,0.03) 40px);
  pointer-events: none;
}

/* ---- top bar ---- */
.topbar {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(20,30,24,0.9), rgba(6,8,7,0.7));
}
.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.berry { font-size: 22px; filter: saturate(1.3); }
.brand-name {
  font-family: 'VT323', monospace; font-size: 30px; letter-spacing: 2px;
  color: var(--green); text-shadow: 0 0 10px rgba(51,255,51,0.5);
}
.brand-sub { color: var(--dim); font-size: 12px; letter-spacing: 2px; }
.cursor-blink { color: var(--green); animation: blink 1s steps(1) infinite; font-weight: 700; }
@keyframes blink { 50% { opacity: 0; } }

.power { display: flex; align-items: center; gap: 8px; }
.led {
  width: 11px; height: 11px; border-radius: 50%;
  background: #3a1a1a; border: 1px solid #602;
  box-shadow: inset 0 0 3px #000;
}
.led.on {
  background: #35ff5a; border-color: #2fa;
  box-shadow: 0 0 10px #35ff5a, 0 0 20px #35ff5a88;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.75; } }
.power-label { font-size: 11px; letter-spacing: 2px; color: var(--dim); }

/* ---- layout ---- */
.layout {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 1fr 380px;
  gap: 20px; padding: 20px; max-width: 1400px; margin: 0 auto;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

/* ---- CRT ---- */
.crt-wrap { display: flex; flex-direction: column; gap: 10px; }
.crt {
  position: relative;
  background: #020402;
  border-radius: 18px;
  padding: 22px;
  border: 14px solid #1a1e1a;
  box-shadow:
    inset 0 0 80px rgba(0,0,0,0.9),
    inset 0 0 30px rgba(51,255,51,0.05),
    0 0 40px rgba(0,0,0,0.8),
    0 10px 30px rgba(0,0,0,0.6);
  outline: none;
  min-height: 460px;
  cursor: text;
}
.crt.off { filter: brightness(0.85); }
.scanlines {
  position: absolute; inset: 14px; border-radius: 8px; pointer-events: none; z-index: 3;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.18), rgba(0,0,0,0.18) 1px, transparent 2px, transparent 3px);
  animation: flicker 0.15s infinite;
}
@keyframes flicker { 0% { opacity: 0.95; } 50% { opacity: 1; } 100% { opacity: 0.97; } }
.crt-screen {
  position: relative; z-index: 2;
  height: 420px; overflow-y: auto;
  font-family: 'VT323', 'IBM Plex Mono', monospace;
  font-size: 19px; line-height: 1.15; letter-spacing: 0.5px;
}
.crt-screen::-webkit-scrollbar { width: 8px; }
.crt-screen::-webkit-scrollbar-thumb { background: rgba(51,255,51,0.25); border-radius: 4px; }
.term-text { margin: 0; white-space: pre-wrap; word-break: break-word; }
.term-cursor { display: inline-block; width: 9px; height: 16px; animation: blink 1s steps(1) infinite; vertical-align: middle; }
.crt-idle { display: flex; align-items: center; justify-content: center; height: 100%; opacity: 0.8; }
.crt-idle pre { font-size: 13px; line-height: 1.1; text-align: left; text-shadow: 0 0 6px currentColor; }

.crt-controls { display: flex; align-items: center; gap: 14px; padding: 0 8px; }
.phos-toggle {
  background: #101a12; color: var(--green); border: 1px solid var(--border);
  padding: 5px 14px; border-radius: 6px; font-family: inherit; font-size: 12px;
  letter-spacing: 2px; cursor: pointer; transition: 0.15s;
}
.phos-toggle:hover { background: #16241a; box-shadow: 0 0 10px rgba(51,255,51,0.3); }
.crt-hint { color: var(--dim); font-size: 12px; }

/* ---- panel ---- */
.panel { display: flex; flex-direction: column; gap: 14px; }
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--border); border-radius: 12px; padding: 14px;
}
.card-title {
  font-size: 12px; letter-spacing: 3px; color: var(--green);
  margin-bottom: 10px; padding-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}
.note { font-size: 11px; color: var(--dim); line-height: 1.5; margin-top: 8px; }

/* file slots */
.file-slot {
  border: 1px dashed rgba(120,255,120,0.2); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 10px; cursor: pointer;
  transition: 0.15s; background: rgba(0,0,0,0.25);
}
.file-slot:hover { background: rgba(51,255,51,0.05); }
.file-slot.dragging { background: rgba(51,255,51,0.12); border-style: solid; }
.slot-label { font-size: 14px; color: var(--text); font-weight: 500; }
.slot-status { font-size: 10px; letter-spacing: 1px; }
.slot-sub { font-size: 11px; color: var(--dim); margin-top: 3px; }

/* drives */
.drives { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.drive-slot {
  background: rgba(0,0,0,0.3); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px;
}
.drive-face {
  position: relative; height: 46px; border-radius: 4px;
  background: linear-gradient(135deg, #2a2e2a, #141814);
  border: 1px solid #333; display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px;
}
.drive-face.inserted {
  background: linear-gradient(135deg, #1a3a22, #0e2415);
  border-color: rgba(51,255,51,0.4);
  box-shadow: inset 0 0 12px rgba(51,255,51,0.15);
}
.drive-label { font-family: 'VT323', monospace; font-size: 22px; color: var(--green); }
.drive-window { font-size: 20px; color: var(--cyan); text-shadow: 0 0 8px var(--cyan); }
.drive-info { display: flex; flex-direction: column; gap: 4px; }
.drive-name { font-size: 10px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drive-empty { font-size: 10px; color: var(--dim); }
.drive-btns { display: flex; gap: 4px; }
.mini-btn {
  flex: 1; background: #142018; color: var(--text); border: 1px solid var(--border);
  border-radius: 4px; padding: 3px 4px; font-family: inherit; font-size: 10px;
  cursor: pointer; transition: 0.12s;
}
.mini-btn:hover { background: #1c2c22; color: var(--green); }
.mini-btn.danger:hover { background: #2c1414; color: #ff6b6b; border-color: #611; }

/* machine controls */
.ctrl-row { display: flex; gap: 8px; margin-bottom: 12px; }
.boot-btn {
  flex: 1.4; background: linear-gradient(180deg, #1f5a2f, #123a1e);
  color: #d6ffe0; border: 1px solid #2fa84a; border-radius: 8px;
  padding: 10px; font-family: inherit; font-size: 14px; font-weight: 600;
  letter-spacing: 1px; cursor: pointer; transition: 0.15s;
  box-shadow: 0 0 14px rgba(51,255,51,0.25);
}
.boot-btn:hover { box-shadow: 0 0 22px rgba(51,255,51,0.5); transform: translateY(-1px); }
.boot-btn.disabled {
  opacity: 0.35; cursor: not-allowed; box-shadow: none;
  background: #1a1e1a; border-color: #333; color: #667;
}
.ctrl-btn {
  flex: 1; background: #141a16; color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 6px; font-family: inherit; font-size: 12px;
  cursor: pointer; transition: 0.12s;
}
.ctrl-btn:hover:not(:disabled) { background: #1c2620; color: var(--green); }
.ctrl-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.speed-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.speed-label { font-size: 11px; letter-spacing: 2px; color: var(--dim); }
.speed-slider { flex: 1; accent-color: var(--green); }
.speed-val { font-size: 11px; color: var(--green); min-width: 48px; text-align: right; }

/* registers */
.regs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  padding-top: 10px; border-top: 1px dashed var(--border);
}
.reg {
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(0,0,0,0.35); border-radius: 4px; padding: 4px 7px;
}
.reg-name { font-size: 10px; color: var(--dim); }
.reg-val { font-size: 12px; color: var(--cyan); }
.flags { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--dim); letter-spacing: 1px; margin-top: 2px; }
.flag {
  width: 18px; text-align: center; padding: 2px 0; border-radius: 3px;
  background: #141a16; color: #445; border: 1px solid #223;
}
.flag.on { background: #1f5a2f; color: #d6ffe0; border-color: #2fa84a; box-shadow: 0 0 6px rgba(51,255,51,0.4); }
.cyc { grid-column: 1 / -1; font-size: 10px; color: var(--dim); text-align: right; }

/* advanced */
.adv-toggle {
  width: 100%; text-align: left; background: none; border: none;
  color: var(--green); font-family: inherit; font-size: 12px; letter-spacing: 2px;
  cursor: pointer; padding: 0;
}
.adv-body { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.adv-label { font-size: 10px; color: var(--dim); }
.adv-input {
  background: #050805; border: 1px solid var(--border); border-radius: 4px;
  color: var(--cyan); font-family: inherit; padding: 6px 8px; font-size: 13px;
  letter-spacing: 2px; text-transform: uppercase;
}
.adv-input:focus { outline: none; border-color: var(--green); }

.tips { background: linear-gradient(180deg, #0a140e, #0d1a12); }

/* footer */
.foot {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  padding: 16px 22px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--dim);
}
.remix {
  color: var(--green); text-decoration: none; border: 1px solid var(--border);
  padding: 5px 12px; border-radius: 6px; letter-spacing: 1px; transition: 0.15s;
}
.remix:hover { background: rgba(51,255,51,0.08); box-shadow: 0 0 10px rgba(51,255,51,0.3); }