:root {
  --accent: #ef572b;
  --accent-hover: #ff7049;
  --bg: #0f0f0f;
  --card: #191919;
  --card-alt: #121212;
  --input: #0d0d0d;
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.56);
  --line: rgba(255, 255, 255, 0.1);
  --soft-accent: rgba(239, 87, 43, 0.14);
  --success: #3ab779;
  --danger: #e5684c;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.2);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f5f5f7;
    --card: #ffffff;
    --card-alt: #fbfbfc;
    --input: #ffffff;
    --text: #141414;
    --muted: rgba(0, 0, 0, 0.55);
    --line: rgba(0, 0, 0, 0.1);
    --soft-accent: rgba(239, 87, 43, 0.1);
    --shadow: 0 16px 40px rgba(20, 20, 20, 0.08);
  }
}

:root[data-theme="light"] {
  --bg: #f5f5f7;
  --card: #ffffff;
  --card-alt: #fbfbfc;
  --input: #ffffff;
  --text: #141414;
  --muted: rgba(0, 0, 0, 0.55);
  --line: rgba(0, 0, 0, 0.1);
  --soft-accent: rgba(239, 87, 43, 0.1);
  --shadow: 0 16px 40px rgba(20, 20, 20, 0.08);
}

:root[data-theme="dark"] {
  --bg: #0f0f0f;
  --card: #191919;
  --card-alt: #121212;
  --input: #0d0d0d;
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.56);
  --line: rgba(255, 255, 255, 0.1);
  --soft-accent: rgba(239, 87, 43, 0.14);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.2);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.5;
  transition: background 0.2s, color 0.2s;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.page-shell { min-height: 100vh; display: flex; flex-direction: column; padding: 0 16px; }

.site-header,
footer { width: min(1080px, 100%); margin: 0 auto; }
.site-header { min-height: 76px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.logo-link img { display: block; width: 132px; height: auto; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.secure-label { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 7px; margin-right: 6px; }
.secure-label::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
.text-button { min-height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; background: var(--input); color: var(--text); font-size: 12px; font-weight: 700; }
.text-button:hover { border-color: var(--accent); color: var(--accent); }
.theme-button { width: 34px; padding: 5px; }

main { flex: 1; }
.hero { width: min(760px, 100%); margin: 0 auto; padding: 64px 0 72px; }
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: 0.18em; text-transform: uppercase; margin-bottom: 7px; }
.eyebrow::first-letter { color: var(--accent); }
h1 { margin: 0; font-size: clamp(29px, 4vw, 38px); line-height: 1.15; letter-spacing: -0.02em; font-weight: 900; }
.hero-copy { margin: 8px 0 26px; color: var(--muted); font-size: 14px; max-width: 620px; }

.composer-card,
.conversation-panel,
.brief-panel,
.review-card {
  background: linear-gradient(160deg, var(--card), var(--card-alt));
  border: 1px solid var(--line);
  border-radius: 16px;
}
.composer-card { padding: 0; overflow: hidden; box-shadow: var(--shadow); }
textarea { width: 100%; border: 0; background: transparent; color: var(--text); outline: none; resize: vertical; }
textarea::placeholder { color: var(--muted); opacity: 0.72; }
.composer-card textarea { min-height: 170px; padding: 20px; font-size: 15px; line-height: 1.6; }
.composer-footer,
.followup-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.composer-footer { border-top: 1px solid var(--line); padding: 12px; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-button,
.icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: var(--input); color: var(--muted); font-weight: 700; }
.upload-button { min-height: 38px; border-radius: 9px; padding: 8px 12px; font-size: 12px; }
.upload-button:hover,
.icon-button:hover { color: var(--accent); border-color: var(--accent); }
.primary-button,
.secondary-button { border-radius: 10px; border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: 12px; font-weight: 800; transition: 0.15s ease; }
.primary-button { min-height: 40px; padding: 9px 18px; background: var(--accent); color: #fff; }
.primary-button:hover:not(:disabled) { background: var(--accent-hover); }
.primary-button:disabled { opacity: 0.46; cursor: not-allowed; }
.secondary-button { min-height: 38px; padding: 8px 14px; border-color: var(--line); background: var(--input); color: var(--text); font-size: 12px; }
.secondary-button:hover { border-color: var(--accent); }
.input-examples { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 17px; color: var(--muted); font-size: 11px; }
.input-examples span::before { content: "✓"; color: var(--accent); margin-right: 6px; }
.privacy-note { margin: 14px 0 0; color: var(--muted); font-size: 11px; }
.file-list { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 12px 10px; }
.file-list:empty { display: none; }
.file-chip { display: inline-flex; align-items: center; gap: 7px; max-width: 240px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--input); color: var(--muted); font-size: 11px; }
.file-chip span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.file-chip button { border: 0; background: none; color: var(--muted); padding: 0; }

.workspace,
.review-view { width: min(1080px, 100%); margin: 0 auto; padding: 44px 0 68px; }
.workspace-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 22px; }
.workspace-heading h1,
.review-heading h1 { font-size: clamp(27px, 3.6vw, 34px); }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.18fr) minmax(330px, 0.82fr); gap: 16px; align-items: start; }
.conversation-panel { min-height: 590px; display: flex; flex-direction: column; overflow: hidden; }
.messages { flex: 1; max-height: 520px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.message { max-width: 88%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; white-space: pre-wrap; font-size: 13px; }
.message.user { align-self: flex-end; background: var(--input); border-bottom-right-radius: 4px; }
.message.assistant { align-self: flex-start; background: var(--soft-accent); border-color: rgba(239, 87, 43, 0.34); border-bottom-left-radius: 4px; }
.message-label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: 0.1em; }
.followup-composer { border-top: 1px solid var(--line); padding: 12px; }
.followup-composer textarea { min-height: 72px; padding: 6px; font-size: 13px; }
.followup-actions { margin-top: 7px; }
.icon-button { width: 36px; height: 36px; border-radius: 8px; font-size: 18px; }
.primary-button.compact { min-height: 36px; padding: 7px 13px; font-size: 12px; }

