:root {
  color-scheme: light dark;
  --bg: #f3f1ea;
  --surface: #fffdf7;
  --text: #1f2a24;
  --muted: #5d6b62;
  --border: #d8d2c3;
  --accent: #1d5c3f;
  --accent-strong: #14452f;
  --accent-text: #ffffff;
  --focus: #b5791f;
  --status-idle: #5d6b62;
  --status-starting: #9a5b00;
  --status-active: #1d6b45;
  --status-error: #a12f2f;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111814;
    --surface: #18211c;
    --text: #eef3ee;
    --muted: #aebbb2;
    --border: #33433a;
    --accent: #79c69b;
    --accent-strong: #9adcb8;
    --accent-text: #0d1a12;
    --focus: #e0ad57;
    --status-idle: #aebbb2;
    --status-starting: #e0ad57;
    --status-active: #79c69b;
    --status-error: #ff9c9c;
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 12% 12%, rgba(29, 92, 63, 0.14), transparent 34%),
    radial-gradient(circle at 88% 86%, rgba(181, 121, 31, 0.12), transparent 38%),
    var(--bg);
  color: var(--text);
  font-family:
    "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  line-height: 1.65;
}

.card {
  width: min(100%, 620px);
  padding: clamp(28px, 6vw, 52px);
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(24, 39, 30, 0.1);
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 4.5vw, 2.3rem);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.mic-toggle {
  width: 100%;
  min-height: 58px;
  margin-top: 20px;
  border: 0;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-size: 1.08rem;
  font-weight: 750;
  cursor: pointer;
  transition:
    background-color 160ms ease,
    transform 160ms ease;
}

.mic-toggle:hover {
  background: var(--accent-strong);
}

.mic-toggle:active {
  transform: translateY(1px);
}

.mic-toggle:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.status {
  min-height: 3.3em;
  margin: 18px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--status-idle);
  background: color-mix(in srgb, var(--surface) 82%, var(--bg));
  font-size: 0.98rem;
  font-weight: 650;
}

.status[data-state="starting"] {
  color: var(--status-starting);
}

.status[data-state="active"] {
  color: var(--status-active);
}

.status[data-state="error"] {
  color: var(--status-error);
}

[hidden] {
  display: none !important;
}

.contact {
  margin: 20px 0 0;
}

.contact-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.contact-row label {
  flex: 0 0 auto;
  font-size: 0.95rem;
  font-weight: 700;
}

.contact-row input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

.contact-row input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.contact-row input:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.contact-status {
  min-height: 1.5em;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 650;
}

.contact-status[data-state="pending"] {
  color: var(--status-starting);
}

.contact-status[data-state="success"] {
  color: var(--status-active);
}

.contact-status[data-state="error"] {
  color: var(--status-error);
}

.recording-note {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--status-starting);
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 82%, var(--bg));
  font-size: 0.92rem;
  font-weight: 650;
}

.history {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

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

.history-head h2 {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.35;
}

.history-refresh,
.history-more,
.history-button {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.history-refresh:hover:enabled,
.history-more:hover:enabled,
.history-button:hover:enabled {
  border-color: var(--accent);
  color: var(--accent);
}

.history-refresh:focus-visible,
.history-more:focus-visible,
.history-button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.history-refresh:disabled,
.history-more:disabled,
.history-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.history-status {
  min-height: 1.5em;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.history-status[data-state="pending"] {
  color: var(--status-starting);
}

.history-status[data-state="error"] {
  color: var(--status-error);
}

.history-list {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  min-width: 0;
}

.history-time {
  color: var(--muted);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.history-phone {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.history-outcome {
  color: var(--muted);
  font-size: 0.86rem;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.history-more {
  width: 100%;
  margin-top: 12px;
}

.history audio {
  display: block;
  width: 100%;
  margin-top: 14px;
}

.privacy-details {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.88rem;
}

.privacy-details summary {
  min-height: 44px;
  padding: 10px 0;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.privacy-details summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.privacy-details p {
  margin: 0 0 8px;
}

.privacy-details p:last-child {
  margin-bottom: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 560px) {
  body {
    padding: 12px;
  }

  .card {
    padding: 22px;
    border-radius: 18px;
  }

  .history-item {
    grid-template-columns: 1fr;
  }

  .history-actions {
    justify-content: flex-start;
  }
}
