@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap");

:root {
  --bg: #0f1115;
  --surface: #171a21;
  --border: #2a3140;
  --text: #e8ecf4;
  --muted: #8b95a8;
  --accent: #5b8def;
  --accent-dim: #3d62a8;
  --danger: #e06c75;
  --radius: 10px;
  --font: "DM Sans", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 20% -10%, #1a2740 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #1e2030 0%, transparent 50%), var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.subtitle code {
  font-size: 0.85em;
  background: var(--surface);
  padding: 0.15em 0.45em;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.key-status {
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}

.key-status.ok {
  color: #7fd99a;
  border-color: #2f4a3a;
}

.key-status.bad {
  color: var(--danger);
  border-color: #4a2f35;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 900px) {
  .grid {
    grid-template-columns: 1.15fr 0.85fr;
    align-items: start;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.editor-panel label,
.history-head h2 {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

textarea,
select,
input[type="range"] {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: #12151c;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
}

textarea {
  resize: vertical;
  min-height: 140px;
}

textarea:focus,
select:focus {
  outline: 2px solid var(--accent-dim);
  outline-offset: 1px;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.row.meta {
  margin-top: 0.35rem;
  justify-content: space-between;
}

.meta #charCount {
  font-size: 0.8rem;
  color: var(--muted);
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
}

.field.full {
  margin-top: 1rem;
}

.hint {
  font-size: 0.75rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
}

.actions {
  margin-top: 1.25rem;
  align-items: center;
}

.status {
  font-size: 0.875rem;
  color: var(--muted);
}

.status.error {
  color: var(--danger);
}

.btn {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  background: #1c2230;
  color: var(--text);
}

.btn:hover {
  border-color: var(--muted);
}

.btn.primary {
  background: linear-gradient(180deg, #5b8def, #4a74c9);
  border-color: #5b8def;
  color: #fff;
  font-weight: 600;
}

.btn.primary:hover {
  filter: brightness(1.05);
}

.btn.primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
}

.btn.ghost {
  background: transparent;
}

.btn.small {
  font-size: 0.8rem;
  padding: 0.35rem 0.65rem;
}

.player-block {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

audio {
  width: 100%;
  margin-top: 0.35rem;
  border-radius: 8px;
}

.hidden {
  display: none !important;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.history-head h2 {
  margin: 0;
}

.history-panel .hint {
  margin: 0 0 1rem;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: min(70vh, 640px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.history-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  background: #12151c;
}

.history-item .snippet {
  font-size: 0.85rem;
  color: var(--text);
  margin: 0 0 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-item .meta-line {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.history-item audio {
  margin-top: 0;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}
