:root {
  --bg: #f6f7f9;
  --bg-accent: #eef2f8;
  --surface: rgba(255, 255, 255, 0.96);
  --surface-border: rgba(29, 43, 62, 0.08);
  --text: #1f2329;
  --muted: #6e7781;
  --primary: #3d6df2;
  --primary-strong: #2f5de0;
  --primary-soft: rgba(61, 109, 242, 0.1);
  --secondary: #f1f3f5;
  --secondary-strong: #e3e8ef;
  --danger: #7a2417;
  --warning: #a16808;
  --shadow: 0 16px 40px rgba(31, 35, 41, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Inter", "Avenir Next", system-ui, sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, #ffffff 0%, #f8f9fb 100%);
}

.shell {
  width: min(760px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 56px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
}

h1 {
  font-size: clamp(1.8rem, 4.6vw, 3.3rem);
  letter-spacing: -0.04em;
}

h2 {
  font-size: 1.4rem;
  margin-bottom: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.controls,
.result {
  padding: 24px;
}

.page-prompt {
  margin-bottom: 16px;
  padding: 4px 2px 2px;
}

.page-prompt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.page-prompt-title {
  max-width: 10ch;
  color: var(--text);
  font-weight: 800;
}

.auth-card {
  max-width: 460px;
  margin: 48px auto 0;
  padding: 28px;
}

.auth-copy {
  margin-bottom: 18px;
}

.auth-text {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.auth-form {
  display: flex;
  flex-direction: column;
}

.result {
  margin-top: 18px;
}

.field-label {
  display: block;
  font-size: 0.92rem;
  margin-bottom: 8px;
  color: var(--muted);
}

.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;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.section-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field-block {
  margin-top: 6px;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(61, 109, 242, 0.08);
  border: 1px solid rgba(61, 109, 242, 0.16);
  font-weight: 600;
}

.live-badge.recording {
  background: rgba(122, 36, 23, 0.1);
  border-color: rgba(122, 36, 23, 0.18);
  color: var(--danger);
}

.live-badge.processing {
  background: rgba(141, 100, 24, 0.12);
  border-color: rgba(141, 100, 24, 0.2);
  color: var(--warning);
}

.live-badge.ready {
  background: var(--primary-soft);
  border-color: rgba(61, 109, 242, 0.16);
  color: var(--primary-strong);
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.85;
}

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
  padding: 16px;
  border-radius: 22px;
  background: #fafbfc;
  border: 1px solid rgba(29, 43, 62, 0.08);
  min-height: 180px;
  max-height: 340px;
  overflow-y: auto;
}

.chat-bubble {
  max-width: 88%;
  padding: 14px 16px;
  border-radius: 20px;
  line-height: 1.45;
}

.chat-bubble p {
  margin: 0;
  white-space: pre-wrap;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: #f2f4f7;
  border-bottom-left-radius: 8px;
}

.chat-bubble.user {
  align-self: flex-end;
  background: rgba(61, 109, 242, 0.1);
  border-bottom-right-radius: 8px;
}

.text-input,
.text-area {
  width: 100%;
  border: 1px solid rgba(29, 43, 62, 0.1);
  border-radius: 22px;
  background: #ffffff;
  color: var(--text);
  padding: 16px 18px;
  font: inherit;
  margin-bottom: 16px;
}

.text-area {
  min-height: 74px;
  resize: vertical;
  margin-bottom: 8px;
}

.input-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 15px 20px;
  font: inherit;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

.primary {
  background: var(--primary);
  color: #fffdf8;
}

.primary:hover:not(:disabled) {
  background: var(--primary-strong);
}

.secondary {
  background: var(--secondary);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(29, 43, 62, 0.05);
}

.voice-button {
  min-width: 190px;
  box-shadow: 0 10px 24px rgba(61, 109, 242, 0.18);
}

.voice-button.recording {
  background: var(--danger);
}

.compact {
  padding: 10px 14px;
  white-space: nowrap;
}

.full {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}

.status {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.45;
  min-height: 1.4em;
}

.clarification-box {
  margin-bottom: 16px;
  padding: 16px;
  border-radius: 20px;
  background: rgba(61, 109, 242, 0.06);
  border: 1px solid rgba(61, 109, 242, 0.14);
}

.clarification-title {
  font-weight: 800;
  color: var(--primary-strong);
  margin-bottom: 8px;
}

.clarification-text {
  margin: 0;
  line-height: 1.5;
}

.clarification-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.clarification-chip {
  border: 1px solid rgba(89, 61, 34, 0.12);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  padding: 10px 14px;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.clarification-chip.selected {
  background: rgba(61, 109, 242, 0.12);
  border-color: rgba(61, 109, 242, 0.28);
  box-shadow: 0 0 0 3px rgba(61, 109, 242, 0.08);
}

.clarification-chip-title {
  display: block;
  font-weight: 600;
  line-height: 1.35;
}

.clarification-chip-meta {
  display: block;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.3;
}

.clarification-chip.listening {
  background: rgba(61, 109, 242, 0.14);
  border-color: rgba(61, 109, 242, 0.28);
  color: var(--primary-strong);
  box-shadow: 0 0 0 3px rgba(61, 109, 242, 0.08);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.summary-item {
  padding: 18px;
  border-radius: 22px;
  background: rgba(248, 249, 251, 0.96);
  border: 1px solid rgba(29, 43, 62, 0.08);
  min-height: 118px;
}

.summary-label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.88rem;
  color: var(--muted);
}

.summary-value {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
  font-size: 1.14rem;
}

.summary-meta {
  display: block;
  margin-top: 8px;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.3;
}

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

  .actions {
    flex-direction: column;
  }

  .actions button {
    width: 100%;
  }

  .status-strip {
    align-items: stretch;
  }

  .section-head {
    flex-direction: column;
  }

  .ready-badge {
    align-self: flex-start;
  }

  .clarification-options {
    flex-direction: column;
  }

  .clarification-chip {
    width: 100%;
  }
}

.warnings {
  margin-top: 16px;
  padding: 16px;
  border-radius: 20px;
  background: rgba(241, 243, 245, 0.92);
  border: 1px solid rgba(29, 43, 62, 0.08);
}

.warnings-title {
  font-weight: 700;
  margin-bottom: 10px;
}

.warnings-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
}

.option-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 10px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(248, 249, 251, 0.96);
  border: 1px solid rgba(29, 43, 62, 0.08);
  font-weight: 600;
}

.option-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.create-result {
  margin: 16px 0 0;
  padding: 18px 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(15, 107, 87, 0.14), rgba(15, 107, 87, 0.08));
  border: 1px solid rgba(15, 107, 87, 0.22);
  color: var(--primary-strong);
  font-weight: 700;
  white-space: pre-wrap;
  line-height: 1.45;
}

.create-result-title {
  display: block;
  margin-bottom: 10px;
  font-size: 1.02rem;
}

.create-result-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.create-result-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.result-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

.result-link:hover {
  transform: translateY(-1px);
}

.result-link.primary-link {
  background: var(--primary);
  color: #fffdf8;
}

.result-link.secondary-link {
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  border: 1px solid rgba(89, 61, 34, 0.12);
}

.create-result.error {
  background: rgba(122, 36, 23, 0.08);
  border-color: rgba(122, 36, 23, 0.18);
  color: var(--danger);
}

.hidden {
  display: none;
}

@media (max-width: 640px) {
  .shell {
    width: min(100vw - 20px, 760px);
    padding-top: 16px;
  }

  .page-prompt {
    padding-top: 2px;
  }

  .page-prompt-row {
    align-items: stretch;
    flex-direction: column;
  }

  .controls,
  .result {
    padding: 18px;
    border-radius: 24px;
  }

  .field-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
  }

  .status-strip {
    align-items: stretch;
  }

  .live-badge {
    width: 100%;
    justify-content: center;
  }

  button {
    width: 100%;
  }
}