.brief-panel { position: sticky; top: 16px; overflow: hidden; }
.brief-header { display: flex; align-items: center; justify-content: space-between; padding: 15px 17px; border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 800; }
.status-dot { display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: var(--accent); }
.brief-header .text-button,
.section-title-row .text-button { min-height: auto; border: 0; background: none; color: var(--muted); padding: 2px; }
.brief-content { padding: 3px 17px 10px; }
.brief-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.brief-item:last-child { border-bottom: 0; }
.brief-item dt { margin-bottom: 4px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.brief-item dd { margin: 0; font-size: 13px; font-weight: 650; white-space: pre-wrap; }
.brief-item.missing dd { color: var(--muted); font-weight: 450; font-style: italic; }
.brief-footer { padding: 15px 17px 17px; border-top: 1px solid var(--line); background: var(--card-alt); }
.brief-footer p { margin: 0 0 11px; color: var(--muted); font-size: 11px; }
.full-width { width: 100%; }

.back-button { margin-bottom: 24px; border: 0; background: transparent; color: var(--muted); padding: 0; font-size: 12px; font-weight: 700; }
.back-button:hover { color: var(--accent); }
.review-heading { max-width: 700px; margin-bottom: 24px; }
.review-heading p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.review-card { padding: 20px; }
.review-card h2,
.dialog-card h2 { margin: 0; font-size: 15px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); }
.section-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.review-summary-row { display: grid; grid-template-columns: 120px 1fr; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.review-summary-row span:first-child { color: var(--muted); }
.contact-card { display: flex; flex-direction: column; gap: 13px; }
.contact-card h2 { margin-bottom: 3px; }
.contact-card label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 650; }
.contact-card input,
.edit-grid input,
.edit-grid textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 10px 11px; background: var(--input); color: var(--text); outline: none; }
.contact-card input:focus,
.edit-grid input:focus,
.edit-grid textarea:focus { border-color: var(--accent); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.turnstile-wrap { min-height: 65px; margin-top: 3px; }
.preview-verification-note { display: flex; min-height: 58px; align-items: center; padding: 11px 12px; border: 1px dashed var(--line); border-radius: 9px; background: var(--input); color: var(--muted); font-size: 11px; }
.contact-card .consent-row { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 8px; font-weight: 450; line-height: 1.45; }
.consent-row input { width: 15px; height: 15px; margin-top: 1px; accent-color: var(--accent); }
.consent-row a { color: var(--accent); }
.form-error { display: none; padding: 9px 10px; border: 1px solid rgba(229, 104, 76, 0.35); border-radius: 8px; background: rgba(229, 104, 76, 0.1); color: var(--danger); font-size: 11px; }
.form-error.visible { display: block; }

.success-view { width: min(620px, 100%); margin: 0 auto; padding: 110px 0; text-align: center; }
.success-mark { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 18px; border-radius: 50%; background: var(--success); color: #fff; font-size: 24px; }
.success-view h1 { font-size: 34px; }
.success-view p { color: var(--muted); font-size: 14px; }

footer { min-height: 70px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
footer nav { display: flex; gap: 16px; }
footer a { text-decoration: none; }
footer a:hover { color: var(--accent); }

.loading-overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(7px); }
.loading-card { display: flex; flex-direction: column; align-items: center; gap: 7px; text-align: center; }
.loading-card span { color: var(--muted); font-size: 11px; }
.loader { width: 36px; height: 36px; margin-bottom: 8px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

dialog { width: min(780px, calc(100% - 30px)); max-height: 90vh; padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, 0.58); backdrop-filter: blur(4px); }
.dialog-card { padding: 20px; }
.dialog-header { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.dialog-header .eyebrow { margin-bottom: 5px; }
.dialog-close { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--input); color: var(--text); font-size: 20px; }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; max-height: 58vh; overflow-y: auto; padding-right: 4px; }
.edit-grid label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 650; }
.edit-grid label.wide { grid-column: 1 / -1; }
.edit-grid textarea { min-height: 80px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 17px; }

@media (max-width: 840px) {
  .workspace-grid,
  .review-grid { grid-template-columns: 1fr; }
  .brief-panel { position: static; }
  .conversation-panel { min-height: 500px; }
}

@media (max-width: 600px) {
  .page-shell { padding: 0 12px; }
  .site-header { min-height: 66px; }
  .logo-link img { width: 116px; }
  .secure-label { display: none; }
  .hero { padding: 46px 0 58px; }
  h1 { font-size: 30px; }
  .composer-card textarea { min-height: 190px; padding: 16px; font-size: 14px; }
  .composer-footer { flex-direction: column; align-items: stretch; }
  .upload-button,
  .composer-footer .primary-button { width: 100%; }
  .input-examples { flex-direction: column; gap: 5px; }
  .workspace,
  .review-view { padding: 32px 0 52px; }
  .workspace-heading { flex-direction: column; align-items: flex-start; }
  .messages { padding: 14px; }
  .message { max-width: 96%; }
  .form-row,
  .edit-grid { grid-template-columns: 1fr; }
  .edit-grid label.wide { grid-column: auto; }
  .review-card { padding: 16px; }
  .review-summary-row { grid-template-columns: 1fr; gap: 3px; }
  footer { min-height: auto; padding: 18px 0; align-items: flex-start; flex-direction: column; gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
