:root {
  --primary: #1a73e8;
  --primary-hover: #1557b0;
  --primary-soft: #e8f0fe;
  --accent: #8ab4f8;
  --ink: #202124;
  --muted: #5f6368;
  --subtle: #74787d;
  --border: #dadce0;
  --border-strong: #bdc1c6;
  --surface: #ffffff;
  --surface-alt: #f8fafd;
  --canvas: #f1f3f4;
  --danger: #d93025;
  --success: #188038;
  --shadow-panel: 0 12px 32px rgba(60, 64, 67, 0.16), 0 2px 8px rgba(60, 64, 67, 0.1);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--surface);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: var(--surface-alt); color: var(--ink); font-size: 14px; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid rgba(26, 115, 232, .5); outline-offset: 2px; }
button:disabled, input:disabled { opacity: .38; cursor: not-allowed; }
[hidden] { display: none !important; }

.app-shell { width: 100%; height: 100%; display: grid; grid-template-rows: 64px 58px minmax(0, 1fr); background: var(--surface-alt); }
.topbar { display: grid; grid-template-columns: auto minmax(180px, 1fr) auto; align-items: center; gap: 18px; padding: 0 18px 0 20px; background: var(--surface-alt); z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; }
.brand-mark img { display: block; width: 100%; height: 100%; }
.brand-word { color: #3c4043; font: 600 21px/1 "Segoe UI", "Microsoft YaHei", sans-serif; letter-spacing: -.35px; }
.document-title { display: flex; align-items: center; gap: 9px; min-width: 0; justify-self: start; }
.document-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: #3c4043; }
.document-state { display: inline-flex; align-items: center; gap: 4px; color: var(--success); font-size: 12px; white-space: nowrap; }
.top-actions { justify-self: end; display: flex; align-items: center; gap: 7px; }
.button { min-height: 38px; border-radius: 19px; border: 1px solid var(--border); padding: 0 15px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; background: var(--surface); font-weight: 600; cursor: pointer; transition: background-color .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease; white-space: nowrap; }
.button:hover:not(:disabled) { border-color: var(--border-strong); background: #f1f3f4; }
.button.primary { border-color: var(--primary); background: var(--primary); color: #fff; box-shadow: none; }
.button.primary:hover:not(:disabled) { border-color: var(--primary-hover); background: var(--primary-hover); }
.button.ghost { background: var(--surface); }
.button.large { min-height: 44px; padding: 0 20px; }
.button.full { width: 100%; }
.button.danger { color: var(--danger); border-color: #fecdd3; background: #fff1f2; }

.editor-layout { min-height: 0; display: grid; grid-template-columns: 70px minmax(0, 1fr) 304px; background: var(--surface-alt); }
.tool-rail { min-height: 0; overflow: auto; margin: 8px 0 8px 8px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); padding: 10px 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; z-index: 8; scrollbar-width: none; }
.tool-rail::-webkit-scrollbar { display: none; }
.tool-button { width: 52px; min-height: 54px; padding: 6px 4px; border: 1px solid transparent; border-radius: 14px; display: grid; place-items: center; align-content: center; gap: 4px; background: transparent; color: var(--muted); cursor: pointer; transition: .15s ease; }
.tool-button i { font-size: 21px; line-height: 1; }
.tool-button small { font-size: 11px; line-height: 1.1; }
.tool-button:hover:not(:disabled) { color: var(--ink); background: #f1f3f4; }
.tool-button.active { color: #174ea6; border-color: transparent; background: #d3e3fd; }
.command-tools .tool-button { width: 50px; min-height: 44px; border-radius: 12px; }
.command-tools .tool-button i { font-size: 19px; }

.workspace { min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) 42px; margin: 8px; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--canvas); position: relative; }
.workspace-toolbar { display: flex; align-items: center; gap: 6px; margin: 0 10px 6px; padding: 6px 10px; border-radius: 22px; background: #edf2fa; z-index: 12; }
.toolbar-group { display: flex; align-items: stretch; gap: 3px; }
.icon-button, .compact-button { min-width: 54px; border: 1px solid transparent; border-radius: 12px; background: transparent; display: grid; align-content: center; justify-items: center; gap: 1px; padding: 4px 8px; color: var(--muted); cursor: pointer; }
.icon-button i, .compact-button i { font-size: 19px; }
.icon-button span, .compact-button span { font-size: 10px; white-space: nowrap; }
.icon-button:hover:not(:disabled), .compact-button:hover:not(:disabled) { background: rgba(255,255,255,.8); color: var(--ink); }
.toolbar-divider { width: 1px; margin: 5px 4px; background: #c7cbd1; }
.toolbar-spacer, .status-spacer { flex: 1; }
.selection-hint { align-self: center; color: var(--subtle); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
.inspector-toggle { display: none; }

.canvas-viewport { min-height: 0; position: relative; overflow: hidden; isolation: isolate; background: var(--canvas); }
.checkerboard { position: absolute; inset: 0; background-color: #f8fafc; background-image: linear-gradient(45deg, #e8edf3 25%, transparent 25%), linear-gradient(-45deg, #e8edf3 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e8edf3 75%), linear-gradient(-45deg, transparent 75%, #e8edf3 75%); background-size: 24px 24px; background-position: 0 0, 0 12px, 12px -12px, -12px 0; opacity: .72; }
.leafer-host, .tool-surface { position: absolute; inset: 0; }
.vector-preview-host { position: absolute; inset: 0; z-index: 1; overflow: hidden; pointer-events: none; contain: layout paint style; }
.vector-preview-host[hidden] { display: none; }
.leafer-host { z-index: 2; }
.tool-surface { z-index: 3; pointer-events: none; }
.tool-surface.active { pointer-events: auto; }
.empty-state { position: absolute; inset: 16px; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; border: 1px dashed #c4cfdd; border-radius: var(--radius-lg); background: var(--surface); color: var(--muted); }
.empty-icon { width: 62px; height: 62px; display: grid; place-items: center; margin-bottom: 18px; }
.empty-icon img { display: block; width: 100%; height: 100%; }
.eyebrow { margin: 0 0 7px; color: var(--primary); font-size: 11px; line-height: 1; font-weight: 760; letter-spacing: .08em; text-transform: uppercase; }
.empty-state h1 { margin: 0; color: var(--ink); font: 500 clamp(28px, 2.5vw, 36px)/1.18 "Segoe UI", "Microsoft YaHei", sans-serif; letter-spacing: -.7px; }
.empty-state > p:not(.eyebrow) { margin: 13px 0 22px; line-height: 1.65; }
.format-note { margin-top: 12px; color: var(--subtle); font-size: 11px; letter-spacing: .03em; }

.statusbar { display: flex; align-items: center; gap: 12px; padding: 0 14px; border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 12px; z-index: 7; }
.image-meta, .zoom-fit { display: inline-flex; align-items: center; gap: 7px; }
.status-dot, .ai-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; flex: 0 0 auto; }
.image-meta.ready .status-dot, .ai-model.connected .ai-status-dot, .settings-status.connected .ai-status-dot { background: var(--success); box-shadow: 0 0 0 3px rgba(5,150,105,.12); }
.zoom-fit, .zoom-button { border: 0; background: transparent; color: var(--muted); min-height: 30px; cursor: pointer; }
.zoom-fit { padding: 0 8px; border-radius: 6px; }
.zoom-fit:hover:not(:disabled) { background: var(--surface-alt); color: var(--ink); }
.zoom-button { width: 28px; display: grid; place-items: center; font-size: 17px; }
.zoom-value { min-width: 38px; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }

.inspector { min-width: 0; min-height: 0; display: grid; grid-template-rows: 52px minmax(0, 1fr); margin: 8px 8px 8px 0; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); z-index: 9; }
.inspector-tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--border); }
.inspector-tab { position: relative; border: 0; background: transparent; color: var(--subtle); cursor: pointer; font-weight: 600; }
.inspector-tab::after { content: ""; position: absolute; left: 28%; right: 28%; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: transparent; }
.inspector-tab.active { color: var(--primary); }
.inspector-tab.active::after { background: var(--primary); }
.inspector-scroll { min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
.panel { padding: 20px 22px 28px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 23px; }
.panel-heading h2, .dialog-heading h2 { margin: 0; color: var(--ink); font: 600 19px/1.25 "Segoe UI", "Microsoft YaHei", sans-serif; letter-spacing: -.2px; }
.text-button { border: 0; background: transparent; padding: 3px 0; color: var(--primary); font-size: 12px; cursor: pointer; }
.control-stack { display: grid; gap: 21px; }
.range-control { display: grid; gap: 9px; color: var(--ink); }
.range-control > span { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.range-control output { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; height: 20px; margin: 0; appearance: none; background: transparent; cursor: pointer; accent-color: var(--primary); }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 999px; background: #cbd7e6; }
input[type="range"]::-webkit-slider-thumb { width: 14px; height: 14px; margin-top: -5px; border: 0; border-radius: 50%; appearance: none; background: var(--primary); box-shadow: 0 0 0 3px #fff, 0 1px 4px rgba(60,64,67,.2); }
input[type="range"]::-moz-range-track { height: 4px; border: 0; border-radius: 999px; background: #cbd7e6; }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px #fff, 0 1px 4px rgba(60,64,67,.2); }
.section-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 25px 0 12px; padding-top: 20px; border-top: 1px solid var(--border); font-weight: 650; }
.section-label small { color: var(--subtle); font-size: 11px; font-weight: 400; }
.preset-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 8px; }
.preset { border: 0; padding: 0; background: transparent; cursor: pointer; color: var(--muted); }
.preset-preview { display: block; aspect-ratio: 1.18; border-radius: 9px; border: 1px solid var(--border); background-color: #eef2f6; background-size: cover; background-position: center; transition: .15s ease; }
.preset em { display: block; margin-top: 6px; font-style: normal; font-size: 11px; }
.preset.active .preset-preview { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(26,115,232,.12); }
.preset[data-preset="clean"] .preset-preview { filter: brightness(1.06) contrast(1.05) saturate(.92); }
.preset[data-preset="warm"] .preset-preview { filter: sepia(.15) saturate(1.12); }
.preset[data-preset="cool"] .preset-preview { filter: hue-rotate(176deg) saturate(.72); }
.preset[data-preset="mono"] .preset-preview { filter: grayscale(1) contrast(1.08); }
.preset[data-preset="vivid"] .preset-preview { filter: saturate(1.5) contrast(1.08); }
.preset[data-preset="fade"] .preset-preview { filter: saturate(.55) contrast(.84) brightness(1.06); }
.preset[data-preset="document"] .preset-preview { filter: grayscale(.65) contrast(1.32) brightness(1.08); }

.wide-range { width: 100%; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.action-grid button { min-height: 66px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); display: grid; place-items: center; align-content: center; gap: 5px; cursor: pointer; }
.action-grid button:hover:not(:disabled) { border-color: #aecbfa; color: var(--primary); background: var(--primary-soft); }
.action-grid i { font-size: 21px; }
.action-grid span { font-size: 11px; }
.size-grid { display: grid; grid-template-columns: 1fr 30px 1fr; align-items: end; gap: 7px; }
.size-grid label { color: var(--muted); font-size: 11px; }
.size-grid label div { margin-top: 6px; display: flex; align-items: center; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.size-grid input { width: 100%; min-width: 0; height: 34px; border: 0; padding: 0 8px; color: var(--ink); }
.size-grid label div span { padding-right: 8px; color: var(--subtle); }
.ratio-lock { width: 30px; height: 34px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--muted); }
.ratio-lock.active { color: var(--primary); background: var(--primary-soft); border-color: #aecbfa; }
.crop-summary { margin-top: 18px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-alt); }
.crop-summary > div { display: flex; justify-content: space-between; margin-bottom: 12px; color: var(--muted); font-size: 12px; }
.crop-summary strong { color: var(--ink); }
.color-control { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.color-control > span { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.color-control input { width: 30px; height: 30px; padding: 2px; border: 1px solid var(--border); border-radius: 7px; background: #fff; }
.font-control { display: grid; gap: 8px; margin-bottom: 20px; }
.font-control > span { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.font-control small { color: var(--subtle); font-size: 10px; font-weight: 400; }
.font-control select { width: 100%; min-height: 38px; padding: 0 34px 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: #fff; color: var(--ink); }
.font-control select:disabled { background: var(--surface-alt); }
.style-tip { margin: 26px 0 18px; padding: 13px 14px; border: 1px solid #d2e3fc; border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--muted); font-size: 12px; line-height: 1.55; }
.style-tip span { color: var(--primary); font-weight: 700; }
.style-tip p { margin: 7px 0 0; }

.ai-workbench { position: absolute; z-index: 14; right: 28px; bottom: 26px; width: 520px; height: 440px; min-width: 420px; min-height: 300px; max-width: calc(100% - 40px); max-height: calc(100% - 40px); display: grid; grid-template-rows: 54px minmax(0, 1fr); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: rgba(255,255,255,.985); box-shadow: var(--shadow-panel); overflow: hidden; resize: none; }
.ai-workbench.fullscreen { inset: 18px !important; width: auto !important; height: auto !important; max-width: none; max-height: none; }
.ai-workbench.collapsed { height: 54px !important; min-height: 54px; }
.ai-workbench.collapsed .ai-body, .ai-workbench.collapsed .ai-resize-handle { display: none; }
.ai-workbench.is-hidden { display: none; }
.ai-header { display: flex; align-items: center; gap: 10px; padding: 0 12px 0 14px; border-bottom: 1px solid var(--border); cursor: move; user-select: none; }
.ai-title { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.ai-title strong { font-size: 15px; }
.ai-title > span:last-child { color: var(--muted); font-size: 12px; }
.ai-mark { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; background: var(--primary); color: #fff; }
.ai-model { margin-left: auto; border: 0; background: transparent; display: inline-flex; align-items: center; gap: 6px; min-width: 0; color: var(--subtle); font-size: 11px; cursor: pointer; }
.ai-model span:last-child { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-window-actions { display: flex; align-items: center; gap: 2px; padding-left: 6px; border-left: 1px solid var(--border); }
.ai-window-actions button, .composer-tools > button { width: 30px; height: 30px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.ai-window-actions button:hover, .composer-tools > button:hover { background: var(--surface-alt); color: var(--ink); }
.ai-body { min-height: 0; display: grid; grid-template-rows: auto auto auto minmax(80px, 1fr) auto auto; overflow: hidden; }
.ai-mode-switch { display: grid; grid-template-columns: 1fr 1fr; margin: 10px 14px 0; padding: 3px; border-radius: 9px; background: #f1f5f9; }
.ai-mode-switch button { min-height: 30px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 650; cursor: pointer; }
.ai-mode-switch button.active { background: #fff; color: var(--primary); box-shadow: 0 1px 4px rgba(15,23,42,.1); }
.ai-context { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; align-items: center; gap: 10px; margin: 9px 14px 0; padding: 9px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-alt); }
.ai-context-thumb { width: 46px; height: 38px; display: grid; place-items: center; overflow: hidden; border-radius: 7px; background: #e2e8f0; color: var(--subtle); position: relative; }
.ai-context-thumb img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.ai-context > div:nth-child(2) { min-width: 0; display: grid; gap: 2px; }
.ai-context > div:nth-child(2) span, .ai-context > div:nth-child(2) small { color: var(--subtle); font-size: 10px; }
.ai-context strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.context-chip { padding: 4px 7px; border-radius: 999px; background: #ccfbf1; color: var(--primary); font-size: 10px; white-space: nowrap; }
.ai-quick-actions { display: flex; gap: 6px; padding: 9px 14px 0; overflow-x: auto; scrollbar-width: none; }
.ai-quick-actions button { min-height: 28px; padding: 0 9px; border: 1px solid var(--border); border-radius: 999px; background: #fff; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; font-size: 11px; white-space: nowrap; cursor: pointer; }
.ai-quick-actions button:hover { border-color: #99f6e4; color: var(--primary); background: #f0fdfa; }
.ai-conversation { min-height: 0; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
.ai-message { display: flex; gap: 8px; align-items: flex-start; }
.ai-message.user { justify-content: flex-end; }
.message-avatar { width: 25px; height: 25px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 8px; background: var(--primary-soft); color: var(--primary); }
.message-content { max-width: 88%; min-width: 0; border: 1px solid var(--border); border-radius: 4px 11px 11px 11px; background: #fff; padding: 9px 10px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.message-content strong { color: var(--ink); }
.message-content p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-message.user .message-content { border-color: #99f6e4; border-radius: 11px 4px 11px 11px; background: #f0fdfa; color: var(--ink); }
.thinking { display: inline-flex; gap: 4px; align-items: center; color: var(--subtle); }
.thinking i { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-proposal { margin: 0 14px 9px; padding: 10px 11px; border: 1px solid #99f6e4; border-radius: 10px; background: #f0fdfa; }
.proposal-heading { display: flex; justify-content: space-between; gap: 8px; color: var(--primary); font-size: 11px; }
.proposal-heading small { color: var(--subtle); }
.ai-proposal > strong { display: block; margin: 6px 0 4px; font-size: 12px; }
.ai-proposal ul { display: flex; flex-wrap: wrap; gap: 5px 10px; list-style: none; margin: 0 0 9px; padding: 0; color: var(--muted); font-size: 11px; }
.proposal-actions { display: flex; align-items: center; gap: 6px; }
.proposal-actions .button { min-height: 30px; padding: 0 10px; font-size: 11px; }
.proposal-actions .text-button { margin-left: auto; }
.ai-composer { margin: 0 14px 14px; border: 1px solid var(--border-strong); border-radius: 11px; background: #fff; box-shadow: 0 2px 8px rgba(15,23,42,.06); }
.ai-composer:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,.09); }
.composer-tools { height: 31px; display: flex; align-items: center; gap: 8px; padding: 0 7px; color: var(--subtle); }
.context-toggle { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; cursor: pointer; }
.context-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.context-toggle span { width: 24px; height: 14px; border-radius: 999px; background: #cbd5e1; position: relative; transition: .15s ease; }
.context-toggle span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: #fff; transition: .15s ease; }
.context-toggle input:checked + span { background: var(--primary); }
.context-toggle input:checked + span::after { transform: translateX(10px); }
.composer-count { margin-left: auto; font-size: 9px; }
.composer-input-row { display: grid; grid-template-columns: minmax(0, 1fr) 34px; gap: 7px; align-items: end; padding: 0 7px 7px 10px; }
.composer-input-row textarea { width: 100%; min-height: 40px; max-height: 110px; resize: none; border: 0; outline: 0; padding: 4px 0; color: var(--ink); background: transparent; font-size: 12px; line-height: 1.45; }
.composer-input-row textarea::placeholder { color: #94a3b8; }
.ai-send { width: 34px; height: 34px; border: 0; border-radius: 9px; background: var(--primary); color: #fff; cursor: pointer; display: grid; place-items: center; }
.ai-send:hover { background: var(--primary-hover); }
.ai-send.streaming { background: var(--ink); }
.ai-resize-handle { position: absolute; right: 2px; bottom: 2px; width: 19px; height: 19px; padding: 0; border: 0; background: transparent; color: #94a3b8; cursor: nwse-resize; transform: rotate(45deg); }
.ai-launcher { height: 38px; padding: 0 15px; border-color: transparent; border-radius: 19px; background: var(--primary-soft); color: #174ea6; display: none; align-items: center; gap: 7px; box-shadow: none; cursor: pointer; }
.ai-launcher-logo { width: 20px; height: 20px; display: block; }
.ai-launcher:hover:not(:disabled) { border-color: transparent; background: #d2e3fc; }
.ai-launcher.visible { display: flex; }

.crop-overlay { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.crop-shade { position: absolute; background: rgba(15,23,42,.5); }
.crop-selection { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--primary); pointer-events: auto; cursor: move; }
.crop-grid { position: absolute; background: rgba(255,255,255,.72); pointer-events: none; }
.crop-grid.vertical { top: 0; bottom: 0; width: 1px; }
.crop-grid.horizontal { left: 0; right: 0; height: 1px; }
.crop-grid.vertical.one { left: 33.333%; } .crop-grid.vertical.two { left: 66.666%; }
.crop-grid.horizontal.one { top: 33.333%; } .crop-grid.horizontal.two { top: 66.666%; }
.crop-selection > i { position: absolute; width: 14px; height: 14px; border: 2px solid #fff; background: var(--primary); border-radius: 50%; }
.crop-selection > i[data-handle="nw"] { left: -8px; top: -8px; cursor: nwse-resize; }
.crop-selection > i[data-handle="ne"] { right: -8px; top: -8px; cursor: nesw-resize; }
.crop-selection > i[data-handle="se"] { right: -8px; bottom: -8px; cursor: nwse-resize; }
.crop-selection > i[data-handle="sw"] { left: -8px; bottom: -8px; cursor: nesw-resize; }
.crop-actions { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 11px; background: #fff; box-shadow: 0 12px 30px rgba(15,23,42,.24); pointer-events: auto; }
.crop-actions select { height: 38px; border: 1px solid var(--border); border-radius: 7px; padding: 0 26px 0 9px; background: #fff; }
.drop-mask { position: absolute; inset: 14px; z-index: 20; border: 2px dashed var(--accent); border-radius: var(--radius-lg); background: rgba(232,240,254,.96); color: var(--primary); display: grid; place-items: center; font-size: 18px; font-weight: 700; }
.drop-mask span { display: inline-flex; align-items: center; gap: 9px; }

dialog { border: 1px solid var(--border-strong); border-radius: var(--radius-lg); padding: 0; color: var(--ink); background: #fff; box-shadow: var(--shadow-panel); }
dialog::backdrop { background: rgba(15,23,42,.34); backdrop-filter: blur(2px); }
.export-dialog { width: min(440px, calc(100vw - 32px)); }
.export-dialog form, .ai-settings-dialog form, .source-dialog form { padding: 22px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.dialog-close { width: 32px; height: 32px; border: 0; border-radius: 8px; background: var(--surface-alt); color: var(--muted); cursor: pointer; }
.export-preview-row { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--radius); background: var(--surface-alt); margin-bottom: 18px; }
.export-badge { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 10px; background: var(--primary); color: #fff; font-weight: 800; }
.export-preview-row div { display: grid; gap: 4px; }
.export-preview-row small { color: var(--muted); }
.select-control, .field-control { display: grid; gap: 7px; margin: 15px 0; color: var(--muted); font-size: 12px; }
.select-control select, .field-control input { width: 100%; height: 42px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 11px; color: var(--ink); background: #fff; }
.vector-compatibility { margin: 14px 0 -4px; padding: 11px 12px; border: 1px solid #c7e3d0; border-radius: var(--radius-sm); background: #f0f9f3; color: #176b3a; font-size: 12px; line-height: 1.55; }
.vector-compatibility.warning { border-color: #f4cf8f; background: #fff8e8; color: #8a4b08; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.ai-settings-dialog { width: min(500px, calc(100vw - 32px)); }
.settings-note { margin: -5px 0 16px; padding: 11px 12px; border: 1px solid #ccfbf1; border-radius: var(--radius-sm); background: #f0fdfa; color: var(--muted); font-size: 12px; line-height: 1.55; }
.settings-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.source-dialog { width: min(640px, calc(100vw - 32px)); }
.source-dialog pre { max-height: 55vh; overflow: auto; margin: 0; padding: 14px; border-radius: var(--radius-sm); background: #0f172a; color: #d1fae5; font: 12px/1.6 Consolas, "Courier New", monospace; white-space: pre-wrap; }
.toast-region { position: fixed; left: 50%; bottom: 24px; z-index: 100; transform: translateX(-50%); display: grid; gap: 8px; pointer-events: none; }
.toast { min-width: 260px; max-width: min(520px, calc(100vw - 32px)); padding: 12px 15px; border: 1px solid var(--border-strong); border-radius: 10px; background: #fff; color: var(--ink); box-shadow: 0 12px 35px rgba(15,23,42,.18); text-align: center; }
.toast.success { border-color: #aecbfa; background: var(--primary-soft); color: var(--primary); }
.toast.error { border-color: #fecdd3; background: #fff1f2; color: var(--danger); }
.toast.warning { border-color: #f4cf8f; background: #fff8e8; color: #8a4b08; }

@media (max-width: 1180px) {
  .topbar { grid-template-columns: auto minmax(180px, 1fr) auto; }
  .top-actions .button span { display: none; }
  .top-actions .button { width: 40px; padding: 0; }
  .editor-layout { grid-template-columns: 64px minmax(0, 1fr) 268px; }
  .tool-button { width: 50px; }
  .panel { padding-left: 18px; padding-right: 18px; }
  .ai-workbench { width: 480px; }
}

@media (max-width: 900px) {
  .editor-layout { grid-template-columns: 58px minmax(0, 1fr); }
  .inspector { display: none; position: fixed; z-index: 40; top: 128px; right: 8px; bottom: 8px; width: min(340px, calc(100vw - 16px)); margin: 0; box-shadow: var(--shadow-panel); }
  .inspector.mobile-open { display: grid; }
  .inspector-toggle { display: grid; }
  .document-state { display: none; }
  .selection-hint { display: none; }
  .command-tools .tool-button:nth-child(n+6) { display: none; }
  .tool-rail { margin-left: 6px; }
  .workspace { margin-left: 6px; margin-right: 6px; }
  .ai-workbench { width: min(520px, calc(100% - 24px)); right: 12px; bottom: 12px; max-height: calc(100% - 24px); }
}

@media (max-width: 640px) {
  .app-shell { grid-template-rows: 54px 54px minmax(0, 1fr); }
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; padding: 0 9px; }
  .brand-word { display: none; }
  .document-title { justify-self: center; }
  .document-name { font-size: 12px; }
  .top-actions .button:not(#open-button):not(#export-button):not(#ai-launcher) { display: none; }
  .workspace { grid-template-rows: minmax(0, 1fr) 38px; }
  .workspace-toolbar { padding: 5px 8px; }
  .command-tools { display: none; }
  .compact-button span, .selection-hint { display: none; }
  .icon-button, .compact-button { min-width: 43px; }
  .inspector { top: 116px; }
  .ai-workbench { min-width: 0; min-height: 280px; width: calc(100% - 12px); height: min(480px, calc(100% - 12px)); right: 6px; bottom: 6px; border-radius: 13px; }
  .ai-model { display: none; }
  .ai-context { grid-template-columns: 42px minmax(0, 1fr); }
  .context-chip { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
