:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #111827;
  --muted: #667085;
  --line: #d7dee8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #b42318;
  --success: #067647;
  --shadow: 0 18px 45px rgba(15, 23, 42, .12);
  --radius: 18px;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1018;
  --surface: #121925;
  --surface-2: #192231;
  --text: #f8fafc;
  --muted: #a8b2c1;
  --line: #2b3748;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --danger: #f97066;
  --success: #47cd89;
  --shadow: 0 22px 60px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, select, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.site-header { height: 72px; padding: 0 clamp(18px,4vw,64px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 20; }
.brand { display: inline-flex; gap: 10px; align-items: center; font-weight: 800; text-decoration: none; letter-spacing: -.02em; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; background: var(--text); color: var(--surface); border-radius: 10px; transform: rotate(-4deg); }
.header-actions { display: flex; gap: 10px; align-items: center; }
.privacy-badge { color: var(--success); border: 1px solid color-mix(in srgb, var(--success) 35%, var(--line)); padding: 7px 11px; border-radius: 999px; font-size: .82rem; font-weight: 700; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 10px; cursor: pointer; }
main { width: min(1500px, calc(100% - 32px)); margin: 0 auto; }
.hero { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(280px,.8fr); gap: 40px; align-items: end; padding: clamp(54px,8vw,110px) 0 48px; }
.eyebrow, .label { display: block; text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 800; color: var(--accent); margin-bottom: 10px; }
h1 { max-width: 850px; margin: 0; font-size: clamp(2.35rem,6vw,5.6rem); line-height: .98; letter-spacing: -.065em; }
.hero-copy p { max-width: 800px; color: var(--muted); font-size: clamp(1.02rem,1.4vw,1.25rem); line-height: 1.65; }
.security-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; background: var(--surface); box-shadow: var(--shadow); }
.security-card strong { display: block; margin-bottom: 8px; }
.security-card p { color: var(--muted); line-height: 1.55; margin: 0; }
.upload-panel { min-height: 340px; border: 2px dashed var(--line); border-radius: 24px; background: var(--surface); display: grid; place-items: center; align-content: center; text-align: center; padding: 34px; transition: .2s ease; }
.upload-panel.dragover { border-color: var(--accent); transform: translateY(-2px); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.upload-panel h2 { margin: 10px 0 5px; font-size: clamp(1.6rem,3vw,2.4rem); }
.upload-panel p { color: var(--muted); margin: 4px 0 20px; }
.upload-icon { width: 68px; height: 68px; border-radius: 18px; display: grid; place-items: center; background: var(--surface-2); font-size: 1.7rem; }
.primary-button, .secondary-button, .tool-button, .text-button { border: 0; cursor: pointer; font-weight: 750; }
.primary-button { background: var(--accent); color: white; padding: 13px 18px; border-radius: 12px; }
.primary-button:hover { background: var(--accent-hover); }
.secondary-button { background: var(--surface-2); color: var(--text); padding: 13px 18px; border-radius: 12px; border: 1px solid var(--line); }
.small-note { font-size: .82rem; margin-top: 18px !important; }
.workspace { margin-top: 8px; display: grid; grid-template-columns: 230px minmax(480px,1fr) 290px; min-height: 720px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); }
.sidebar, .export-panel { padding: 20px; background: color-mix(in srgb, var(--surface) 96%, var(--surface-2)); }
.sidebar { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.sidebar-heading { display: flex; justify-content: space-between; gap: 10px; align-items: start; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.sidebar-heading strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.text-button { background: none; color: var(--accent); padding: 2px; }
.page-list { padding: 14px 0; display: grid; gap: 12px; overflow: auto; flex: 1; }
.page-thumb { width: 100%; border: 2px solid transparent; border-radius: 12px; padding: 8px; background: var(--surface-2); color: var(--text); cursor: pointer; text-align: left; }
.page-thumb.active { border-color: var(--accent); }
.page-thumb canvas { display: block; width: 100%; height: auto; border-radius: 5px; background: white; }
.page-thumb span { display: block; margin-top: 7px; font-size: .78rem; color: var(--muted); text-align: center; }
.sidebar-footer { border-top: 1px solid var(--line); padding-top: 12px; }
.status-line { display: flex; justify-content: space-between; padding: 5px 0; font-size: .86rem; color: var(--muted); }
.status-line strong { color: var(--text); }
.editor-shell { min-width: 0; background: var(--surface-2); display: flex; flex-direction: column; }
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.toolbar-group { display: flex; gap: 7px; align-items: center; }
.tool-button { padding: 9px 11px; border-radius: 9px; background: var(--surface-2); color: var(--text); border: 1px solid transparent; font-size: .86rem; }
.tool-button.active { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.tool-button:disabled { opacity: .4; cursor: not-allowed; }
.tool-button.danger:not(:disabled) { color: var(--danger); }
.zoom-controls output { width: 48px; text-align: center; font-size: .82rem; color: var(--muted); }
.canvas-stage { flex: 1; overflow: auto; padding: 34px; display: grid; place-items: start center; min-height: 590px; }
.canvas-wrapper { position: relative; box-shadow: 0 8px 30px rgba(15,23,42,.2); background: white; transform-origin: top center; }
.canvas-wrapper canvas { display: block; }
#overlayCanvas { position: absolute; inset: 0; cursor: crosshair; touch-action: none; }
.editor-tip { padding: 10px 16px; background: var(--surface); border-top: 1px solid var(--line); color: var(--muted); font-size: .84rem; display: flex; gap: 8px; }
.export-panel { border-left: 1px solid var(--line); }
.export-panel h2 { margin: 0 0 8px; }
.export-panel > p { color: var(--muted); line-height: 1.5; font-size: .9rem; }
.field-label { display: block; font-size: .8rem; font-weight: 800; margin: 18px 0 7px; }
select { width: 100%; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
.checkbox-row { display: flex; align-items: center; gap: 9px; margin: 18px 0; font-size: .88rem; }
.full-width { width: 100%; margin-bottom: 10px; }
.warning-box { padding: 14px; margin-top: 12px; border: 1px solid color-mix(in srgb, #f79009 40%, var(--line)); background: color-mix(in srgb, #f79009 8%, var(--surface)); border-radius: 12px; }
.warning-box p { color: var(--muted); margin: 5px 0 0; font-size: .82rem; line-height: 1.45; }
.feature-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; padding: 44px 0 70px; }
.feature-grid article { border: 1px solid var(--line); border-radius: 16px; padding: 22px; background: var(--surface); }
.feature-grid article > span { color: var(--accent); font-weight: 900; }
.feature-grid h3 { margin: 16px 0 8px; }
.feature-grid p { margin: 0; color: var(--muted); line-height: 1.5; }
dialog { width: min(1100px,94vw); height: min(850px,90vh); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(2,6,23,.72); backdrop-filter: blur(5px); }
.dialog-header { height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; border-bottom: 1px solid var(--line); }
.preview-body { height: calc(100% - 68px); overflow: auto; padding: 20px; background: var(--surface-2); }
.preview-body img { display: block; max-width: 100%; margin: 0 auto; box-shadow: var(--shadow); }
.progress-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(2,6,23,.72); display: grid; place-items: center; backdrop-filter: blur(6px); }
.progress-card { width: min(420px,calc(100% - 32px)); background: var(--surface); padding: 28px; border-radius: 18px; box-shadow: var(--shadow); text-align: center; }
.spinner { width: 42px; height: 42px; border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%; margin: 0 auto 18px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
progress { width: 100%; height: 9px; }
.toast { position: fixed; z-index: 120; left: 50%; bottom: 28px; transform: translate(-50%,25px); opacity: 0; pointer-events: none; background: var(--text); color: var(--surface); padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
footer { width: min(1500px,calc(100% - 32px)); margin: 0 auto; display: flex; justify-content: space-between; padding: 22px 0 32px; color: var(--muted); border-top: 1px solid var(--line); }
footer nav { display: flex; gap: 18px; }
footer a { text-decoration: none; }
@media (max-width: 1120px) {
  .workspace { grid-template-columns: 180px minmax(420px,1fr); }
  .export-panel { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px 16px; }
  .export-panel h2, .export-panel > p, .warning-box { grid-column: 1 / -1; }
  .field-label { margin-top: 4px; }
}
@media (max-width: 760px) {
  main { width: min(100% - 20px,1500px); }
  .privacy-badge { display: none; }
  .hero { grid-template-columns: 1fr; padding-top: 48px; }
  .workspace { display: block; min-height: auto; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .page-list { display: flex; overflow-x: auto; }
  .page-thumb { width: 120px; flex: 0 0 auto; }
  .sidebar-footer { display: none; }
  .canvas-stage { padding: 16px; min-height: 430px; }
  .toolbar { justify-content: flex-start; }
  .export-panel { display: block; }
  .feature-grid { grid-template-columns: 1fr; }
  footer { align-items: center; gap: 16px; flex-direction: column; }
}
