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

:root {
  --bg: #0a0a0a;
  --fg: #c8c8c8;
  --fg-dim: #555;
  --fg-bright: #e8e8e8;
  --glow: rgba(255, 255, 255, 0.06);
  --border: #333;
}

[data-theme="light"] {
  --bg: #f5f5f5;
  --fg: #333;
  --fg-dim: #999;
  --fg-bright: #111;
  --glow: rgba(0, 0, 0, 0.04);
  --border: #ccc;
}

html {
  font-size: 16px;
}

@media (min-width: 900px) {
  html { font-size: 18px; }
  main#terminal { max-width: 720px; }
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", "Courier New", monospace;
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.4s, color 0.4s;
}

/* Menu toggle */
#menu-toggle {
  position: fixed;
  top: 1rem;
  right: 1.2rem;
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0.25;
  z-index: 100;
  user-select: none;
  transition: opacity 0.3s;
}

#menu-toggle:hover {
  opacity: 0.7;
}

/* Menu overlay */
#menu-overlay,
#confirm-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.3s;
}

#menu-overlay.hidden,
#confirm-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

#menu-panel,
#confirm-panel {
  text-align: center;
  line-height: 2.4;
}

#confirm-panel p {
  margin-bottom: 0.5rem;
  color: var(--fg-dim);
}

.confirm-buttons {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.menu-item {
  cursor: pointer;
  color: var(--fg-dim);
  transition: color 0.2s;
  user-select: none;
}

.menu-item:hover {
  color: var(--fg-bright);
}

.menu-parent {
  position: relative;
}

.menu-sub {
  margin-top: 0.3rem;
  text-align: center;
  line-height: 2;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}

.menu-sub.visible {
  max-height: 6rem;
  opacity: 1;
}

/* Glow overlay */
#glow-overlay {
  position: fixed;
  inset: 0;
  background: var(--glow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease-out;
  z-index: 50;
}

#glow-overlay.active {
  opacity: 1;
}

/* Terminal / main content */
main#terminal {
  max-width: 640px;
  margin: 0 auto;
  padding: 3rem 1.5rem 6rem;
}

/* Loading sequence */
.load-line {
  white-space: pre;
  color: var(--fg-dim);
  overflow: hidden;
}

.load-line .status {
  color: var(--fg);
}

/* Memory entries */
.memory-block {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  animation: fadeIn 0.6s ease;
}

.memory-block:first-of-type {
  border-top: none;
}

.memory-prompt {
  color: var(--fg-dim);
  margin-bottom: 1.5rem;
}

.memory-text {
  color: var(--fg-bright);
  margin-bottom: 1.5rem;
  line-height: 1.8;
}

.memory-timestamp {
  font-size: 0.75rem;
  color: var(--fg-dim);
  opacity: 0.5;
  margin-bottom: 0.5rem;
}

/* Buttons */
.memory-actions {
  display: flex;
  gap: 2rem;
  margin-top: 1rem;
}

.mem-btn {
  cursor: pointer;
  color: var(--fg-dim);
  border: none;
  background: none;
  font-family: inherit;
  font-size: inherit;
  padding: 0;
  transition: color 0.2s;
  user-select: none;
}

.mem-btn:hover {
  color: var(--fg-bright);
}

.mem-btn.chosen {
  pointer-events: none;
}

/* User response (right-aligned) */
.user-response {
  text-align: right;
  color: var(--fg-dim);
  margin-top: 1rem;
  font-size: 0.85rem;
  opacity: 0.6;
  animation: fadeIn 0.4s ease;
}

.user-response .response-timestamp {
  font-size: 0.7rem;
  display: block;
  margin-top: 0.2rem;
  opacity: 0.6;
}

/* Initial prompt */
.recall-prompt {
  margin-top: 3rem;
  animation: fadeIn 0.8s ease;
}

.recall-prompt .mem-btn {
  color: var(--fg);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Blinking cursor */
.cursor-blink::after {
  content: "\2588";
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* Responsive */
@media (max-width: 480px) {
  html { font-size: 13px; }
  main#terminal { padding: 2rem 1rem 4rem; }
  .memory-actions { gap: 1.5rem; }
}
