/* Reset + page */
* { box-sizing: border-box; }
html, body, #root { margin: 0; padding: 0; height: 100%; width: 100%; }
body {
  background: #0b0c10;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  color: #e4e4e7;
  overflow: hidden;
  /* Subtle radial to give the "desktop" some depth behind the terminal window */
  background:
    radial-gradient(ellipse at 30% 20%, #1a1b26 0%, #0a0b10 60%, #05060a 100%);
}

#root { display: flex; align-items: center; justify-content: center; padding: 24px; }

/* ─── Terminal window ──────────────────────────────────────── */
.terminal-root {
  width: min(1100px, 100%);
  height: min(720px, 100%);
  background: var(--bg);
  color: var(--fg);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.06),
    0 30px 80px rgba(0,0,0,0.55),
    0 8px 24px rgba(0,0,0,0.35);
  font-family: var(--font);
  font-size: var(--size);
  line-height: 1.55;
  transition: background 200ms ease, color 200ms ease;
}

/* Selection color per theme */
.terminal-root ::selection { background: var(--selection); }

/* ─── Window chrome ─────────────────────────────────────── */
.window-chrome {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: var(--chrome);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  user-select: none;
  gap: 12px;
}
.traffic-lights {
  display: flex;
  gap: 8px;
  align-items: center;
}
.tl {
  width: 12px; height: 12px; border-radius: 50%;
  display: inline-block;
  box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.25);
}
.tl-close { background: #ff5f57; }
.tl-min   { background: #febc2e; }
.tl-max   { background: #28c840; }

.window-title {
  flex: 1;
  text-align: center;
  font-family: var(--font);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.window-spacer { width: 52px; /* balance traffic-lights */ }

/* ─── Terminal body ─────────────────────────────────────── */
.term-body {
  flex: 1;
  padding: 18px 22px 22px;
  overflow-y: auto;
  overflow-x: hidden;
  font-family: var(--font);
  font-size: var(--size);
  color: var(--fg);
  cursor: text;
  scrollbar-width: thin;
  scrollbar-color: var(--muted) transparent;
}
.term-body::-webkit-scrollbar { width: 8px; }
.term-body::-webkit-scrollbar-track { background: transparent; }
.term-body::-webkit-scrollbar-thumb {
  background: color-mix(in oklab, var(--muted) 50%, transparent);
  border-radius: 4px;
}

/* ─── Line styles ───────────────────────────────────────── */
.line {
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 1.55em;
}
.line.muted, .muted { color: var(--muted); }
.line.accent, .accent { color: var(--accent); }
.line.error, .error { color: var(--error); }
.line.dir, .dir { color: var(--dir); }
.line.file-line { color: var(--fg); }
.user { color: var(--user); }
.host { color: var(--host); }
.fg { color: var(--fg); }

/* ls grid */
.ls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 2px 24px;
  margin: 2px 0;
}
.ls-grid span { white-space: nowrap; }
.ls-grid .dir { font-weight: 500; }

/* ─── Input line ────────────────────────────────────────── */
.input-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
}
.input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}
.term-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--size);
  line-height: inherit;
  padding: 0;
  caret-color: transparent;
}
.cursor-wrap {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
  white-space: pre;
  font-family: var(--font);
  font-size: var(--size);
  line-height: inherit;
}
.cursor-measure {
  visibility: hidden;
  white-space: pre;
}
.cursor {
  display: inline-block;
  width: 0.55em;
  height: 1.1em;
  background: var(--fg);
  vertical-align: text-bottom;
  animation: blink 1.05s steps(2, start) infinite;
  opacity: 0.85;
}
@keyframes blink { 50% { opacity: 0; } }

/* Hide cursor when window not focused (best-effort visual) */
body:not(:focus-within) .cursor { animation: none; opacity: 0.3; }

/* ─── Tweaks toggle button (floating) ───────────────────── */
.tweaks-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.12);
  color: #e4e4e7;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  transition: background 150ms ease, transform 150ms ease;
}
.tweaks-toggle:hover { background: rgba(255,255,255,0.14); transform: rotate(30deg); }

/* ─── Tweaks panel ──────────────────────────────────────── */
.tweaks-panel {
  position: fixed;
  top: 64px;
  right: 16px;
  width: 300px;
  background: rgba(18, 19, 26, 0.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 16px 18px 18px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.45);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  color: #e4e4e7;
  z-index: 99;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}
