:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f8f9fc;
  --panel-muted: #f3f5f9;
  --text: #12151d;
  --text-2: #2c3240;
  --muted: #778092;
  --muted-2: #9aa2b1;
  --line: #e3e7ef;
  --line-strong: #d7dce7;
  --primary: #5d55f5;
  --primary-2: #6f65ff;
  --primary-dark: #4b43db;
  --primary-soft: #f1efff;
  --primary-soft-2: #e9e7ff;
  --success: #10a36c;
  --success-soft: #effbf6;
  --danger: #ff3d57;
  --danger-soft: #fff3f5;
  --warning: #f4a11b;
  --shadow-panel: 0 8px 24px rgba(39, 48, 72, .055), 0 1px 2px rgba(39, 48, 72, .035);
  --shadow-button: 0 10px 24px rgba(83, 76, 235, .22);
  --radius-panel: 20px;
  --topbar-h: 92px;
  --workspace-gap: 16px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
html { background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background:
    radial-gradient(circle at 52% -150px, rgba(101, 94, 244, .075), transparent 460px),
    var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select { font: inherit; }
button { color: inherit; }
button, select, .file-card, .object-item, .thumbnail-card { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(93, 85, 245, .19);
  outline-offset: 2px;
}
.hidden { display: none !important; }
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
::selection { background: rgba(93,85,245,.16); }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Header ---------- */
.topbar {
  height: var(--topbar-h);
  padding: 0 28px 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid rgba(225,229,238,.95);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}
.brand-mark { width: 56px; height: 56px; display: block; flex: 0 0 auto; }
.brand-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.brand-name {
  font-size: 26px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -.85px;
  color: #111318;
}
.brand-name span { color: var(--primary); }
.brand-subtitle { font-size: 11px; color: #7b8496; font-weight: 500; white-space: nowrap; }

.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 14px; min-width: 0; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid #e0e6ec;
  border-radius: 999px;
  background: #fff;
  color: #3e4a50;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(33,42,61,.03);
}
.status-pill i { width: 8px; height: 8px; border-radius: 50%; background: #b8bdc8; }
.status-ready { border-color: #dcebe5; background: #fbfefd; }
.status-ready i { background: var(--success); box-shadow: 0 0 0 4px rgba(16,163,108,.10); }
.status-error { color: #8d4050; background: #fffafb; border-color: #f1dce1; }
.status-error i { background: var(--danger); box-shadow: 0 0 0 4px rgba(255,61,87,.08); }
.storage-note { color: #8c94a4; font-size: 10px; white-space: nowrap; }

.theme-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #f8f9fc;
}
.theme-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #7c8494;
  cursor: pointer;
  transition: .16s ease;
}
.theme-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-btn:first-child { color: var(--warning); }
.theme-btn:last-child { color: var(--primary); }
.theme-btn.active { background: #fff; box-shadow: 0 2px 7px rgba(31,38,57,.08); }
.privacy-button {
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: #282d38;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 7px rgba(31,38,57,.03);
  transition: .16s ease;
}
.privacy-button:hover { border-color: #d4d9e3; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(31,38,57,.06); }
.privacy-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Main layout ---------- */
.workspace {
  flex: 1;
  width: 100%;
  display: grid;
  grid-template-columns: 280px minmax(520px, 1fr) 360px;
  gap: var(--workspace-gap);
  padding: 16px 18px 18px;
  min-height: calc(100vh - var(--topbar-h));
  align-items: stretch;
}
.panel {
  min-width: 0;
  min-height: 0;
  background: rgba(255,255,255,.97);
  border: 1px solid rgba(224,228,237,.98);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
}
.panel-heading {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
}
.panel-heading h2 { margin: 3px 0 0; font-size: 15px; line-height: 1.15; letter-spacing: -.25px; }
.eyebrow { margin: 0; color: #939bac; font-size: 9px; line-height: 1; text-transform: uppercase; font-weight: 800; letter-spacing: .18em; }
.circle-icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  transition: .16s ease;
}
.circle-icon-btn:hover { background: #f7f8fc; border-color: #d2d8e2; }
.circle-icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

/* ---------- Library ---------- */
.library-panel {
  height: calc(100vh - var(--topbar-h) - 34px);
  display: flex;
  flex-direction: column;
}
.library-upload {
  padding: 16px 16px 14px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}
.library-upload-button {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 13px;
  background: linear-gradient(135deg, #635bff 0%, #564cf0 100%);
  color: #fff;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 11px 24px rgba(80,72,232,.22), inset 0 1px 0 rgba(255,255,255,.16);
  transition: .18s ease;
}
.library-upload-button:hover { transform: translateY(-1px); box-shadow: 0 14px 28px rgba(80,72,232,.25), inset 0 1px 0 rgba(255,255,255,.18); }
.library-upload-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.library-upload p { margin: 10px 0 0; color: #8992a2; font-size: 9px; line-height: 1.45; }
.library-upload p span { color: #a3aab7; }
.file-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 11px 10px;
  scrollbar-width: thin;
  scrollbar-color: #d9dee8 transparent;
}
.file-card {
  width: 100%;
  min-height: 68px;
  display: grid;
  grid-template-columns: 68px minmax(0,1fr) 22px;
  align-items: center;
  gap: 10px;
  margin: 0 0 7px;
  padding: 7px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: .15s ease;
}
.file-card:hover { background: #f8f9fc; }
.file-card.active { background: #f4f2ff; border-color: #7a71ff; box-shadow: inset 0 0 0 1px rgba(103,95,245,.08); }
.file-thumb { width: 68px; height: 54px; object-fit: cover; border-radius: 9px; background: #edf0f5; }
.file-info { min-width: 0; }
.file-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 760; color: #202530; letter-spacing: -.15px; }
.file-meta { display: flex; align-items: center; gap: 6px; margin-top: 5px; color: #7e8797; font-size: 9px; }
.file-state { width: 7px; height: 7px; border-radius: 50%; background: #c2c7d0; flex: 0 0 auto; }
.file-state.done { background: var(--success); }
.file-state.empty { background: #bdc2cc; }
.file-state.detecting { background: var(--primary); animation: pulse 1s infinite; }
.file-state.error { background: var(--danger); }
.file-remove {
  width: 22px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 8px;
  color: #697386;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  opacity: 1;
}
.file-remove:hover { background: #fff; color: #343a46; }
.library-footer {
  min-height: 55px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 15px;
  border-top: 1px solid var(--line);
  color: #6f7888;
  font-size: 10px;
  background: #fff;
}
.text-btn { border: 0; background: transparent; padding: 4px 0; color: inherit; font-size: 10px; cursor: pointer; }
.text-btn:disabled { opacity: .35; cursor: default; }
.text-btn.danger:not(:disabled) { color: #ff314e; }

/* ---------- Editor ---------- */
.editor-panel {
  position: relative;
  height: calc(100vh - var(--topbar-h) - 34px);
  min-height: 590px;
  display: flex;
  background: #fff;
}
.welcome-state { margin: auto; max-width: 610px; padding: 46px 30px; text-align: center; }
.welcome-mark { width: 72px; height: 72px; margin: 0 auto 22px; }
.welcome-mark img { width: 100%; height: 100%; }
.welcome-state h1 { margin: 9px 0 14px; color: #151820; font-size: 36px; line-height: 1.06; letter-spacing: -1.4px; }
.welcome-copy { max-width: 500px; margin: 0 auto 24px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.trust-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 20px; }
.trust-row span { padding: 6px 9px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: #727b8c; font-size: 9px; }

.editor-view { width: 100%; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.editor-toolbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.toolbar-left { min-width: 0; display: flex; align-items: center; gap: 12px; }
.tool-cluster, .icon-cluster { display: flex; align-items: center; gap: 5px; }
.tool-btn {
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: #3f4655;
  font-size: 10.5px;
  font-weight: 680;
  cursor: pointer;
  transition: .16s ease;
}
.tool-btn svg, .toolbar-icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool-btn:hover { background: #f7f8fc; }
.tool-btn.active { color: var(--primary); background: #f0efff; border-color: #d8d3ff; }
.toolbar-divider { width: 1px; height: 32px; background: var(--line); flex: 0 0 auto; }
.toolbar-icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #5c6677;
  cursor: pointer;
}
.toolbar-icon-btn:hover:not(:disabled) { background: #f5f6fa; color: #2c3340; }
.toolbar-icon-btn:disabled { opacity: .35; cursor: default; }
.zoom-control {
  height: 40px;
  display: grid;
  grid-template-columns: 36px 55px 36px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafbfc;
  overflow: hidden;
}
.zoom-control button { height: 100%; border: 0; background: transparent; color: #3c4452; font-size: 20px; cursor: pointer; }
.zoom-control button:hover { background: #f3f5f8; }
.zoom-control span { text-align: center; color: #232832; font-size: 11px; font-weight: 750; }
.toolbar-meta { display: flex; align-items: center; gap: 10px; color: #687285; white-space: nowrap; }
#canvasInfo { font-size: 10px; }
.info-dot { width: 18px; height: 18px; display: grid; place-items: center; border: 1.5px solid #778195; border-radius: 50%; font-size: 9px; font-weight: 800; }
.canvas-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #f5f7fb;
}
#editorCanvas { display: block; width: 100%; height: 100%; max-width: 100%; max-height: 100%; touch-action: none; }
.detecting-badge {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  background: rgba(25,28,36,.90);
  color: #fff;
  font-size: 10px;
  pointer-events: none;
  box-shadow: 0 9px 24px rgba(0,0,0,.14);
  backdrop-filter: blur(10px);
}
.spinner { width: 12px; height: 12px; border: 2px solid rgba(255,255,255,.28); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.canvas-hint { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); padding: 8px 12px; border-radius: 999px; background: rgba(26,29,37,.86); color: #fff; font-size: 10px; pointer-events: none; }
.drop-overlay { position: absolute; inset: 10px; z-index: 30; display: none; place-items: center; border: 2px dashed var(--primary); border-radius: 16px; background: rgba(246,246,255,.95); color: var(--primary); backdrop-filter: blur(8px); pointer-events: none; }
.drop-overlay.active { display: grid; }
.drop-overlay div { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.drop-overlay span { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: #fff; }

.thumbnail-strip {
  flex: 0 0 108px;
  min-height: 108px;
  display: flex;
  align-items: center;
  border-top: 1px solid var(--line);
  background: #fff;
  overflow: hidden;
}
.thumbnail-list {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: #d9dee8 transparent;
}
.thumbnail-card {
  flex: 0 0 132px;
  height: 82px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 10px;
  background: #eef1f5;
  overflow: hidden;
  cursor: pointer;
  transition: .15s ease;
}
.thumbnail-card:hover { transform: translateY(-1px); }
.thumbnail-card.active { border-color: #6e63ff; box-shadow: 0 0 0 2px rgba(110,99,255,.06); }
.thumbnail-card img { width: 100%; height: 100%; display: block; object-fit: cover; }
.bottom-status { display: none; }

/* ---------- Settings ---------- */
.settings-panel {
  height: calc(100vh - var(--topbar-h) - 34px);
  display: flex;
  flex-direction: column;
  background: #fff;
}
.settings-scroll { flex: 1; min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: #d9dee8 transparent; }
.settings-main-title {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}
.settings-main-title h2 { margin: 0; font-size: 16px; letter-spacing: -.25px; }
.section-title-icon, .mini-title-icon { color: var(--primary); display: grid; place-items: center; }
.section-title-icon svg { width: 18px; height: 18px; }
.section-title-icon svg, .mini-title-icon svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.setting-section { padding: 13px 16px; border-bottom: 1px solid var(--line); }
.setting-label, .setting-row label, .section-heading-label label { color: #252a34; font-size: 10px; font-weight: 760; }
.effect-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; margin-top: 11px; }
.effect-btn {
  height: 68px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid #dde2eb;
  border-radius: 12px;
  background: #f8f9fc;
  color: #3f4757;
  font-size: 10px;
  font-weight: 650;
  cursor: pointer;
  transition: .16s ease;
}
.effect-btn:hover { border-color: #ccd2dd; background: #f5f6fa; }
.effect-btn.active { border-color: #665cff; background: #f4f2ff; color: #554ceb; box-shadow: 0 0 0 1px rgba(102,92,255,.05); }
.effect-icon { width: 22px; height: 22px; display: grid; place-items: center; }
.effect-icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.effect-btn[data-effect="solid"] .effect-icon svg rect { fill: #172235; stroke: #172235; }
.compact-setting { padding-top: 12px; padding-bottom: 12px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.setting-row output, .setting-row > span { color: #7e8796; font-size: 9px; }
.range {
  --range-progress: 50%;
  width: 100%;
  height: 6px;
  margin: 3px 0 1px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary) 0 var(--range-progress), #dfe3ea var(--range-progress) 100%);
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  cursor: pointer;
}
.range::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: transparent; }
.range::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -5px;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,.16);
  appearance: none;
  -webkit-appearance: none;
}
.range::-moz-range-track { height: 6px; border: 0; background: transparent; }
.range::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.16); }
.setting-help { margin: 9px 0 0; color: #8a93a3; font-size: 9px; line-height: 1.5; }
.section-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.section-heading-label { display: flex; align-items: center; gap: 8px; }
.mini-title-icon { width: 17px; height: 17px; }
.mini-title-icon svg { width: 16px; height: 16px; }
.mini-title-icon.neutral { color: #4b5362; }
.count-badge { min-width: 24px; height: 22px; display: inline-grid; place-items: center; padding: 0 7px; border: 1px solid #e3e6ed; border-radius: 999px; background: #f6f7fa; color: #667082; font-size: 9px; font-weight: 750; }
.object-list { display: flex; flex-direction: column; gap: 7px; max-height: 176px; overflow: auto; }
.object-item {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  min-height: 49px;
  border: 1px solid #e1e5ed;
  border-radius: 11px;
  background: #fff;
  cursor: pointer;
  transition: .15s ease;
}
.object-item.selected { border-color: #cfcaff; background: #f8f7ff; }
.object-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: #efedff; color: var(--primary); font-size: 10px; font-weight: 800; }
.object-copy strong { display: block; color: #20252f; font-size: 10px; }
.object-copy small { display: block; margin-top: 2px; color: #7f8898; font-size: 8.5px; }
.object-toggle { width: 29px; height: 18px; position: relative; appearance: none; border-radius: 999px; background: #d8dde5; cursor: pointer; transition: .16s ease; }
.object-toggle::after { content: ""; width: 14px; height: 14px; position: absolute; top: 2px; left: 2px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.16); transition: .16s ease; }
.object-toggle:checked { background: var(--primary); }
.object-toggle:checked::after { transform: translateX(11px); }
.object-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; }
.advanced-section { padding-top: 0; padding-bottom: 0; }
.advanced-section details { margin: 0 -16px; }
.advanced-section summary { min-height: 50px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; list-style: none; cursor: pointer; color: #2f3541; font-size: 10px; font-weight: 740; }
.advanced-section summary::-webkit-details-marker { display: none; }
.advanced-section summary::after { content: "+"; color: #586274; font-size: 18px; font-weight: 400; }
.advanced-section details[open] summary::after { content: "−"; }
.advanced-label { display: inline-flex; align-items: center; gap: 8px; }
.details-body { padding: 0 16px 15px; }
.redetect-button { margin-top: 12px; width: 100%; }
.export-settings { border-bottom: 0; }
.export-heading { margin-bottom: 9px; }
.two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two-fields label { color: #8a93a2; font-size: 8.5px; font-weight: 600; }
select {
  width: 100%;
  height: 36px;
  margin-top: 5px;
  padding: 0 28px 0 10px;
  border: 1px solid #dfe3eb;
  border-radius: 9px;
  background: #fff;
  color: #242a34;
  font-size: 9.5px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(30,37,55,.02);
}
.export-quality-note {
  margin-top: 10px;
  min-height: 50px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border: 1px solid #9ee1c4;
  border-radius: 10px;
  background: #effbf6;
}
.quality-check { width: 20px; height: 20px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--success); color: #fff; font-size: 11px; font-weight: 800; }
.export-quality-note strong { color: #18704d; font-size: 10px; }
.export-quality-note small { color: #66877a; font-size: 8.5px; }
#qualitySelect:disabled { opacity: .58; cursor: default; }
.export-bar { padding: 11px 15px 12px; border-top: 1px solid var(--line); background: #fff; }
.download-button {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #635bff 0%, #554bef 100%);
  color: #fff;
  font-size: 11px;
  font-weight: 760;
  cursor: pointer;
  box-shadow: var(--shadow-button);
  transition: .16s ease;
}
.download-button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 13px 27px rgba(83,76,235,.26); }
.download-button:disabled { opacity: .55; cursor: default; transform: none; }
.download-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Shared buttons ---------- */
.btn { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 11px; border: 1px solid transparent; border-radius: 10px; font-size: 9.5px; font-weight: 700; cursor: pointer; transition: .16s ease; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: linear-gradient(135deg, #655cff, #5449ec); color: #fff; box-shadow: 0 9px 22px rgba(83,76,235,.21); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); }
.btn-secondary { border-color: #dfe3eb; background: #fff; color: #303641; }
.btn-secondary:hover:not(:disabled) { background: #f8f9fc; border-color: #d3d8e2; }
.btn-danger-soft { border-color: #ffdce2; background: var(--danger-soft); color: #ff3b53; }
.btn-danger-soft:hover:not(:disabled) { background: #ffecef; }
.btn-large { min-height: 44px; padding: 0 18px; font-size: 11px; border-radius: 12px; }

/* ---------- Modal / toast ---------- */
.modal { width: min(460px, calc(100vw - 30px)); padding: 0; border: 0; border-radius: 20px; box-shadow: 0 30px 90px rgba(20,25,38,.25); }
.modal::backdrop { background: rgba(20,25,38,.38); backdrop-filter: blur(5px); }
.modal form { padding: 23px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.modal h3 { margin: 4px 0 14px; font-size: 19px; letter-spacing: -.4px; }
.modal p { color: #757f90; font-size: 11px; line-height: 1.65; }
.modal-close { width: 31px; height: 31px; border: 1px solid var(--line); border-radius: 9px; background: #f6f7fa; font-size: 18px; cursor: pointer; }
.modal .btn { margin-top: 6px; }
.toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { min-width: 220px; max-width: 350px; padding: 11px 13px; border: 1px solid rgba(255,255,255,.1); border-radius: 12px; background: rgba(24,28,36,.94); color: #fff; font-size: 10px; box-shadow: 0 14px 40px rgba(0,0,0,.22); backdrop-filter: blur(12px); animation: toastIn .2s ease; }
.toast.error { background: rgba(125,36,49,.96); }

/* ---------- Dark theme ---------- */
body[data-theme="dark"] {
  --bg: #10131a;
  --panel: #181c25;
  --panel-soft: #1d222d;
  --panel-muted: #202631;
  --text: #f2f4f8;
  --text-2: #e1e5ec;
  --muted: #9ba5b7;
  --muted-2: #737f92;
  --line: #2a3140;
  --line-strong: #343c4c;
  background: #10131a;
}
body[data-theme="dark"] .topbar,
body[data-theme="dark"] .panel,
body[data-theme="dark"] .editor-toolbar,
body[data-theme="dark"] .thumbnail-strip,
body[data-theme="dark"] .export-bar,
body[data-theme="dark"] .library-footer,
body[data-theme="dark"] .settings-panel { background: #181c25; }
body[data-theme="dark"] .brand-name,
body[data-theme="dark"] .panel-heading h2,
body[data-theme="dark"] .settings-main-title h2,
body[data-theme="dark"] .setting-label,
body[data-theme="dark"] .setting-row label,
body[data-theme="dark"] .section-heading-label label,
body[data-theme="dark"] .object-copy strong { color: #f2f4f8; }
body[data-theme="dark"] .theme-switch,
body[data-theme="dark"] .zoom-control,
body[data-theme="dark"] .effect-btn,
body[data-theme="dark"] .object-item,
body[data-theme="dark"] select,
body[data-theme="dark"] .privacy-button,
body[data-theme="dark"] .status-pill,
body[data-theme="dark"] .circle-icon-btn,
body[data-theme="dark"] .btn-secondary { background: #202631; color: #dbe0e8; }
body[data-theme="dark"] .theme-btn.active { background: #2a3140; }
body[data-theme="dark"] .canvas-stage { background: #141821; }
body[data-theme="dark"] .file-card:hover { background: #1d222c; }
body[data-theme="dark"] .file-card.active { background: #24213d; }
body[data-theme="dark"] .export-quality-note { background: #153328; border-color: #286c51; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Responsive ---------- */
@media (max-width: 1240px) {
  .workspace { grid-template-columns: 238px minmax(450px,1fr) 320px; }
  .storage-note { display: none; }
  .brand-mark { width: 50px; height: 50px; }
  .brand-name { font-size: 23px; }
  .effect-btn { font-size: 9px; }
}

@media (max-width: 980px) {
  :root { --topbar-h: 70px; --workspace-gap: 9px; }
  .topbar { padding: 0 13px; }
  .brand-mark { width: 43px; height: 43px; }
  .brand-name { font-size: 19px; }
  .brand-subtitle { display: none; }
  .theme-switch { display: none; }
  .privacy-button span { display: none; }
  .privacy-button { width: 40px; padding: 0; justify-content: center; }
  .workspace { display: flex; flex-direction: column; padding: 8px; gap: 8px; }
  .library-panel { order: 1; height: auto; min-height: 62px; }
  .library-heading, .library-upload, .library-footer { display: none; }
  .file-list { display: flex; gap: 8px; overflow-x: auto; padding: 8px; }
  .file-card { flex: 0 0 170px; min-height: 52px; margin: 0; grid-template-columns: 52px minmax(0,1fr); }
  .file-thumb { width: 52px; height: 40px; }
  .file-remove { display: none; }
  .editor-panel { order: 2; height: 60vh; min-height: 520px; }
  .settings-panel { order: 3; height: auto; overflow: visible; }
  .settings-scroll { overflow: visible; }
  .thumbnail-strip { flex-basis: 94px; min-height: 94px; }
  .thumbnail-card { flex-basis: 118px; height: 70px; }
  .settings-main-title { min-height: 54px; }
}

@media (max-width: 620px) {
  :root { --topbar-h: 62px; }
  .topbar { padding: 0 10px; }
  .brand { gap: 8px; }
  .brand-mark { width: 39px; height: 39px; }
  .brand-name { font-size: 18px; }
  .header-actions { gap: 7px; }
  .status-pill { width: 36px; height: 36px; min-height: 36px; padding: 0; justify-content: center; font-size: 0; }
  .privacy-button { width: 36px; height: 36px; }
  .workspace { padding: 0; gap: 0; }
  .panel { border-radius: 0; border-left: 0; border-right: 0; box-shadow: none; }
  .library-panel { border-top: 0; }
  .editor-panel { min-height: 66vh; height: 66vh; }
  .editor-toolbar { min-height: 58px; padding: 0 8px; }
  .tool-btn { width: 38px; padding: 0; justify-content: center; }
  .tool-btn span { display: none; }
  .toolbar-divider { display: none; }
  .toolbar-left { gap: 5px; }
  .icon-cluster { display: none; }
  .zoom-control { grid-template-columns: 30px 45px 30px; height: 36px; }
  .toolbar-meta #canvasInfo { display: none; }
  .info-dot { display: none; }
  .thumbnail-strip { flex-basis: 86px; min-height: 86px; }
  .thumbnail-list { gap: 8px; padding: 8px; }
  .thumbnail-card { flex-basis: 104px; height: 66px; }
  .effect-grid { gap: 6px; }
  .effect-btn { height: 68px; font-size: 8.5px; }
  .two-fields { grid-template-columns: 1fr 1fr; }
}
