:root {
  color-scheme: light;
  --bg: #f4efe6;
  --surface: rgba(255, 252, 247, 0.9);
  --surface-strong: #fffaf2;
  --ink: #1f241f;
  --muted: #5f675f;
  --line: rgba(58, 70, 58, 0.14);
  --accent: #0f766e;
  --accent-strong: #125b61;
  --accent-soft: #d7efe9;
  --sand: #eadfcb;
  --shadow: 0 20px 50px rgba(44, 38, 28, 0.12);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.18), transparent 32%),
    radial-gradient(circle at top right, rgba(233, 174, 73, 0.18), transparent 28%),
    linear-gradient(180deg, #f8f3ea 0%, #efe6d7 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

.app-shell {
  width: min(1400px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 32px;
}

.hero-card,
.control-panel,
.preview-panel > article {
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.hero-card {
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
  padding: 20px 24px;
  border-radius: var(--radius-xl);
}

.hero-card::after {
  content: "";
  position: absolute;
  inset: auto -90px -120px auto;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15, 118, 110, 0.22), transparent 66%);
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: clamp(2.2rem, 4.6vw, 3.4rem);
  line-height: 0.98;
  letter-spacing: -0.04em;
}

h2 {
  font-size: 1.05rem;
}

.hero-copy {
  max-width: 62ch;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.45;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 520px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.tab-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.tab-button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(58, 70, 58, 0.18);
  background: rgba(255, 250, 242, 0.82);
  color: var(--ink);
  font-weight: 700;
}

.tab-button.is-active {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #f5fffd;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: grid;
}

.control-panel,
.preview-panel {
  min-width: 0;
}

.control-panel {
  display: grid;
  gap: 20px;
  padding: 26px;
  border-radius: var(--radius-xl);
}

.panel-block,
.history-panel {
  display: grid;
  gap: 14px;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.panel-heading {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.panel-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: #f1eadb;
  color: #6f5d2c;
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
}

.field {
  display: grid;
  gap: 8px;
}

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

.field-grow {
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select,
textarea,
.download-link {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  color: var(--ink);
}

input,
select {
  min-height: 48px;
  padding: 0 14px;
}

textarea {
  min-height: 130px;
  padding: 14px;
  resize: vertical;
  line-height: 1.48;
}

textarea[readonly] {
  background: #f7f1e6;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.chip-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.chip {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(18, 91, 97, 0.16);
  border-radius: 999px;
  background: #fff7ea;
  color: #684d1c;
  font-size: 0.9rem;
  font-weight: 700;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.chip:hover,
.chip.is-active {
  border-color: rgba(15, 118, 110, 0.35);
  background: #e8f5f1;
  color: var(--accent-strong);
  transform: translateY(-1px);
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.action-row.compact {
  grid-template-columns: 1fr 1fr;
}

button,
.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(58, 70, 58, 0.18);
  background: #fffaf2;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

button:hover,
.download-link:hover {
  border-color: var(--accent);
}

.ghost-button {
  min-height: 34px;
  padding: 0 12px;
  background: transparent;
}

.hidden {
  display: none;
}

.primary-button {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #f5fffd;
}

.status-message,
.helper-text,
.history-meta,
.history-script,
.prompt-preview {
  color: var(--muted);
  line-height: 1.5;
}

.warning-text {
  min-height: 20px;
  color: #d92d20;
  font-weight: 700;
}

.helper-list {
  display: grid;
  gap: 10px;
  color: var(--muted);
}

.status-message {
  min-height: 24px;
  font-size: 0.94rem;
}

.preview-panel {
  display: grid;
  gap: 24px;
}

.preview-panel > article {
  padding: 24px;
  border-radius: var(--radius-xl);
}

audio {
  width: 100%;
  margin-top: 4px;
}

.download-link.hidden {
  display: none;
}

.history-list {
  display: grid;
  gap: 14px;
}

.history-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 250, 242, 0.9);
}

.history-topline {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.history-title {
  font-weight: 800;
}

.history-script {
  font-size: 0.92rem;
}

.prompt-preview {
  font-size: 0.9rem;
  white-space: pre-wrap;
}

.empty-state {
  padding: 18px;
  border: 1px dashed rgba(95, 103, 95, 0.34);
  border-radius: 18px;
  background: rgba(255, 248, 238, 0.75);
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 18px, 1400px);
    padding-top: 16px;
  }

  .hero-card,
  .control-panel,
  .preview-panel > article {
    border-radius: 22px;
  }

  .hero-card,
  .control-panel,
  .preview-panel > article {
    padding-left: 18px;
    padding-right: 18px;
  }

  .panel-grid,
  .action-row,
  .action-row.compact,
  .field-inline {
    grid-template-columns: 1fr;
  }

  .panel-heading,
  .history-topline {
    align-items: start;
    flex-direction: column;
  }
}


.api-key-panel-block.is-collapsed {
  gap: 8px;
}

.api-key-panel-block.is-collapsed .api-key-body {
  display: none;
}

.markdown-preview {
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f7f1e6;
  color: var(--ink);
  font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
  font-size: 0.86rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
