:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f3f6fa;
  font-synthesis: none;
  --ink: #172033;
  --muted: #667085;
  --line: #dce3ec;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --blue: #176bff;
  --blue-dark: #0f4fc4;
  --blue-soft: #e9f1ff;
  --green: #14804a;
  --orange: #e9651b;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(25, 42, 70, .10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: radial-gradient(circle at 80% -10%, #e5efff 0, transparent 30%), #f3f6fa; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(23, 107, 255, .24); outline-offset: 2px; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.topbar {
  min-height: 72px;
  padding: 0 clamp(20px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(220, 227, 236, .9);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); font-weight: 800; text-decoration: none; letter-spacing: -.025em; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: var(--blue); color: white; letter-spacing: -.05em; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.session-note { font-size: 13px; color: var(--muted); }
.language-control select { min-height: 36px; border: 1px solid var(--line); border-radius: 9px; background: white; padding: 0 30px 0 10px; font-weight: 700; }
.icon-button, .text-button { border: 0; background: transparent; color: var(--muted); font-weight: 700; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: white; }
.text-button:hover, .icon-button:hover { color: var(--blue); }

main { width: min(1480px, 100%); margin: 0 auto; }
.welcome-shell { min-height: calc(100vh - 72px); padding: clamp(48px, 8vw, 108px) clamp(24px, 6vw, 92px); display: grid; grid-template-columns: minmax(0, .95fr) minmax(420px, 1.05fr); gap: clamp(40px, 7vw, 100px); align-items: center; }
.welcome-copy h1 { max-width: 680px; margin: 12px 0 22px; font-size: clamp(44px, 5.6vw, 76px); line-height: .98; letter-spacing: -.065em; }
.eyebrow { display: inline-block; color: var(--blue); font-size: 13px; font-weight: 850; letter-spacing: .12em; }
.lede { max-width: 650px; color: var(--muted); font-size: clamp(18px, 1.6vw, 22px); line-height: 1.55; }
.mode-grid { margin-top: 36px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.mode-card { min-height: 180px; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; text-align: left; border: 1px solid var(--line); border-radius: 18px; padding: 24px; background: white; color: var(--ink); box-shadow: 0 10px 30px rgba(25, 42, 70, .05); transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.mode-card:hover { transform: translateY(-3px); border-color: #aac7ff; box-shadow: var(--shadow); }
.mode-card-primary { border-color: #90b7ff; background: linear-gradient(145deg, #fff 35%, #eef4ff); }
.mode-card strong { font-size: 20px; letter-spacing: -.025em; }
.mode-card > span:last-child { color: var(--muted); line-height: 1.5; }
.mode-badge { padding: 6px 8px; border-radius: 7px; background: var(--blue); color: white; font-size: 11px; font-weight: 850; letter-spacing: .09em; }
.mode-badge-neutral { background: #edf0f5; color: #536079; }
.privacy-line { margin-top: 26px; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.privacy-line > span:first-child { color: var(--green); }

.welcome-preview { perspective: 1400px; }
.preview-window { border-radius: 24px; overflow: hidden; background: white; border: 1px solid #d7e0eb; box-shadow: 0 40px 100px rgba(31, 53, 88, .20); transform: rotateY(-5deg) rotateX(2deg); }
.preview-window-bar { height: 46px; display: flex; align-items: center; gap: 7px; padding: 0 18px; background: #f4f6f9; border-bottom: 1px solid #e0e6ee; }
.preview-window-bar i { width: 10px; height: 10px; border-radius: 50%; background: #cbd3df; }
.preview-window-body { padding: clamp(22px, 4vw, 46px); }
.mini-stepper { display: grid; grid-template-columns: auto 1fr auto 1fr auto 1fr auto 1fr auto 1fr auto; align-items: center; color: var(--blue); }
.mini-stepper b { width: 28px; height: 28px; display: grid; place-items: center; border: 2px solid currentColor; border-radius: 50%; font-size: 12px; }
.mini-stepper span { height: 2px; background: #dce5f3; }
.preview-window-body > p { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .1em; }
.preview-posts { display: grid; grid-template-columns: 1fr 1fr .8fr; align-items: end; gap: 12px; margin-top: 28px; }
.preview-posts img { width: 100%; border-radius: 10px; box-shadow: 0 8px 20px rgba(17, 31, 54, .15); }
.preview-check { margin-top: 28px; padding: 14px 16px; background: #edf9f2; border-radius: 10px; color: #236340; font-size: 14px; font-weight: 700; }
.preview-check span { display: inline-grid; place-items: center; width: 23px; height: 23px; margin-right: 6px; background: var(--green); color: white; border-radius: 50%; }

.wizard-shell { padding: 28px clamp(18px, 4vw, 62px) 60px; }
.stepper { display: grid; grid-template-columns: repeat(6, minmax(100px, 1fr)); margin-bottom: 24px; overflow-x: auto; padding-bottom: 4px; }
.step-button { position: relative; min-width: 112px; border: 0; background: transparent; padding: 10px 8px 14px; color: #8a94a6; font-size: 13px; font-weight: 750; text-align: left; border-bottom: 3px solid #dfe5ed; }
.step-button span { display: block; margin-bottom: 5px; font-size: 11px; letter-spacing: .06em; }
.step-button.active { color: var(--blue); border-color: var(--blue); }
.step-button.done { color: var(--green); border-color: #8dd2ad; }
.wizard-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 24px; align-items: start; }
.workspace-card, .context-panel { background: rgba(255, 255, 255, .95); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 10px 30px rgba(25, 42, 70, .055); }
.workspace-card { min-height: 680px; overflow: hidden; }
#step-content { padding: clamp(24px, 4vw, 48px); }
.context-panel { padding: 24px; position: sticky; top: 96px; }
.context-panel h3 { margin: 0 0 16px; font-size: 16px; }
.context-panel p, .context-panel li { color: var(--muted); font-size: 14px; line-height: 1.5; }
.context-list { display: grid; gap: 12px; padding: 0; margin: 0; list-style: none; }
.context-list li { padding: 12px; border-radius: 10px; background: var(--surface-soft); }
.context-list strong { display: block; color: var(--ink); margin-bottom: 3px; }
.wizard-navigation { min-height: 76px; border-top: 1px solid var(--line); padding: 14px clamp(24px, 4vw, 48px); display: flex; justify-content: space-between; align-items: center; gap: 16px; background: #fafbfd; }
.navigation-right { display: flex; align-items: center; gap: 16px; }

.step-header { margin-bottom: 32px; }
.step-header h1 { margin: 8px 0 10px; font-size: clamp(30px, 4vw, 44px); letter-spacing: -.045em; }
.step-header p { max-width: 760px; color: var(--muted); line-height: 1.55; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; gap: 8px; align-content: start; }
.field.full { grid-column: 1 / -1; }
.field > span, .field-label { font-size: 14px; font-weight: 760; color: #364158; }
.field small { color: var(--muted); line-height: 1.4; }
.field input, .field textarea, .field select, .input-like { width: 100%; min-height: 46px; border: 1px solid #cfd8e5; border-radius: 10px; padding: 11px 13px; background: white; color: var(--ink); }
.field textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.field input[type="color"] { padding: 5px; min-height: 48px; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23, 107, 255, .11); outline: none; }
.field.invalid input, .field.invalid textarea { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 13px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 32px 0 16px; }
.section-heading h2, .section-heading h3 { margin: 0; letter-spacing: -.025em; }
.button { min-height: 44px; border-radius: 10px; padding: 0 17px; border: 1px solid transparent; font-weight: 800; }
.button-primary { background: var(--blue); color: white; }
.button-primary:hover { background: var(--blue-dark); }
.button-secondary { background: white; border-color: var(--line); color: var(--ink); }
.button-secondary:hover { border-color: #aab8ca; }
.button-quiet { background: var(--blue-soft); color: var(--blue-dark); }
.button-danger { background: #fff0ee; color: var(--danger); }
.button:disabled { cursor: not-allowed; opacity: .48; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.notice { padding: 15px 17px; border: 1px solid #c9dafb; border-radius: 11px; background: #f1f6ff; color: #395276; line-height: 1.5; }
.notice-warning { border-color: #f4d6ac; background: #fff8ed; color: #7a4b13; }
.notice-success { border-color: #b9e2cb; background: #effaf4; color: #275f40; }

.upload-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.upload-card { min-height: 170px; border: 1.5px dashed #bdc8d8; border-radius: 12px; background: #fbfcfe; padding: 16px; display: grid; place-items: center; text-align: center; position: relative; overflow: hidden; }
.upload-card input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-card strong { display: block; margin-bottom: 5px; }
.upload-card span { color: var(--muted); font-size: 13px; }
.upload-preview { width: 100%; height: 138px; object-fit: contain; border-radius: 8px; background: white; }
.source-list { display: grid; gap: 14px; }
.source-card { display: grid; grid-template-columns: minmax(170px, .8fr) minmax(260px, 1.5fr) minmax(170px, 1fr) auto; gap: 12px; align-items: start; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfe; }
.source-card input, .source-card select { width: 100%; min-height: 42px; border: 1px solid #cfd8e5; border-radius: 8px; padding: 8px 10px; }
.source-status { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
.source-status.success { color: var(--green); }
.source-status.error { color: var(--danger); }

.analysis-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.analysis-grid .field textarea { min-height: 140px; }
.plan-list { display: grid; gap: 18px; }
.plan-card { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.plan-card-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; background: #f7f9fc; border-bottom: 1px solid var(--line); }
.plan-card-header h3 { margin: 0; }
.plan-card-body { padding: 18px; }
.format-pill { padding: 7px 10px; border-radius: 999px; background: #eaf1ff; color: #315d9b; font-size: 12px; font-weight: 800; }

.editor-layout { display: grid; grid-template-columns: minmax(360px, .9fr) minmax(360px, 1.1fr); gap: 24px; align-items: start; }
.preview-panel { position: sticky; top: 96px; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.preview-stage { min-height: 560px; display: grid; place-items: center; padding: 18px; border-radius: 14px; background: #e9edf3; overflow: hidden; }
.preview-stage img { max-height: 620px; width: auto; border-radius: 6px; box-shadow: 0 14px 34px rgba(22, 35, 56, .20); }
.post-tabs, .frame-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab-button { min-height: 38px; border: 1px solid var(--line); border-radius: 9px; background: white; padding: 0 12px; color: var(--muted); font-weight: 750; }
.tab-button.active { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.editor-fields { display: grid; gap: 16px; }
.approval-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; border-radius: 10px; background: #f5f8fc; }
.check-row { display: flex; align-items: flex-start; gap: 10px; color: #435069; line-height: 1.45; }
.check-row input { width: 18px; height: 18px; margin-top: 2px; }

.final-checklist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 0; list-style: none; }
.final-checklist li { display: flex; gap: 10px; padding: 13px 14px; border-radius: 10px; background: #f6f8fb; color: #435069; }
.final-checklist li::before { content: "✓"; width: 22px; height: 22px; flex: 0 0 22px; display: grid; place-items: center; border-radius: 50%; background: var(--green); color: white; font-size: 12px; font-weight: 900; }
.download-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.download-card { min-height: 110px; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 18px; background: white; color: var(--ink); text-align: left; }
.download-card:hover { border-color: #9ebcff; background: #f8fbff; }
.download-card strong { font-size: 17px; }
.download-card span { color: var(--muted); font-size: 13px; }

.modal { width: min(600px, calc(100% - 32px)); border: 0; border-radius: 18px; padding: 0; box-shadow: 0 28px 90px rgba(18, 31, 52, .32); }
.modal::backdrop { background: rgba(19, 29, 46, .60); backdrop-filter: blur(3px); }
.modal > form, .modal > div { padding: 34px; position: relative; }
.modal h2 { margin: 8px 0 10px; font-size: 30px; letter-spacing: -.04em; }
.modal p { color: var(--muted); line-height: 1.5; }
.modal-close { position: absolute; top: 15px; right: 15px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #f0f3f7; color: #536079; font-size: 22px; }
.modal-actions { margin-top: 22px; display: flex; justify-content: flex-end; gap: 10px; }
.cost-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 20px 0; }
.cost-summary div { padding: 12px; border-radius: 9px; background: #f5f7fa; }
.cost-summary span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.modal-wide { width: min(760px, calc(100% - 32px)); }
.help-list { padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.help-list li { display: grid; gap: 4px; padding: 15px; background: #f6f8fb; border-radius: 10px; }
.help-list li span { color: var(--muted); line-height: 1.4; }
.toast-region { position: fixed; right: 22px; bottom: 22px; z-index: 100; display: grid; gap: 10px; }
.toast { max-width: 380px; padding: 14px 16px; border-radius: 10px; background: #172033; color: white; box-shadow: var(--shadow); animation: toast-in .18s ease; }
.toast.error { background: #922b21; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
.loading { position: relative; pointer-events: none; opacity: .7; }
.loading::after { content: ""; width: 20px; height: 20px; border: 3px solid #ffffff66; border-top-color: white; border-radius: 50%; animation: spin .8s linear infinite; position: absolute; left: calc(50% - 10px); top: calc(50% - 10px); }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1040px) {
  .session-note { display: none; }
  .welcome-shell { grid-template-columns: 1fr; }
  .welcome-preview { max-width: 720px; }
  .wizard-layout { grid-template-columns: 1fr; }
  .context-panel { position: static; }
  .editor-layout { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
}

@media (max-width: 720px) {
  .topbar { padding: 0 15px; }
  .brand > span:last-child, #logout-button { display: none; }
  .topbar-actions { gap: 6px; }
  .welcome-shell { padding: 42px 18px; }
  .welcome-copy h1 { font-size: 44px; }
  .mode-grid, .form-grid, .form-grid.three, .analysis-grid, .upload-grid, .download-grid, .final-checklist { grid-template-columns: 1fr; }
  .preview-window { transform: none; }
  .wizard-shell { padding: 18px 10px 40px; }
  #step-content { padding: 22px 18px; }
  .source-card { grid-template-columns: 1fr; }
  .cost-summary { grid-template-columns: 1fr; }
  .help-list { grid-template-columns: 1fr; }
  .wizard-navigation { align-items: stretch; flex-direction: column-reverse; }
  .navigation-right { justify-content: space-between; }
  .button { min-height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