.tweaks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #a1a1aa;
  margin-bottom: 14px;
}
.tweaks-close {
  background: none;
  border: none;
  color: #71717a;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.tweaks-close:hover { color: #e4e4e7; }

.tweaks-section {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.tweaks-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.tweaks-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #a1a1aa;
  margin-bottom: 8px;
}
.tweaks-value { color: #71717a; text-transform: none; letter-spacing: 0; }

/* theme swatches */
.tweaks-swatches {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.swatch {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  text-align: left;
  color: #e4e4e7;
  transition: border 120ms ease, background 120ms ease;
}
.swatch:hover { background: rgba(255,255,255,0.06); }
.swatch.active {
  border-color: rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.08);
}
.swatch-row {
  display: flex;
  gap: 3px;
  margin-bottom: 6px;
}
.swatch-chip {
  width: 100%;
  height: 18px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.08);
}
.swatch-name { font-size: 11px; color: #d4d4d8; }

/* select */
.tweaks-select {
  width: 100%;
  padding: 7px 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  color: #e4e4e7;
  font-family: inherit;
  font-size: 12px;
  outline: none;
}
.tweaks-select:focus { border-color: rgba(255,255,255,0.2); }

/* range */
.tweaks-range {
  width: 100%;
  accent-color: #a1a1aa;
}

/* prompt pills */
.tweaks-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pill {
  padding: 5px 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  color: #d4d4d8;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  cursor: pointer;
  transition: background 120ms ease, border 120ms ease;
}
.pill:hover { background: rgba(255,255,255,0.08); }
.pill.active {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.3);
  color: #fff;
}

/* checkbox row */
.tweaks-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  cursor: pointer;
  color: #d4d4d8;
}
.tweaks-toggle-row input { accent-color: #a1a1aa; }

/* ─── Pager (less) ───────────────────────────────────────── */
.pager {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.pager-content {
  flex: 1;
  margin: 0;
  padding: 18px 22px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font);
  font-size: var(--size);
  color: var(--fg);
  line-height: 1.55;
}
.pager-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 16px;
  background: color-mix(in oklab, var(--fg) 85%, transparent);
  color: var(--bg);
  font-size: calc(var(--size) - 1px);
  letter-spacing: 0.02em;
}
.pager-title::before { content: ':'; opacity: 0.7; margin-right: 4px; }
.pager-title { font-weight: 500; }
.pager-hint b { font-weight: 700; }

/* make body position:relative so pager can absolute-fill it */
.term-body { position: relative; }

/* ─── Whoami ────────────────────────────────────────────── */
.whoami {
  display: flex;
  gap: 22px;
  align-items: flex-start;
  padding: 8px 0 14px;
}
.whoami-avatar-wrap {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.whoami-avatar {
  width: 140px;
  height: 140px;
  border-radius: 8px;
  border: 1px solid color-mix(in oklab, var(--fg) 20%, transparent);
  display: block;
  image-rendering: auto;
}
.whoami-colorbar {
  display: flex;
  gap: 3px;
  height: 14px;
}
.whoami-colorbar span {
  flex: 1;
  border-radius: 2px;
}
.whoami-colorbar span:nth-child(1) { background: var(--error); }
.whoami-colorbar span:nth-child(2) { background: var(--accent); }
.whoami-colorbar span:nth-child(3) { background: var(--user); }
.whoami-colorbar span:nth-child(4) { background: var(--dir); }
.whoami-colorbar span:nth-child(5) { background: var(--host); }
.whoami-colorbar span:nth-child(6) { background: var(--muted); }
.whoami-info {
  flex: 1;
  min-width: 0;
  font-family: var(--font);
  font-size: var(--size);
  line-height: 1.55;
}
.whoami-head { margin-bottom: 2px; font-weight: 700; }
.whoami-sep { color: var(--muted); margin-bottom: 4px; }
.whoami-row { display: flex; gap: 8px; }
.whoami-key {
  min-width: 90px;
  font-weight: 500;
}

@media (max-width: 560px) {
  .whoami { flex-direction: column; gap: 12px; }
  .whoami-avatar { width: 110px; height: 110px; }
}

/* Responsive */
@media (max-width: 720px) {
  #root { padding: 0; }
  .terminal-root {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }
  .tweaks-panel {
    width: calc(100% - 32px);
    right: 16px;
  }
  .ls-grid { grid-template-columns: repeat(2, 1fr); }
}
