:root {
  --bg: #080b09;
  --panel: #0d120f;
  --row: #101713;
  --row-hover: #151f19;
  --row-active: #18261e;
  --border: rgba(215, 242, 226, 0.08);
  --border-hover: rgba(110, 231, 183, 0.28);
  --accent: #5eead4;
  --emerald: #34d399;
  --amber: #f59e0b;
  --text: #edf4f0;
  --muted: #8a9e93;
  --dim: #52635a;
  --sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
}

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

html, body {
  height: 100%;
}

body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(650px 280px at 20% 0%, rgba(52, 211, 153, 0.09), transparent 70%),
    radial-gradient(550px 240px at 80% 0%, rgba(245, 158, 11, 0.06), transparent 70%);
  z-index: 0;
}

/* ── Topbar ── */
.topbar {
  position: relative;
  z-index: 10;
  height: 58px;
  flex: 0 0 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 11, 9, 0.8);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  flex: 0 0 auto;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--emerald);
  background: linear-gradient(145deg, rgba(52, 211, 153, 0.14), rgba(52, 211, 153, 0.04));
  border: 1px solid rgba(52, 211, 153, 0.28);
  box-shadow: 0 4px 16px rgba(52, 211, 153, 0.12);
  flex: 0 0 auto;
}

.brand-copy {
  display: flex;
  align-items: baseline;
  gap: 9px;
  min-width: 0;
}

.brand-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
  color: var(--text);
  white-space: nowrap;
}

.brand-sep {
  color: var(--dim);
  font-weight: 400;
}

.brand-sub {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

/* ── Search ── */
.search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 260px;
  min-width: 140px;
  height: 34px;
  padding: 0 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  transition: border-color 0.15s ease, flex-basis 0.2s ease, box-shadow 0.15s ease;
}

.search:focus-within {
  flex-basis: 300px;
  border-color: var(--border-hover);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.09);
  color: var(--emerald);
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
}

.search input::placeholder {
  color: var(--dim);
}

.search kbd,
.statusbar kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  line-height: 1.3;
}

.btn-chip {
  cursor: pointer;
  height: 34px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.btn-chip svg {
  color: var(--muted);
}

.btn-chip:hover,
.btn-chip.active {
  border-color: var(--border-hover);
  background: var(--row-hover);
}

.btn-chip.active svg,
.btn-chip.copied {
  color: var(--emerald);
  border-color: rgba(52, 211, 153, 0.45);
}

/* ── Prompt panel ── */
.prompt-panel {
  position: relative;
  z-index: 9;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--border);
  background: #060907;
}

.prompt-panel[hidden] {
  display: none;
}

.prompt-inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 12px 24px 14px;
}

.prompt-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.prompt-tag {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--emerald);
}

.prompt-meta-actions {
  display: flex;
  gap: 6px;
}

.mini-btn {
  cursor: pointer;
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 9px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.mini-btn:hover {
  color: var(--text);
  border-color: var(--border-hover);
}

.prompt-panel pre {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  color: #cfe4d8;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 11px 13px;
  white-space: pre-wrap;
  max-height: 22vh;
  overflow: auto;
}

/* ── Center stage & directory ── */
.stage {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 20px 24px 12px;
}

.directory {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.dir-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.015);
}

.dir-cols {
  flex: 1;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--dim);
}

.col-right {
  display: none;
}

.dir-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
  font-variant-numeric: tabular-nums;
}

.dir-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  divide-y: 1px solid var(--border);
}

.dir-list::-webkit-scrollbar {
  width: 7px;
}

.dir-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
}

/* ── Row ── */
.row {
  cursor: pointer;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: transparent;
  transition: background 0.12s ease;
}

.row:hover,
.row.selected {
  background: var(--row-hover);
}

.row.selected {
  box-shadow: inset 2px 0 0 var(--emerald);
}

.row-idx {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.row:hover .row-idx,
.row.selected .row-idx {
  color: var(--emerald);
}

.row-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.row-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Reasoning tag ── */
.tag {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-radius: 999px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  white-space: nowrap;
  flex: 0 0 auto;
}

.reasoning-low {
  color: #9ca3af;
  border-color: rgba(156, 163, 175, 0.35);
  background: rgba(156, 163, 175, 0.08);
}

.reasoning-medium {
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.1);
}

.reasoning-high {
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(52, 211, 153, 0.1);
}

/* Fallback for custom levels (ultra, max, etc.) */
.reasoning-ultra,
.reasoning-max,
.reasoning-very-high,
.reasoning-extra-high {
  color: #c4b5fd;
  border-color: rgba(167, 139, 250, 0.45);
  background: rgba(167, 139, 250, 0.1);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-play {
  cursor: pointer;
  height: 30px;
  padding: 0 13px;
  border-radius: 7px;
  border: 1px solid rgba(52, 211, 153, 0.3);
  background: rgba(52, 211, 153, 0.1);
  color: #a7f3d0;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease, transform 0.12s ease;
}

.row:hover .btn-play,
.row.selected .btn-play {
  background: var(--emerald);
  border-color: var(--emerald);
  color: #042015;
}

.empty-state {
  padding: 56px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

/* ── Bottom statusbar ── */
.statusbar {
  position: relative;
  z-index: 1;
  flex: 0 0 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 11.5px;
  color: var(--dim);
  border-top: 1px solid var(--border);
  background: rgba(8, 11, 9, 0.7);
}

.statusbar .dot {
  opacity: 0.5;
}

/* ── Fullscreen Modal Player ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
}

.modal.open {
  display: block;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 5, 4, 0.86);
  backdrop-filter: blur(8px);
}

.modal-box {
  position: absolute;
  inset: 12px;
  background: #000;
  border: 1px solid var(--border-hover);
  border-radius: 13px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.8);
}

.modal-bar {
  height: 46px;
  flex: 0 0 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.modal-left {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  overflow: hidden;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 10px var(--emerald);
  flex: 0 0 auto;
}

.modal-index {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  flex: 0 0 auto;
}

.modal-left strong {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-controls {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ctrl-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 2px;
}

.ctrl-btn {
  cursor: pointer;
  height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--row);
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}

.ctrl-ico {
  font-size: 13px;
  line-height: 1;
}

.ctrl-btn:hover {
  border-color: var(--border-hover);
  background: var(--row-hover);
}

.ctrl-btn.copied {
  color: var(--emerald);
  border-color: rgba(52, 211, 153, 0.45);
}

.ctrl-btn.close:hover {
  border-color: rgba(248, 113, 113, 0.5);
  color: #fecaca;
}

.modal-box iframe {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  background: #000;
}

@media (max-width: 920px) {
  .brand-sep,
  .brand-sub {
    display: none;
  }
  .ctrl-txt {
    display: none;
  }
  .ctrl-btn {
    width: 30px;
    padding: 0;
  }
  .modal-bar {
    padding: 0 10px 0 12px;
    gap: 8px;
  }
}

@media (max-width: 680px) {
  .brand-sep,
  .brand-sub,
  .statusbar,
  #btn-copy-quick,
  .search kbd {
    display: none;
  }
  .topbar {
    padding: 0 12px;
    gap: 8px;
  }
  .brand {
    gap: 8px;
  }
  .brand-title {
    font-size: 14px;
  }
  .search,
  .search:focus-within {
    flex: 1 1 0;
    min-width: 90px;
    margin-left: 0;
  }
  .stage {
    padding: 12px;
  }
  .modal-box {
    inset: 0;
    border-radius: 0;
    border: 0;
  }
  .modal-index,
  .ctrl-sep {
    display: none;
  }
}
