:root {
  --bg-1: #f4efe1;
  --bg-2: #ddd4bd;
  --ink: #1d1a15;
  --ink-soft: #4f4638;
  --panel: rgba(255, 249, 238, 0.85);
  --border: rgba(29, 26, 21, 0.14);
  --danger: #c72626;
  --danger-dark: #9f1717;
  --action: #1f6a61;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(circle at 15% 20%, #f8f2e6 0%, var(--bg-1) 36%, var(--bg-2) 100%);
  font-family: "Space Grotesk", sans-serif;
  position: relative;
  overflow-x: hidden;
}

.bg-shape {
  position: fixed;
  border-radius: 999px;
  filter: blur(18px);
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
}

.bg-shape-1 {
  width: 28rem;
  height: 28rem;
  background: #ea8d6b;
  top: -8rem;
  left: -5rem;
}

.bg-shape-2 {
  width: 24rem;
  height: 24rem;
  background: #5aa097;
  right: -4rem;
  bottom: -7rem;
}

.container {
  width: min(720px, calc(100% - 1.1rem));
  margin: 1rem auto 1.2rem;
  position: relative;
  z-index: 1;
  animation: float-in 460ms ease-out;
}

.hero-link {
  display: block;
  text-decoration: none;
  color: inherit;
  text-align: center;
}

.hero-link h1 {
  margin: 0 0 0.8rem;
  font-family: "Fraunces", serif;
  font-size: clamp(2rem, 6vw, 3.4rem);
  line-height: 1.08;
  transition: color 140ms ease;
}

.hero-link:hover h1 {
  color: var(--action);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem;
  backdrop-filter: blur(6px);
  box-shadow: 0 10px 32px rgba(26, 20, 14, 0.1);
}

.panel + .panel {
  margin-top: 1rem;
}

.recorder-panel {
  position: relative;
  min-height: 18rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-corner {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
}

.upload-corner input {
  display: none;
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.38rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.recorder-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  text-align: center;
}

.record-btn {
  width: min(48vw, 180px);
  aspect-ratio: 1 / 1;
  border-radius: 999px;
  border: 6px solid #f9d6d6;
  background: radial-gradient(circle at 30% 25%, #ec5e5e, var(--danger));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 20px 42px rgba(112, 20, 20, 0.28);
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.record-btn:active {
  transform: scale(0.97);
}

.record-btn.recording {
  background: radial-gradient(circle at 30% 25%, #d83f3f, var(--danger-dark));
}

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

.record-icon {
  font-size: clamp(2.5rem, 8vw, 4rem);
  line-height: 1;
}

.status {
  margin: 0;
  font-weight: 700;
}

.hint {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.94rem;
}

.loading {
  color: var(--action);
  font-weight: 700;
}

.progress-panel {
  width: min(100%, 22rem);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.workflow-panel {
  width: min(100%, 22rem);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.confirm-view,
.progress-view {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.confirm-filename {
  margin: 0;
  font-weight: 700;
  font-size: 0.95rem;
  word-break: break-word;
  text-align: center;
}

.confirm-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.confirm-select {
  width: 100%;
  font-family: inherit;
  font-size: 0.92rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  background: #fff;
}

.confirm-stats {
  margin: 0;
  display: grid;
  gap: 0.35rem;
}

.confirm-stat {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: baseline;
}

.confirm-stat dt {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.confirm-stat dd {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.confirm-actions {
  display: flex;
  justify-content: center;
  gap: 0.55rem;
}

.confirm-submit {
  background: var(--action);
  color: #fff;
  border-color: var(--action);
}

.confirm-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.progress-bar {
  width: 100%;
  height: 0.55rem;
  border-radius: 999px;
  background: rgba(29, 26, 21, 0.1);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #5aa097, #1f6a61);
  transition: width 400ms ease;
}

.progress-timer {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--action);
  font-variant-numeric: tabular-nums;
}

.job-link-wrap {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  word-break: break-all;
}

.job-link {
  color: var(--action);
  font-size: 0.85rem;
  text-decoration: underline;
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

.result-panel h2 {
  margin: 0;
  font-family: "Fraunces", serif;
}

.copy-btn {
  font-family: inherit;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  padding: 0.42rem 0.76rem;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

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

pre {
  margin: 0.5rem 0;
  white-space: pre-wrap;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  padding: 0.85rem;
  max-height: 18rem;
  overflow: auto;
}

.error {
  color: #9c2410;
  font-weight: 600;
}

.hidden {
  display: none;
}

.history-panel h2 {
  margin: 0 0 0.65rem;
  font-family: "Fraunces", serif;
}

.history-table {
  display: flex;
  flex-direction: column;
}

.history-row {
  display: grid;
  grid-template-columns: 5.25rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem 0.85rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

.history-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.history-row:first-child {
  padding-top: 0;
}

.history-when {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
}

.history-main {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
}

.history-link {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
}

.history-model {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: lowercase;
}

.history-link:hover {
  color: var(--action);
  text-decoration: underline;
}

.history-row .delete-btn {
  justify-self: end;
  font-family: inherit;
  background: #fff;
  color: var(--ink-soft);
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  padding: 0.28rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
}

.history-row .delete-btn:hover {
  color: var(--danger);
  border-color: rgba(199, 38, 38, 0.28);
}

@media (max-width: 640px) {
  .panel {
    padding: 0.85rem;
  }

  .recorder-panel {
    min-height: 16.5rem;
  }

  .upload-corner {
    top: 0.7rem;
    right: 0.7rem;
  }

  .history-row {
    grid-template-columns: 4.5rem minmax(0, 1fr) auto;
    gap: 0.5rem 0.65rem;
  }

  .history-row .delete-btn {
    padding: 0.24rem 0.45rem;
    font-size: 0.72rem;
  }
}

@keyframes float-in {
  from {
    opacity: 0;
    transform: translateY(9px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
