* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

:root {
  --bg: #090b10;
  --panel: #11151d;
  --panel-2: #171d28;
  --line: #283141;
  --text: #eef2f7;
  --muted: #97a4b5;
  --accent: #f0c75e;
  --accent-2: #f5e39a;
  --danger: #d94b57;
  --ok: #80cdbf;
  --shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
}

html,
body {
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  background:
    radial-gradient(circle at top left, rgba(128, 205, 191, 0.10), transparent 25rem),
    radial-gradient(circle at top right, rgba(240, 199, 94, 0.10), transparent 28rem),
    linear-gradient(180deg, #090b10 0%, #0f141d 100%);
  color: var(--text);
  touch-action: pan-y;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}

.shell {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 16px clamp(8px, 2vw, 18px) 72px;
}

.topbar,
.panel {
  background: rgba(17, 21, 29, 0.94);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  min-width: 0;
}

.topbar {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 16px;
}

.eyebrow,
.session-label,
label span,
.status-pill {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-family: "Courier New", Courier, monospace;
  font-size: 0.76rem;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.4rem, 7vw, 4.5rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(1.45rem, 4vw, 2.1rem);
  line-height: 1.05;
}

.muted,
.status-line,
.generation-meta,
.prompt-preview,
.log-tail {
  color: var(--muted);
}

.session-box {
  min-width: min(260px, 100%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.creator-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.85fr);
  gap: 16px;
  min-width: 0;
}

.panel {
  border-radius: 18px;
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0c1017;
  color: var(--text);
  font: 16px/1.42 Georgia, "Times New Roman", serif;
  padding: 12px 13px;
  -webkit-appearance: none;
  appearance: none;
}

textarea {
  resize: vertical;
  min-height: 230px;
}

input:focus,
textarea:focus {
  outline: 2px solid rgba(240, 199, 94, 0.32);
  border-color: var(--accent);
}

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

button,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #16120a;
  padding: 10px 16px;
  font: 700 16px/1 Georgia, "Times New Roman", serif;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

button[disabled] {
  opacity: 0.56;
  cursor: wait;
}

.secondary-button,
.secondary-link {
  background: #2b3442;
  color: var(--text);
}

.compact {
  min-width: 44px;
  padding: 8px 13px;
}

.status-line {
  min-height: 22px;
  font-size: 0.95rem;
}

.status-line a {
  color: var(--accent-2);
}

.generation-list {
  display: grid;
  gap: 12px;
}

.history-status {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(151, 164, 181, 0.24);
  border-radius: 12px;
  background: rgba(12, 16, 23, 0.62);
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.3;
}

.history-status.is-active {
  border-color: rgba(240, 199, 94, 0.46);
  color: var(--accent-2);
}

.generation-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(23, 29, 40, 0.86);
  padding: 13px;
  min-width: 0;
  overflow: hidden;
}

.generation-card.is-running {
  border-color: rgba(240, 199, 94, 0.48);
}

.generation-title {
  margin: 0 0 6px;
  font-size: 1.12rem;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.generation-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.78rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.status-pill {
  display: inline-flex;
  width: max-content;
  margin: 8px 0;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: #222a36;
}

.status-pill.done { color: #10201d; background: var(--ok); }
.status-pill.failed { color: #fff; background: var(--danger); }
.status-pill.drafting,
.status-pill.running,
.status-pill.queued { color: #16120a; background: var(--accent); }

.render-note {
  margin: 6px 0 10px;
  color: var(--accent-2);
  font-weight: 700;
  line-height: 1.3;
}

.cost-note {
  margin: -2px 0 10px;
  color: var(--muted);
  font: 700 0.78rem/1.2 "Courier New", Courier, monospace;
}

.prompt-preview {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  margin: 4px 0 10px;
  line-height: 1.35;
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.audio-player {
  display: grid;
  grid-template-columns: auto auto auto minmax(96px, 1fr);
  gap: 8px;
  align-items: center;
  margin: 12px 0 10px;
  padding: 10px;
  border: 1px solid rgba(128, 205, 191, 0.20);
  border-radius: 12px;
  background: rgba(12, 16, 23, 0.72);
  min-width: 0;
}

.player-button {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 8px 11px;
  background: #2b3442;
  color: var(--text);
  font-size: 0.95rem;
}

.play-toggle {
  min-width: 74px;
  background: var(--accent);
  color: #16120a;
}

.audio-player.is-playing .play-toggle {
  background: var(--ok);
  color: #10201d;
}

.player-time {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  color: var(--muted);
  font: 700 0.82rem/1 "Courier New", Courier, monospace;
}

.player-scrub {
  grid-column: 1 / -1;
  width: 100%;
  height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--accent);
}

.player-scrub:focus {
  outline: 2px solid rgba(240, 199, 94, 0.32);
  outline-offset: 2px;
}

.log-tail {
  margin: 10px 0 0;
  padding: 10px;
  max-height: 150px;
  overflow: auto;
  border-radius: 10px;
  background: #0c1017;
  border: 1px solid var(--line);
  font: 12px/1.35 "Courier New", Courier, monospace;
  white-space: pre-wrap;
}

.floating-refresh {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 40;
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 999px;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.36);
}

.boot-error {
  position: fixed;
  inset: 12px;
  z-index: 200;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--danger);
  border-radius: 14px;
  background: #180b0e;
  color: #fff;
  font: 14px/1.4 "Courier New", Courier, monospace;
}

@media (max-width: 820px) {
  .shell {
    padding-top: 8px;
  }

  .topbar,
  .creator-grid,
  .form-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    padding: 14px;
    border-radius: 14px;
  }

  .session-box {
    width: 100%;
  }

  .panel {
    padding: 12px;
    border-radius: 14px;
  }

  .panel-head {
    align-items: center;
    flex-wrap: wrap;
  }

  textarea {
    min-height: 260px;
  }

  .audio-player {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    padding: 9px;
  }

  .play-toggle {
    grid-column: 1 / -1;
  }

  .seek-back,
  .seek-forward {
    grid-column: auto;
  }

  .player-time {
    grid-column: 1 / -1;
  }
}
