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

:root {
  --accent: #e6a800;
  --accent-hover: #cc9500;
  --accent-light: #fff8e6;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --border: #e0e0e0;
  --border-focus: #e6a800;
  --text-primary: #1a1a1a;
  --text-secondary: #6b6b6b;
  --text-muted: #9e9e9e;
  --error-bg: #fff5f5;
  --error-border: #fca5a5;
  --error-text: #b91c1c;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Header */
header {
  margin-bottom: 2.5rem;
  text-align: center;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.logo-icon {
  flex-shrink: 0;
}

.logo-text {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 400;
}

/* Input section */
.input-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}

.field-group:last-child {
  margin-bottom: 0;
}

label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
}

textarea,
input[type="number"],
select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  appearance: none;
}

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

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6b6b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(230, 168, 0, 0.12);
  background: var(--surface);
}

textarea::placeholder,
input::placeholder {
  color: var(--text-muted);
}

/* Label row */
.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Mic indicator */
.mic-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: default;
  transition: color 0.15s;
  user-select: none;
}

.mic-indicator.recording {
  color: #ef4444;
  animation: pulse-text 1.5s ease-in-out infinite;
}

@keyframes pulse-text {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Refine row */
.refine-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 0;
}

.refine-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.refine-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

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

.refine-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.spinner-sm {
  display: inline-block;
  width: 11px;
  height: 11px;
  border: 1.5px solid rgba(0,0,0,0.15);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

/* Options toggle */
.options-toggle-wrapper {
  margin-bottom: 0;
}

.options-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.35rem 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: color 0.15s;
}

.options-toggle:hover {
  color: var(--accent);
}

.toggle-arrow {
  display: inline-block;
  transition: transform 0.2s ease;
  font-style: normal;
}

.options-toggle[aria-expanded="true"] .toggle-arrow {
  transform: rotate(180deg);
}

/* Options panel */
.options-panel {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.28s ease, opacity 0.2s ease, margin-top 0.2s ease;
  margin-top: 0;
}

.options-panel.open {
  max-height: 300px;
  opacity: 1;
  margin-top: 1.25rem;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.5rem;
}

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

/* Generate button */
.generate-btn {
  width: 100%;
  margin-top: 1.5rem;
  padding: 0.8rem 1.5rem;
  background: var(--accent);
  color: #1a1a1a;
  border: none;
  border-radius: var(--radius);
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 8px rgba(230, 168, 0, 0.3);
}

.generate-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(230, 168, 0, 0.4);
}

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

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

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0,0,0,0.2);
  border-top-color: #1a1a1a;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* Output section */
.output-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.output-header h2 {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.output-actions {
  display: flex;
  gap: 0.5rem;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.action-btn.copied {
  border-color: #22c55e;
  color: #16a34a;
  background: #f0fdf4;
}

.tab-output {
  font-family: 'Space Mono', 'Courier New', Courier, monospace;
  font-size: 0.82rem;
  line-height: 1.7;
  padding: 1.5rem;
  white-space: pre;
  overflow-x: auto;
  color: var(--text-primary);
  min-height: 120px;
  tab-size: 4;
}

/* Scrollbar styling */
.tab-output::-webkit-scrollbar {
  height: 6px;
}

.tab-output::-webkit-scrollbar-track {
  background: var(--bg);
}

.tab-output::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Error banner */
.error-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.85rem 1.1rem;
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: var(--radius);
  color: var(--error-text);
  font-size: 0.88rem;
  margin-top: 1rem;
}

.error-banner svg {
  flex-shrink: 0;
  margin-top: 1px;
}

/* Footer */
footer {
  margin-top: 2.5rem;
  text-align: center;
}

footer p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.api-status {
  font-weight: 500;
}

.api-status.ok {
  color: #16a34a;
}

.api-status.missing {
  color: var(--error-text);
}

/* Streaming cursor */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
  margin-left: 1px;
}
