:root {
  --red: #ba0c2f;
  --red-dark: #950a26;
  --red-light: #fdf0f2;
  --red-ring: rgba(186, 12, 47, 0.2);

  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-alt: #fafafa;
  --border: #dde1e7;
  --border-focus: #ba0c2f;
  --text: #1a1a1a;
  --text-muted: #5c6070;
  --text-light: #8a8f9e;

  --success: #1a7f4b;
  --error: #c0392b;
  --info: #1a5fa0;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.07), 0 6px 20px rgba(0, 0, 0, 0.05);

  --transition: 0.15s ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

.auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-gate[hidden] {
  display: none;
}

.auth-gate-card {
  width: min(100%, 420px);
  padding: 32px;
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.auth-gate-card h1 {
  margin: 0 0 12px;
  color: var(--red);
  font-size: 24px;
}

.auth-gate-card p {
  margin: 12px 0 0;
  color: var(--text-muted);
}

header {
  background: var(--red);
  color: #fff;
  padding: 20px 24px;
  position: relative;
  display: flex;
  align-items: center;
}

.header-logo {
  position: absolute;
  left: 24px;
}

.header-logo img {
  display: block;
  height: 50px;
  width: auto;
}

.header-inner {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.header-text {
  text-align: center;
}

.header-text h1 {
  margin: 0;
  font-size: 28px;
  font-weight: bold;
  letter-spacing: -0.3px;
}

.header-text p {
  margin: 4px 0 0;
  font-size: 15px;
  opacity: 0.9;
}

main {
  max-width: 960px;
  margin: 32px auto;
  padding: 0 20px 48px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 28px;
  margin-bottom: 24px;
}

.card h2 {
  margin: 0 0 4px;
  font-size: 18px;
  color: var(--red);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.section-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: flex-start;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 4px;
}

.helper {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.char-count {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  transition: color var(--transition);
}

.placeholder-text {
  color: var(--text-muted);
  margin: 0;
}

input[type="text"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

input[type="text"]:hover,
select:hover,
textarea:hover {
  border-color: #b0b8c5;
}

input[type="text"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #8a8f9e;
  box-shadow: 0 0 0 3px rgba(138, 143, 158, 0.2);
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--error);
}

textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
}

/* browser default arrows look bad — replacing with a consistent one across all browsers */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235c6070' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition:
    background var(--transition),
    color var(--transition),
    border-color var(--transition),
    opacity var(--transition),
    box-shadow var(--transition);
  white-space: nowrap;
}

button:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.primary-btn {
  background: var(--red);
  color: #fff;
  padding: 12px 24px;
  margin-top: 8px;
}

.primary-btn:hover:not(:disabled) {
  background: var(--red-dark);
}
.primary-btn:active:not(:disabled) {
  background: #7a0820;
}

.outline-btn {
  background: var(--surface);
  color: var(--red);
  border: 1.5px solid var(--red);
  padding: 10px 16px;
}

.outline-btn:hover:not(:disabled) {
  background: var(--red-light);
}
.outline-btn:active:not(:disabled) {
  background: #fce4e9;
}

.remove-btn {
  background: #eff0f3;
  color: var(--text-muted);
  padding: 8px 14px;
  font-size: 13px;
}

.remove-btn:hover:not(:disabled) {
  background: #e2e4ea;
  color: var(--text);
}

.go-btn {
  padding: 10px 24px;
  margin-top: 8px;
}

.speaker-card {
  background: var(--surface-alt);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: box-shadow var(--transition);
}

/* subtle highlight when user is actively editing a card */
.speaker-card:focus-within {
  box-shadow: 0 0 0 2px rgba(186, 12, 47, 0.1);
}

.speaker-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.speaker-label {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.speaker-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.speaker-settings {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.speaker-actions {
  display: flex;
  justify-content: flex-end;
}

/* shown after Go is clicked — hidden by default */
.speaker-output {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.speaker-status {
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--error);
}

/* the ? icon next to Emphasize Word */
.field-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 11px;
  font-weight: 700;
  background: var(--border);
  color: var(--text-muted);
  border-radius: 50%;
  cursor: default;
  position: relative;
}

.field-hint .tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  background: #2c2c2c;
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  z-index: 10;
  pointer-events: none;
  line-height: 1.4;
}

.field-hint:hover .tooltip,
.field-hint:focus .tooltip {
  display: block;
}

.audio-file {
  background: var(--surface-alt);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.audio-file p {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

audio {
  width: 100%;
  display: block;
}

.download-link {
  display: inline-block;
  color: var(--red);
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  padding: 4px 0;
  transition: color var(--transition);
}

.download-link:hover {
  color: var(--red-dark);
  text-decoration: underline;
}

.download-link:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
  border-radius: 2px;
}

.status {
  margin: 16px 0 0;
  font-size: 14px;
  font-weight: 600;
}

.status--success {
  color: var(--success);
}
.status--error {
  color: var(--error);
}
.status--info {
  color: var(--info);
}

@media (max-width: 700px) {
  header h1 {
    font-size: 22px;
  }

  .card {
    padding: 20px 16px;
  }

  .section-header {
    flex-direction: column;
    align-items: stretch;
  }

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

  /* stack all grids to single column on mobile */
  .speaker-grid,
  .speaker-settings {
    grid-template-columns: 1fr;
  }

  .speaker-actions {
    justify-content: stretch;
  }

  .go-btn {
    width: 100%;
  }

  .header-logo {
    position: static;
    margin-bottom: 8px;
  }

  .header-inner {
    flex-direction: column;
    text-align: center;
  }
}
/* respect user's OS motion preference */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(186, 12, 47, 0.3);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
  margin-right: 6px;
}

.speaker-card.done {
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(26, 127, 75, 0.15);
}

.empty-state {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.empty-state-text {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
}

.empty-state-hint {
  margin: 0;
  font-size: 13px;
  color: var(--text-light);
}

.action-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
