@font-face {
  font-family: "Inter";
  src: local("Inter"), local("Inter Regular");
  font-display: block;
  font-weight: 400 700;
  font-style: normal;
}

:root {
  --bg: #0f172a;
  --panel: #111827;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --border: #1f2937;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 20% 20%, rgba(56, 189, 248, 0.15), transparent 25%), var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
textarea, input, button {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 10px;
  background: #0b1220;
  color: var(--text);
}
textarea { min-height: 120px; }
button {
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  border: none;
  font-weight: 600;
  cursor: pointer;
}
button:hover { opacity: 0.9; }
select {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 10px;
  background: #0b1220;
  color: var(--text);
  appearance: none;
}
select:invalid { color: var(--muted); }
option { background: #0b1220; color: var(--text); }
option[disabled] { color: var(--muted); }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
}
.brand a { font-weight: 700; font-size: 18px; color: var(--text); }
.nav a { margin-left: 16px; color: var(--text); }

.content { padding: 32px; max-width: 1100px; margin: 0 auto; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,0.35); }
.panel-inner { margin-top: 16px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: rgba(15, 23, 42, 0.7); }
.panel-inner.mini { margin-top: 12px; }
.panel-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.panel-header h1, .panel-header h2 { margin: 0 0 6px 0; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.reader-grid { grid-template-columns: 320px 1fr; }
.column { display: flex; flex-direction: column; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack-inline { display: flex; gap: 10px; }

.card-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.card { padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: #0b1220; display: flex; justify-content: space-between; gap: 12px; }
.card.active { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5); }
.muted { color: var(--muted); margin: 4px 0; }
.tag { display: inline-block; padding: 4px 8px; border-radius: 999px; background: rgba(56, 189, 248, 0.12); color: var(--accent); font-size: 12px; margin-right: 6px; }
.meta { display: flex; gap: 10px; align-items: center; color: var(--muted); }
.spinner.inline { width: 16px; height: 16px; border-width: 2px; }
.thumb { margin: 8px 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #0b1220; }
.thumb img { display: block; width: 100%; max-height: 180px; object-fit: cover; }
.mini-text { font-size: 12px; }
.checkbox { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.mono { font-family: "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; background: #0b1220; padding: 10px; border-radius: 8px; }
.alert { border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.alert.error { background: rgba(248, 113, 113, 0.12); border: 1px solid #f87171; color: #fecdd3; }
.alert.error li { white-space: pre-wrap; word-break: break-word; }
.alert.success { background: rgba(34, 197, 94, 0.12); border: 1px solid #22c55e; color: #bbf7d0; }
.panel-inner.mini { margin-top: 8px; }
.reader-sidebar { position: sticky; top: 80px; align-self: start; }
.reader-draft { margin-top: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: #0b1220; }
.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
.htmx-request.spinner { display: inline-block; }

@keyframes spin {
  to { transform: rotate(360deg); }
}
.ghost-btn {
  width: auto;
  padding: 2px 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.prompt-layout { grid-template-columns: 280px 1fr; gap: 20px; }
.prompt-tiles { display: flex; flex-direction: column; gap: 12px; }
.prompt-tiles-header { display: flex; align-items: center; justify-content: space-between; }
.prompt-tiles-header h2 { margin: 0; }
.prompt-tile-list { display: flex; flex-direction: column; gap: 12px; }
.prompt-tile {
  text-align: left;
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-left: 3px solid transparent;
  padding: 12px 12px 12px 10px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.92), rgba(11, 18, 32, 0.98));
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.25);
}
.prompt-tile:hover { border-color: rgba(56, 189, 248, 0.6); }
.prompt-tile.active {
  border-color: var(--accent);
  border-left-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5), 0 14px 24px rgba(0, 0, 0, 0.3);
}
.prompt-tile.new { border-style: dashed; color: var(--muted); }
.prompt-tile .tile-title { font-weight: 600; }
.prompt-tile .tile-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.prompt-tile .tile-status { color: var(--muted); font-size: 11px; margin-top: 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.prompt-editor { display: flex; flex-direction: column; gap: 12px; }
.prompt-version { align-items: center; }

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .panel-header { flex-direction: column; }
  .stack-inline { flex-direction: column; }
  .reader-grid { grid-template-columns: 1fr; }
  .reader-sidebar { position: static; }
  .prompt-layout { grid-template-columns: 1fr; }
}

@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 500ms;
  animation-timing-function: ease-in-out;
}

::view-transition-old(root) {
  animation-name: fade-out;
}

::view-transition-new(root) {
  animation-name: fade-in;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 1ms;
  }
}
