[data-theme="dark"] {
  --bg-color: #0c0d10;
  --term-bg: #121318;
  --header-bg: #1a1c23;
  --header-border: #2a2d38;
  --text-color: #33ff00;
  --text-dim: #1e9900;
  --accent: #00ffff;
  --error: #ff3366;
  --drawer-bg: #0e1015;
  --code-bg: #181a20;
  --scanline-opacity: 0.35;
  --shadow: rgba(0, 255, 255, 0.1);
}

[data-theme="light"] {
  --bg-color: #eee8d5;
  --term-bg: #fdf6e3;
  --header-bg: #e0d8c3;
  --header-border: #cb4b16;
  --text-color: #073642;
  --text-dim: #586e75;
  --accent: #d33682;
  --error: #dc322f;
  --drawer-bg: #f7f0dd;
  --code-bg: #ebdcb9;
  --scanline-opacity: 0.08;
  --shadow: rgba(0, 0, 0, 0.12);
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: 'Fira Code', 'Courier New', Courier, monospace;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  transition: background-color 0.3s, color 0.3s;
}

.accent { color: var(--accent); font-weight: bold; }
.error { color: var(--error); }

.terminal {
  width: 100%;
  max-width: 1100px;
  height: 82vh;
  background-color: var(--term-bg);
  border: 2px solid var(--header-border);
  border-radius: 8px;
  box-shadow: 0 10px 30px var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: all 0.3s ease;
}

.terminal-header {
  background-color: var(--header-bg);
  padding: 10px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--header-border);
}

.window-buttons { display: flex; gap: 8px; }
.btn { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.btn-close { background-color: #ff5f56; }
.btn-min { background-color: #ffbd2e; }
.btn-max { background-color: #27c93f; }
.window-title { font-size: 0.85rem; opacity: 0.85; }

.gui-nav { display: flex; gap: 12px; }
.gui-nav button {
  background: none; border: none; color: var(--accent);
  font-family: inherit; font-size: 0.85rem; cursor: pointer;
  text-decoration: underline; font-weight: bold;
}

.terminal-workspace { display: flex; flex-grow: 1; height: calc(100% - 40px); overflow: hidden; }
.terminal-body { padding: 20px; flex-grow: 1; overflow-y: auto; font-size: 0.95rem; }

.output-line { margin-bottom: 10px; white-space: pre-wrap; word-break: break-word; }
.prompt-line { display: flex; align-items: center; margin-top: 10px; }
.prompt-label { color: var(--accent); margin-right: 10px; white-space: nowrap; font-weight: bold; }

.command-input {
  background: transparent; border: none; color: var(--text-color);
  font-family: inherit; font-size: 0.95rem; flex-grow: 1; outline: none;
}

.scanlines {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%);
  background-size: 100% 4px; pointer-events: none; opacity: var(--scanline-opacity);
}

.reader-drawer {
  width: 0;
  background-color: var(--drawer-bg);
  border-left: 0px solid var(--header-border);
  overflow-y: auto;
  transition: width 0.3s ease, border-left 0.3s ease;
  display: flex;
  flex-direction: column;
}

.reader-drawer.open { width: 55%; border-left: 2px solid var(--header-border); padding: 20px; }
.drawer-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px dashed var(--header-border); padding-bottom: 10px; margin-bottom: 15px; }
.close-btn { background: none; border: none; color: var(--error); font-family: inherit; font-weight: bold; cursor: pointer; }

.preview-box { border: 1px solid var(--accent); padding: 15px; margin: 15px 0; background: var(--code-bg); cursor: pointer; }
.code-block { background: var(--code-bg); padding: 10px; border: 1px solid var(--header-border); margin-top: 10px; font-size: 0.85rem; }

.lightbox-overlay { display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0, 0, 0, 0.75); justify-content: center; align-items: center; z-index: 100; }
.lightbox-overlay.active { display: flex; }
.lightbox-modal { width: 90%; max-width: 700px; background: var(--term-bg); border: 2px solid var(--accent); box-shadow: 0 0 30px var(--shadow); border-radius: 6px; overflow: hidden; }
.lightbox-header { background: var(--header-bg); padding: 10px 15px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--header-border); }
.lightbox-body { padding: 25px; text-align: center; }

/* Content rendering */
.reader-drawer p { line-height: 1.65; margin: 0 0 12px; }
.reader-drawer h1, .reader-drawer h2, .reader-drawer h3 { line-height: 1.3; margin: 0 0 14px; }
.reader-drawer h2 { color: var(--accent); }
.reader-drawer h3 { margin-top: 18px; }
.reader-drawer ul { margin: 0 0 16px 22px; line-height: 1.6; }
.reader-drawer li { margin-bottom: 6px; }
.reader-drawer hr { border: 0; border-top: 1px dashed var(--header-border); margin: 18px 0; }
.reader-drawer code { background: var(--code-bg); padding: 2px 5px; }
.reader-drawer a { color: var(--accent); }
.md-spacer { height: 8px; }

.preview-box {
  width: 100%;
  color: var(--text-color);
  font-family: inherit;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.code-block {
  display: block;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.5;
  margin: 12px 0 18px;
}

.command-input:focus {
  outline: none;
  text-shadow: 0 0 5px var(--shadow);
}

@media (max-width: 800px) {
  body { padding: 0; align-items: stretch; }
  .terminal {
    height: 100vh;
    max-width: none;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  .terminal-header { flex-wrap: wrap; gap: 8px; }
  .gui-nav { gap: 8px; flex-wrap: wrap; }
  .terminal-body { padding: 14px; font-size: 0.86rem; }
  .reader-drawer.open {
    position: absolute;
    inset: 0;
    width: 100%;
    z-index: 20;
    border-left: 0;
    padding: 16px;
  }
  .banner { overflow-x: auto; }
}

@media (max-width: 480px) {
  .window-title { display: none; }
  .terminal-header { justify-content: space-between; }
  .gui-nav button { font-size: 0.78rem; }
  .prompt-line { align-items: flex-start; }
  .prompt-label { margin-right: 6px; }
}
