:root {
  --bg-page: #1a1a1a;
  --bg-surface: #1a1a1a;
  --bg-surface-raised: #242422;
  --surface-hover: rgba(255, 255, 255, 0.04);

  --text-primary: #ffffff;
  --text-body: #e5e4de;
  --text-secondary: #8a8880;
  --text-tertiary: #6b6963;

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-button: rgba(255, 255, 255, 0.18);

  --brand-green-icon: #97c459;
  --brand-green-success: #97c459;
  --brand-green-cta: #7da53c;
  --brand-green-cta-text: #fcfcf8;
  --brand-green-soft: rgba(125, 165, 60, 0.1);
  --brand-green-soft-border: rgba(125, 165, 60, 0.3);
  --brand-green-soft-text: #c0dd97;

  --destructive: #d35a3f;

  --selection: hsl(75 55% 55% / 0.3);

  --shadow-soft: 0 1px 2px hsl(0 0% 0% / 0.04), 0 1px 1px hsl(0 0% 0% / 0.03);

  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  --radius-pill: 9999px;

  --font-sans: 'Inter', system-ui, -apple-system, Segoe UI, sans-serif;
  --font-display: Georgia, 'Times New Roman', serif;

  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--bg-page);
  color: var(--text-body);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--selection);
}

::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-thumb {
  background: var(--border-button);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

.column {
  max-width: 768px;
  margin: 0 auto;
  padding: 24px 24px 96px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.page-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.status {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status.is-recording {
  color: var(--brand-green-success);
}

.status .dot {
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: var(--brand-green-icon);
  animation: pulse 1.4s ease-in-out infinite;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill-outline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-body);
  background: transparent;
  border: 0.5px solid var(--border-button);
  border-radius: var(--radius-pill);
  transition: background-color 120ms ease, color 120ms ease, opacity 120ms ease;
}

.pill-outline:hover:not(:disabled) {
  background: var(--surface-hover);
}

.pill-outline:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pill-outline svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.pill-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0.5px solid var(--border-button);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  transition: background-color 120ms ease, color 120ms ease;
}

.pill-icon:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-body);
}

.pill-indicator {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: var(--brand-green-icon);
  opacity: 0;
  transition: opacity 160ms ease;
}

.pill-icon.has-key .pill-indicator {
  opacity: 1;
}

.pill-outline-destructive {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--destructive);
  background: transparent;
  border: 0.5px solid var(--border-button);
  border-radius: var(--radius-pill);
  transition: background-color 120ms ease, opacity 120ms ease;
}

.pill-outline-destructive:hover:not(:disabled) {
  background: rgba(211, 90, 63, 0.1);
}

.pill-outline-destructive:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pill-solid-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--brand-green-cta-text);
  background: var(--brand-green-cta);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-soft);
  transition: background-color 140ms ease, opacity 140ms ease;
}

.pill-solid-cta:hover:not(:disabled) {
  background: #8bb544;
}

.pill-solid-cta:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Record area */
.record-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px 0 8px;
}

.record-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 28px;
  border-radius: var(--radius-pill);
  background: var(--brand-green-cta);
  color: var(--brand-green-cta-text);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.005em;
  box-shadow: var(--shadow-soft);
  transition: background-color 140ms ease, transform 80ms ease, opacity 140ms ease;
}

.record-btn:hover:not(:disabled) {
  background: #8bb544;
}

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

.record-btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.record-btn.is-recording {
  background: transparent;
  color: var(--brand-green-soft-text);
  border: 1px solid var(--brand-green-soft-border);
  box-shadow: none;
}

.record-btn.is-recording:hover {
  background: rgba(125, 165, 60, 0.08);
}

.record-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.record-btn .icon-stop {
  display: none;
}

.record-btn.is-recording .icon-mic {
  display: none;
}

.record-btn.is-recording .icon-stop {
  display: inline;
}

.loader-bar {
  width: 100%;
  max-width: 320px;
  height: 2px;
  border-radius: var(--radius-pill);
  background: var(--border-subtle);
  overflow: hidden;
  opacity: 0;
  transition: opacity 160ms ease;
}

.loader-bar.is-visible {
  opacity: 1;
}

.loader-bar > span {
  display: block;
  width: 33%;
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--brand-green-icon);
  transform: translateX(-100%);
  animation: shimmer 1.4s ease-in-out infinite;
}

/* Transcript */
.transcript-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-label {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.transcript {
  position: relative;
  min-height: 240px;
  padding: 24px;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text-body);
  white-space: pre-wrap;
  word-wrap: break-word;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

.transcript-empty {
  margin: 0;
  color: var(--text-tertiary);
  font-style: italic;
  font-size: 14px;
}

.transcript-empty.is-hidden {
  display: none;
}

.transcript-finals {
  color: var(--text-body);
}

.transcript-partial {
  color: var(--text-secondary);
}

.transcript-partial::before {
  content: ' ';
  white-space: pre;
}

.transcript-partial.is-empty::before {
  content: '';
}

/* Footer */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 36px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
  background: rgba(26, 26, 26, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.footer-right {
  opacity: 0.7;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 56px;
  transform: translate(-50%, 8px);
  padding: 10px 16px;
  background: var(--bg-surface-raised);
  color: var(--text-body);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  font-size: 13px;
  box-shadow: var(--shadow-soft);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 50;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-error {
  border-color: rgba(211, 90, 63, 0.5);
  color: var(--destructive);
}

/* Dialog */
.dialog {
  width: min(480px, calc(100vw - 32px));
  margin: auto;
  padding: 0;
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-2xl);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  font-family: var(--font-sans);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.dialog-form {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dialog-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.dialog-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.dialog-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--brand-green-icon);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
  transition: border-color 120ms ease;
}

.dialog-link:hover {
  border-bottom-color: var(--brand-green-icon);
}

.dialog-link svg {
  margin-top: 1px;
  opacity: 0.8;
}

.dialog-label {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.dialog-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  background: var(--bg-surface);
  color: var(--text-body);
  border: 1px solid var(--border-button);
  border-radius: var(--radius-md);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13px;
  letter-spacing: 0.02em;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.dialog-input::placeholder {
  color: var(--text-tertiary);
  font-family: var(--font-sans);
  letter-spacing: normal;
}

.dialog-input:focus {
  outline: none;
  border-color: var(--brand-green-icon);
  box-shadow: 0 0 0 3px rgba(151, 196, 89, 0.18);
}

.dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.dialog-spacer {
  flex: 1;
}

/* Animations */
@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(300%);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

@media (max-width: 560px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .topbar-actions {
    width: 100%;
  }
  .footer-right {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .loader-bar > span,
  .status .dot {
    animation: none;
  }
  * {
    transition-duration: 0.01ms !important;
  }
}
