:root {
  --bg0: #e8f0ef;
  --bg1: #f4f8f7;
  --ink: #13221f;
  --muted: #5a6f6a;
  --line: #c5d4d0;
  --panel: rgba(255, 255, 255, 0.78);
  --start: #0f6e56;
  --start-hover: #0b5844;
  --stop: #8f2d2d;
  --stop-hover: #732323;
  --recording: #b42318;
  --shadow: 0 18px 50px rgba(19, 34, 31, 0.08);
  --radius: 18px;
  --font: "DM Sans", sans-serif;
  --display: "Instrument Serif", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #cfe8e2 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #d7e3f0 0%, transparent 50%),
    linear-gradient(160deg, var(--bg0), var(--bg1));
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}

.brand h1 {
  margin: 0 0 22px;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.2rem, 4vw, 3.2rem);
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.workspace,
.history {
  background: var(--panel);
  border: 1px solid rgba(197, 212, 208, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.workspace {
  padding: 20px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 12px 22px;
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-start {
  background: var(--start);
  color: #fff;
}

.btn-start:hover:not(:disabled) {
  background: var(--start-hover);
}

.btn-stop {
  background: var(--stop);
  color: #fff;
}

.btn-stop:hover:not(:disabled) {
  background: var(--stop-hover);
}

.status {
  color: var(--muted);
  font-size: 0.92rem;
  min-height: 1.2em;
}

.status.live::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--recording);
  box-shadow: 0 0 0 0 rgba(180, 35, 24, 0.55);
  animation: pulse 1.4s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(180, 35, 24, 0.5); }
  70% { box-shadow: 0 0 0 10px rgba(180, 35, 24, 0); }
  100% { box-shadow: 0 0 0 0 rgba(180, 35, 24, 0); }
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.transcript {
  width: 100%;
  min-height: 420px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  font: inherit;
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.transcript:focus {
  border-color: #7aa89c;
  box-shadow: 0 0 0 3px rgba(15, 110, 86, 0.12);
}

.history {
  padding: 18px 16px 16px;
  max-height: calc(100vh - 120px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

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

.history h2 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.btn-clear-all {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--stop);
  border-radius: 9px;
  padding: 6px 12px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-clear-all:hover {
  background: #fdf1f1;
  border-color: #e0b9b9;
}

.btn-clear-all[hidden] {
  display: none;
}

.history-list {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 4px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 12px;
  animation: fadeIn 0.35s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.history-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.history-item time {
  font-size: 0.78rem;
  color: var(--muted);
}

.btn-delete {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.btn-delete:hover {
  color: var(--stop);
  background: #fdf1f1;
}

.history-item p {
  margin: 0 0 10px;
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: 0.95rem;
}

.history-item audio {
  width: 100%;
  height: 36px;
}

.history-empty {
  color: var(--muted);
  font-size: 0.95rem;
  padding: 8px 2px;
}

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

  .history {
    max-height: none;
  }

  .transcript {
    min-height: 280px;
  }
}
