:root {
  --ink: #20201e;
  --muted: #77756e;
  --muted-2: #a19f97;
  --paper: #f3f2ee;
  --surface: #ffffff;
  --surface-soft: #f8f7f3;
  --line: #dfded7;
  --line-strong: #c7c5bb;
  --accent: #b98d5b;
  --accent-dark: #8c6742;
  --sage: #61756a;
  --danger: #a44c46;
  --shadow: 0 18px 50px rgba(34, 33, 28, .08);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; line-height: 1.5; }
button, input, textarea, select { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .drop-zone:focus-visible { outline: 3px solid rgba(97, 117, 106, .35); outline-offset: 2px; }

.app-shell { min-height: 100vh; }
.topbar { min-height: 74px; padding: 0 34px; display: flex; align-items: center; justify-content: space-between; gap: 24px; background: rgba(255,255,255,.84); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; backdrop-filter: blur(14px); }
.brand-lockup, .topbar-meta, .section-label-row, .optimizer-row, .optimizer-controls, .form-actions, .output-heading, .output-actions, .card-header, .card-header-actions, .review-item, .media-item, .media-meta, .media-actions { display: flex; align-items: center; }
.brand-lockup { gap: 12px; }
.brand-mark { width: 31px; height: 31px; display: grid; place-items: center; color: #fff; background: var(--ink); border-radius: 50%; font-family: Georgia, serif; font-size: 17px; }
.brand-name { margin: 0; font-size: 12px; letter-spacing: .18em; font-weight: 700; }
.brand-subtitle { margin: 1px 0 0; color: var(--muted); font-size: 11px; letter-spacing: .04em; }
.topbar-meta { gap: 9px; color: var(--muted); font-size: 11px; letter-spacing: .03em; }
.status-dot { width: 7px; height: 7px; background: var(--sage); border-radius: 50%; box-shadow: 0 0 0 4px rgba(97,117,106,.12); }
.divider { width: 1px; height: 15px; background: var(--line-strong); }

.workspace { width: min(1520px, calc(100% - 40px)); margin: 0 auto; padding: 34px 0 60px; display: grid; grid-template-columns: minmax(360px, .88fr) minmax(500px, 1.12fr); gap: 26px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.input-panel { padding: 28px; }
.output-panel { padding: 28px; min-height: 800px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.panel-heading h1, .panel-heading h2 { margin: 4px 0 4px; font-family: Georgia, "Times New Roman", serif; font-weight: 400; letter-spacing: -.025em; font-size: clamp(28px, 3vw, 38px); }
.panel-intro { max-width: 470px; margin: 0; color: var(--muted); font-size: 13px; }
.eyebrow, .card-kicker, .section-label { margin: 0; color: var(--accent-dark); font-size: 10px; letter-spacing: .16em; font-weight: 700; text-transform: uppercase; }
.step-badge, .review-badge { padding: 5px 9px; color: var(--sage); background: #eef3ef; border: 1px solid #d7e2da; border-radius: 999px; font-size: 10px; letter-spacing: .07em; text-transform: uppercase; white-space: nowrap; }

.field { display: grid; gap: 7px; margin-bottom: 17px; }
.field > span { color: #4d4a43; font-size: 12px; font-weight: 650; }
.field em { color: var(--danger); font-style: normal; }
.field input, .field textarea, .field select, .compact-field input, .compact-field select { width: 100%; color: var(--ink); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; transition: border .15s ease, box-shadow .15s ease, background .15s ease; }
.field input:hover, .field textarea:hover, .field select:hover { border-color: var(--line-strong); }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--sage); background: #fff; box-shadow: 0 0 0 4px rgba(97,117,106,.08); outline: none; }
.field textarea { resize: vertical; min-height: 76px; }
.field-grid { display: grid; gap: 14px; }
.two-up { grid-template-columns: 1fr 1fr; }
.field-hint { margin: -2px 0 0; color: var(--muted-2); font-size: 11px; }
.market-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.check-card { min-height: 62px; padding: 9px; display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 7px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 11px; cursor: pointer; }
.check-card:has(input:checked) { color: var(--sage); background: #f0f5f1; border-color: #a9bcae; }
.check-card input { accent-color: var(--sage); }
.check-card span { font-weight: 750; font-size: 12px; }
.check-card small { grid-column: 2; color: var(--muted-2); font-size: 9px; white-space: nowrap; }

.upload-block { margin-top: 7px; padding-top: 20px; border-top: 1px solid var(--line); }
.section-label-row { justify-content: space-between; margin-bottom: 9px; }
.muted-label { color: var(--muted-2); font-size: 11px; }
.drop-zone { min-height: 150px; padding: 20px; display: grid; place-items: center; align-content: center; gap: 4px; text-align: center; color: var(--muted); background: repeating-linear-gradient(135deg, #faf9f6, #faf9f6 8px, #f6f5f0 8px, #f6f5f0 16px); border: 1px dashed #bcb9ae; border-radius: 16px; cursor: pointer; }
.drop-zone:hover, .drop-zone.is-dragover { color: var(--ink); border-color: var(--sage); background: #f2f6f2; }
.drop-zone strong { color: var(--ink); font-size: 14px; }
.drop-zone > span:not(.drop-icon) { font-size: 11px; }
.drop-icon { width: 29px; height: 29px; display: grid; place-items: center; color: var(--accent-dark); border: 1px solid #d5c3ab; border-radius: 50%; font-size: 22px; line-height: 1; }
.text-button { margin-top: 4px; padding: 0; color: var(--accent-dark); background: transparent; border: 0; font-size: 11px; text-decoration: underline; text-underline-offset: 3px; }
.media-list { display: grid; gap: 8px; margin-top: 12px; }
.media-item { gap: 10px; padding: 8px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 12px; }
.media-thumb { width: 52px; height: 52px; object-fit: cover; flex: 0 0 auto; border-radius: 8px; background: #e9e7e0; }
.media-meta { min-width: 0; flex: 1; display: block; }
.media-name { display: block; overflow: hidden; color: var(--ink); font-size: 11px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.media-sub { display: block; color: var(--muted-2); font-size: 10px; }
.media-status { color: var(--sage); font-size: 10px; white-space: nowrap; }
.media-status.pending { color: var(--muted); }

.optimizer-row { justify-content: space-between; gap: 16px; margin: 18px 0; padding: 14px; background: #faf9f6; border: 1px solid var(--line); border-radius: 14px; }
.optimizer-controls { justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.compact-field { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; }
.compact-field input, .compact-field select { width: auto; min-width: 67px; padding: 7px 8px; border-radius: 8px; font-size: 11px; }
.compact-field input[type="range"] { width: 74px; padding: 0; accent-color: var(--sage); }
.compact-field em, .compact-field output { color: var(--muted-2); font-style: normal; font-size: 10px; }
.advanced-settings { margin: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.advanced-settings summary { padding: 13px 0; color: var(--muted); cursor: pointer; font-size: 12px; }
.advanced-content { padding: 2px 0 12px; }
.warning-text { color: #966553; }

.form-actions { gap: 9px; padding-top: 4px; }
.primary-button, .secondary-button, .ghost-button, .copy-field, .mini-tab { border-radius: 10px; transition: transform .15s ease, background .15s ease, border .15s ease; }
.primary-button, .secondary-button, .ghost-button { min-height: 42px; padding: 0 15px; border: 1px solid transparent; font-size: 12px; font-weight: 700; }
.primary-button { color: #fff; background: var(--ink); }
.primary-button:hover { background: #3a3934; transform: translateY(-1px); }
.secondary-button { color: var(--sage); background: #eef3ef; border-color: #cedbd0; }
.secondary-button:hover { background: #e1ece3; }
.ghost-button { color: var(--muted); background: transparent; border-color: var(--line); }
.ghost-button:hover { color: var(--ink); border-color: var(--line-strong); background: var(--surface-soft); }
.small { min-height: 34px; padding: 0 11px; font-size: 11px; }

.output-heading { align-items: flex-start; justify-content: space-between; gap: 16px; }
.output-actions { gap: 8px; padding-top: 2px; }
.status-banner { min-height: 39px; margin: -3px 0 17px; padding: 9px 11px; display: flex; align-items: center; gap: 9px; border-radius: 10px; font-size: 11px; }
.status-banner.idle { color: var(--muted); background: #f7f6f2; border: 1px solid var(--line); }
.status-banner.working { color: #7d633e; background: #fbf5eb; border: 1px solid #ead8ba; }
.status-banner.success { color: #4c6f58; background: #eff7f0; border: 1px solid #cce0cf; }
.status-banner.error { color: var(--danger); background: #fcf1f0; border: 1px solid #ebcbc8; }
.status-light { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--muted-2); }
.working .status-light { background: var(--accent); animation: pulse 1s infinite alternate; }
.success .status-light { background: var(--sage); }
.error .status-light { background: var(--danger); }
@keyframes pulse { to { opacity: .35; } }
.output-stack { display: grid; gap: 14px; }
.output-card { padding: 16px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 15px; }
.featured-card { background: #fbfaf6; border-color: #d9cbb9; }
.card-header { justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card-header h3 { margin: 2px 0 0; font-size: 13px; font-weight: 700; }
.card-kicker { color: var(--muted-2); font-size: 9px; }
.copy-field { padding: 5px 8px; color: var(--sage); background: transparent; border: 1px solid #cbd8cc; font-size: 10px; }
.copy-field:hover { background: #eaf1eb; }
.card-header-actions { gap: 5px; }
.mini-tab { padding: 4px 7px; color: var(--muted); background: transparent; border: 1px solid transparent; font-size: 10px; }
.mini-tab.is-active { color: var(--sage); background: #eaf1eb; border-color: #cbd8cc; }
.output-grid { display: grid; gap: 14px; }
.two-column { grid-template-columns: 1fr 1fr; }
.output-text { width: 100%; min-height: 42px; padding: 10px; color: #45433d; background: #fff; border: 1px solid var(--line); border-radius: 9px; resize: vertical; font-size: 12px; line-height: 1.55; }
.output-text:focus { outline: none; border-color: var(--sage); }
.title-output { min-height: 58px; font-family: Georgia, "Times New Roman", serif; font-size: 18px; }
.description-output { min-height: 170px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; }
.description-preview { min-height: 170px; padding: 15px; color: #44423b; background: #fff; border: 1px solid var(--line); border-radius: 9px; font-size: 13px; }
.description-preview h3 { margin: 0 0 8px; font-family: Georgia, serif; font-size: 18px; font-weight: 400; }
.description-preview ul { margin: 8px 0 0; padding-left: 19px; }
.tall { min-height: 126px; }
.char-count { margin-top: 5px; color: var(--muted-2); text-align: right; font-size: 10px; }
.alt-list, .review-list { display: grid; gap: 8px; }
.alt-row { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 9px; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 9px; }
.alt-row img { width: 38px; height: 38px; object-fit: cover; border-radius: 6px; }
.alt-copy { min-width: 0; }
.alt-copy strong, .alt-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alt-copy strong { color: var(--ink); font-size: 10px; }
.alt-copy span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.review-item { align-items: flex-start; gap: 9px; padding: 9px 10px; background: #fff; border: 1px solid var(--line); border-radius: 9px; font-size: 11px; }
.review-icon { width: 18px; height: 18px; display: grid; place-items: center; flex: 0 0 auto; color: #966553; background: #fff3e8; border-radius: 50%; font-size: 10px; }
.review-item.ok .review-icon { color: var(--sage); background: #edf6ef; }
.empty-state { margin: 0; color: var(--muted-2); font-size: 11px; }
.app-footer { width: min(1520px, calc(100% - 40px)); margin: 0 auto; padding: 0 0 30px; display: flex; justify-content: space-between; gap: 14px; color: var(--muted-2); font-size: 10px; letter-spacing: .03em; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: min(360px, calc(100% - 48px)); padding: 11px 14px; color: #fff; background: var(--ink); border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; font-size: 12px; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 1120px) {
  .workspace { grid-template-columns: 1fr; }
  .output-panel { min-height: 0; }
}
@media (max-width: 680px) {
  .topbar { padding: 0 17px; }
  .topbar-meta { display: none; }
  .workspace { width: min(100% - 22px, 640px); padding-top: 16px; }
  .app-footer { width: min(100% - 22px, 640px); display: block; line-height: 1.8; }
  .input-panel, .output-panel { padding: 18px; border-radius: 18px; }
  .two-up, .two-column { grid-template-columns: 1fr; }
  .market-grid { grid-template-columns: repeat(2, 1fr); }
  .optimizer-row { display: block; }
  .optimizer-controls { justify-content: flex-start; margin-top: 11px; }
  .output-heading { display: block; }
  .output-actions { margin-top: 13px; }
  .form-actions { flex-wrap: wrap; }
  .primary-button { flex: 1 1 180px; }
}
