:root {
  color-scheme: dark;
  --bg: #2d2f32;
  --panel: #36383b;
  --panel-soft: #3d3f43;
  --surface: #47494e;
  --surface-hover: #52555a;
  --line: #56595e;
  --line-soft: #45474b;
  --text: #f7f7f8;
  --muted: #b9bac0;
  --subtle: #9a9ca2;
  --accent: #19c9f2;
  --accent-2: #1268ff;
  --accent-soft: rgba(25, 201, 242, 0.15);
  --accent-text: #7de7ff;
  --danger: #ef6b74;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.72);
  --focus: 0 0 0 2px #2d2f32, 0 0 0 4px var(--accent);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; min-width: 320px; min-height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body { overflow: hidden; }
button, input, select { font: inherit; }
button { color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); }
input[type="range"]:focus-visible { box-shadow: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--accent); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--accent); }

.app-shell { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 62px minmax(0, 1fr); height: 100vh; height: 100dvh; background: radial-gradient(circle at 45% 15%, #45484c 0, #323438 48%, #292b2e 100%); }
.topbar { position: relative; z-index: 60; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px 0 18px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, rgba(62,64,68,.98), rgba(46,48,51,.98)); box-shadow: 0 8px 24px rgba(0,0,0,.24); backdrop-filter: blur(18px); }
.brand { display: flex; flex: 0 0 auto; align-items: center; gap: 10px; min-width: 0; }
.brand-icon { width: 36px; height: 36px; object-fit: contain; }
.brand-name { color: white; font-size: 20px; font-weight: 800; letter-spacing: -.04em; }
.brand-subtitle { margin-left: 2px; color: var(--subtle); font-size: 11px; font-weight: 800; letter-spacing: .16em; }
.topbar-actions { display: flex; min-width: 0; align-items: center; gap: 6px; padding: 4px; overflow-x: auto; scrollbar-width: none; }
.topbar-actions::-webkit-scrollbar { display: none; }
.toolbar-divider { flex: 0 0 1px; height: 24px; margin: 0 3px; background: var(--line); }
.icon-action { width: 38px; padding: 0; font-size: 19px; }

/* ---------- Ngăn preset ---------- */
.preset-drawer { position: fixed; z-index: 55; top: 62px; bottom: 0; left: 0; display: grid; width: min(320px, 92vw); grid-template-rows: auto auto auto minmax(0,1fr) auto; border-right: 1px solid #5b6972; background: linear-gradient(165deg,#424549,#36383c 54%,#303236); box-shadow: 24px 0 70px rgba(0,0,0,.38); transform: translateX(-105%); transition: transform 190ms ease; }
.preset-drawer.open { transform: translateX(0); }
.drawer-handle { position: fixed; z-index: 56; top: 112px; left: 0; display: grid; width: 24px; height: 58px; padding: 0; border: 1px solid #61737e; border-left: 0; border-radius: 0 7px 7px 0; background: #41474c; color: var(--accent-text); cursor: pointer; place-items: center; transition: left 190ms ease, background 150ms ease; }
.drawer-handle:hover { background: #515c63; }
.drawer-handle.open { left: min(320px, 92vw); }
.drawer-handle span { display: block; font-size: 20px; line-height: 1; transition: transform 190ms ease; }
.drawer-handle.open span { transform: rotate(180deg); }
.drawer-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 18px 16px 12px; }
.drawer-header h2 { margin: 3px 0 0; font-size: 17px; letter-spacing: .08em; }
.drawer-close { width: 32px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: #44474b; color: var(--muted); cursor: pointer; font-size: 20px; }
.drawer-close:hover { border-color: #39708f; color: white; }
.drawer-hint { margin: 0 16px 10px; color: #a9bcc7; font-size: 12px; line-height: 1.45; }
.preset-amount { display: grid; grid-template-columns: auto minmax(0,1fr) 44px; align-items: center; gap: 8px 10px; margin: 0 16px 10px; padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 10px; background: rgba(0,0,0,.12); color: var(--muted); font-size: 12px; }
.preset-current { display: flex; grid-column: 1 / -1; justify-content: space-between; gap: 8px; }
.preset-current strong { overflow: hidden; color: var(--accent-text); text-overflow: ellipsis; white-space: nowrap; }
.preset-amount output { color: var(--text); font-variant-numeric: tabular-nums; text-align: right; }
.preset-list { min-height: 0; padding: 0 10px 10px; overflow-y: auto; scrollbar-color: #294a5d transparent; scrollbar-width: thin; }
.preset-group-title { margin: 10px 6px 5px; color: var(--subtle); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.preset-list-item { position: relative; display: flex; align-items: center; margin-bottom: 3px; border: 1px solid transparent; border-radius: 7px; transition: 130ms ease; }
.preset-list-item:hover, .preset-list-item:focus-within { border-color: #294d63; background: rgba(17,46,63,.72); }
.preset-list-item.active { border-color: var(--accent); background: var(--accent-soft); }
.preset-apply { display: grid; flex: 1; min-width: 0; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 8px; min-height: 40px; padding: 8px 10px; border: 0; border-radius: 7px; background: transparent; color: #d6d7db; cursor: pointer; text-align: left; }
.preset-list-item.active .preset-apply { color: var(--accent-text); }
.preset-list-name { display: block; overflow: hidden; font-size: 12px; font-weight: 720; text-overflow: ellipsis; white-space: nowrap; }
.preset-current-mark { color: var(--accent); font-size: 13px; }
.preset-actions { display: flex; gap: 2px; padding-right: 5px; opacity: 0; transition: opacity 120ms ease; }
.preset-list-item:hover .preset-actions, .preset-list-item:focus-within .preset-actions { opacity: 1; }
.preset-action { min-width: 28px; height: 26px; padding: 0 5px; border: 1px solid transparent; border-radius: 6px; background: rgba(255,255,255,.06); color: var(--muted); cursor: pointer; font-size: 11px; font-weight: 700; }
.preset-action:hover { border-color: var(--line); color: white; }
.preset-action.danger:hover { border-color: var(--danger); color: var(--danger); }
.drawer-footer { display: grid; gap: 7px; padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.drawer-footer span { color: #8fa3ae; font-size: 11px; line-height: 1.4; text-align: center; }

/* ---------- Nút ---------- */
.button, .icon-button, .fit-button, .mode-button, .mask-type, .tool-toggle, .chip-button { border: 1px solid transparent; border-radius: 9px; cursor: pointer; transition: 150ms ease; }
.button { flex: 0 0 auto; min-height: 38px; padding: 0 13px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.button-primary { border-color: #368be9; background: #1678df; color: white; }
.button-primary:hover:not(:disabled) { background: #2486ee; }
.button-ghost { border-color: var(--line); background: #44464a; color: #f0f0f2; }
.button-ghost:hover:not(:disabled) { border-color: #6c7076; background: var(--surface-hover); }
button:disabled { cursor: not-allowed; opacity: .4; }
.chip-button { min-height: 28px; padding: 0 10px; border-color: var(--line); background: #44464a; color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.chip-button:hover:not(:disabled), .chip-button.active { border-color: var(--accent); color: var(--accent-text); }
.chip-button.active { background: var(--accent-soft); }

/* ---------- Khu xem ảnh ---------- */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 0; min-height: 0; transition: grid-template-columns 200ms ease; }
body.panel-open .workspace { grid-template-columns: minmax(0, 1fr) var(--panel-width, 372px); }
.stage-panel { position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr) auto 32px; min-width: 0; min-height: 0; background: radial-gradient(circle at 50% 35%, #4b4e52 0, #36383c 52%, #2c2e31 100%); }
.stage-toolbar, .stage-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 15px; color: var(--muted); font-size: 12px; }
.stage-toolbar { min-height: 50px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--line-soft); background: rgba(53,55,58,.82); }
.stage-footer { overflow: hidden; border-top: 1px solid var(--line-soft); background: #343639; white-space: nowrap; }
.footer-hints { overflow: hidden; text-overflow: ellipsis; }
.file-meta, .zoom-controls { display: flex; align-items: center; }
.file-meta { min-width: 0; flex: 1 1 160px; gap: 10px; }
.file-name { max-width: min(28vw, 380px); overflow: hidden; color: #e3e3e6; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.file-dimensions { color: var(--subtle); white-space: nowrap; }
.zoom-controls { flex: 1 1 auto; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.icon-button, .fit-button, .tool-toggle { height: 30px; border-color: transparent; background: transparent; color: var(--muted); }
.icon-button { width: 30px; padding: 0; font-size: 18px; }
.fit-button { padding: 0 8px; font-size: 12px; }
.tool-toggle { padding: 0 10px; border-color: var(--line); font-size: 12px; font-weight: 700; white-space: nowrap; }
.tool-toggle.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.icon-button:hover:not(:disabled), .fit-button:hover:not(:disabled), .tool-toggle:hover:not(:disabled) { background: var(--surface); color: white; }
#zoomValue { min-width: 72px; text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }

.preview-modes { display: flex; flex: 0 0 auto; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #393b3e; }
.mode-button { min-width: 58px; height: 28px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; }
.mode-button:hover { color: white; }
.mode-button.active { background: #55585d; color: white; }

.canvas-viewport { position: relative; display: grid; min-height: 0; overflow: hidden; place-items: center; touch-action: none; user-select: none; }
#editorCanvas { position: absolute; inset: 0; display: block; }
.image-frame { position: absolute; z-index: 3; pointer-events: none; box-shadow: var(--shadow); }
.frame-overlay { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.frame-overlay .geo-line { fill: none; stroke: rgba(255,255,255,.9); stroke-width: 1.3; filter: drop-shadow(0 0 1.5px rgba(0,0,0,.95)); }
.frame-overlay .geo-mid { stroke-dasharray: 2 5; stroke: rgba(255,255,255,.55); }
.frame-overlay .geo-dashed { stroke-dasharray: 6 5; }
.frame-overlay .geo-axis { stroke: rgba(25,201,242,.75); stroke-width: 1; }
.frame-overlay .geo-handle { fill: var(--accent); stroke: white; stroke-width: 1.6; filter: drop-shadow(0 0 2px rgba(0,0,0,.8)); }
.frame-overlay .geo-handle-alt { fill: #1d1f22; }
.frame-overlay .geo-rotate { fill: #f2c230; }
.frame-overlay .crop-shade { fill: rgba(10,11,13,.62); }
.frame-overlay .crop-frame { fill: none; stroke: rgba(255,255,255,.9); stroke-width: 1; }
.frame-overlay .crop-grid { stroke: rgba(255,255,255,.35); stroke-width: 1; }
.frame-overlay .crop-corner { fill: none; stroke: white; stroke-width: 3.5; filter: drop-shadow(0 0 2px rgba(0,0,0,.8)); }
.frame-overlay .crop-edge { stroke: white; stroke-width: 3.5; filter: drop-shadow(0 0 2px rgba(0,0,0,.8)); }
.before-badge, .mask-badge { position: absolute; z-index: 6; top: 13px; padding: 6px 9px; border: 1px solid rgba(255,255,255,.18); border-radius: 6px; background: rgba(4,4,6,.76); color: white; font-size: 11px; font-weight: 850; letter-spacing: .1em; line-height: 1; backdrop-filter: blur(10px); }
.before-badge { left: 13px; }
.mask-badge { right: 13px; display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 10px; border-color: rgba(255,80,110,.5); color: #ffb3c2; letter-spacing: .02em; }
.mask-badge button { padding: 4px 9px; border: 1px solid rgba(255,255,255,.25); border-radius: 5px; background: rgba(255,255,255,.08); color: white; cursor: pointer; font-size: 11px; font-weight: 700; }
.mask-badge button:hover { background: rgba(255,255,255,.18); }
.preview-badge { position: absolute; z-index: 6; top: 13px; left: 50%; padding: 6px 10px; border: 1px solid rgba(25,201,242,.55); border-radius: 6px; background: rgba(4,12,18,.82); color: var(--accent-text); font-size: 11px; font-weight: 850; letter-spacing: .08em; transform: translateX(-50%); backdrop-filter: blur(10px); }
.split-line { position: absolute; z-index: 3; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: rgba(255,255,255,.9); box-shadow: 0 0 0 1px rgba(0,0,0,.42), 0 0 16px rgba(0,0,0,.8); }
.split-grip { position: absolute; top: 50%; left: 50%; width: 22px; height: 36px; border: 2px solid white; border-radius: 11px; background: rgba(20,22,24,.8); transform: translate(-50%,-50%); }
.split-label { position: absolute; top: 12px; padding: 5px 7px; border-radius: 5px; background: rgba(3,3,4,.72); color: white; font-size: 11px; font-weight: 800; letter-spacing: .08em; line-height: 1; white-space: nowrap; }
.split-before { right: 8px; }
.split-after { left: 8px; }
.brush-cursor { position: absolute; z-index: 7; border: 1px solid white; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,.85); pointer-events: none; transform: translate(-50%,-50%); }
.brush-cursor::after { position: absolute; top: 50%; left: 50%; width: var(--inner, 0); height: var(--inner, 0); border: 1px dashed rgba(255,255,255,.6); border-radius: 50%; content: ""; transform: translate(-50%,-50%); }

.crop-bar { position: absolute; z-index: 8; bottom: 12px; left: 50%; display: flex; max-width: calc(100% - 24px); flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 14px; padding: 9px 12px; border: 1px solid #5f6267; border-radius: 12px; background: rgba(40,42,45,.94); box-shadow: 0 14px 40px rgba(0,0,0,.5); transform: translateX(-50%); backdrop-filter: blur(10px); }
.crop-field { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.crop-bar { cursor: default; }
.crop-field select { width: auto; height: 32px; }
.crop-straighten input { width: 150px; }
.crop-straighten output { min-width: 44px; color: var(--text); font-variant-numeric: tabular-nums; }
.crop-buttons { display: flex; gap: 6px; }
.crop-buttons .button { min-height: 32px; padding: 0 11px; }

.empty-state { position: relative; z-index: 2; display: flex; width: min(480px, 90%); flex-direction: column; align-items: center; padding: 42px 28px; border: 1px dashed #686a70; border-radius: 18px; background: linear-gradient(145deg, rgba(76,78,82,.86), rgba(48,50,53,.86)); text-align: center; box-shadow: inset 0 1px rgba(255,255,255,.05); }
.empty-visual { width: 105px; color: #6a6a76; }
.empty-visual svg { width: 100%; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.empty-state h1 { margin: 13px 0 6px; font-size: clamp(22px, 3vw, 30px); letter-spacing: -.04em; }
.empty-state p { margin: 0 0 21px; color: var(--muted); font-size: 14px; }
.open-image-button { min-width: 130px; }
.sample-button { margin-top: 10px; padding: 4px 8px; border: 0; border-bottom: 1px solid #555560; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; }
.sample-button:hover { border-color: var(--accent); color: var(--accent-text); }
.restore-card { display: grid; width: 100%; gap: 6px; margin-top: 18px; padding: 14px; border: 1px solid rgba(25,201,242,.4); border-radius: 12px; background: rgba(17,46,63,.5); text-align: left; }
.restore-card strong { font-size: 14px; }
.restore-card span { color: var(--muted); font-size: 12px; }
.restore-actions { display: flex; gap: 8px; margin-top: 6px; }
.privacy-note { margin-top: 15px; color: var(--subtle); font-size: 12px; }
.drop-overlay { position: absolute; z-index: 20; inset: 13px; display: grid; border: 2px dashed var(--accent); border-radius: 17px; background: rgba(3,12,18,.92); color: var(--accent-text); font-size: 20px; font-weight: 750; place-items: center; backdrop-filter: blur(12px); }
kbd { padding: 1px 5px; border: 1px solid #303038; border-radius: 4px; background: #121216; color: #d4d4da; font-family: inherit; font-size: 11px; }

/* ---------- Filmstrip ---------- */
.filmstrip { min-width: 0; padding: 8px 12px 10px; border-top: 1px solid var(--line); background: linear-gradient(180deg, #3c3e42, #313336); }
.filmstrip-header { display: flex; align-items: center; justify-content: space-between; min-height: 22px; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.filmstrip-header div { display: flex; align-items: center; gap: 10px; }
.filmstrip-header strong { color: #e5e5e8; font-size: 12px; }
.text-button { padding: 2px 0; border: 0; border-bottom: 1px solid transparent; background: transparent; color: #c8c8d0; cursor: pointer; font-size: 12px; }
.text-button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-text); }
.filmstrip-list { display: flex; gap: 8px; min-width: 0; padding: 3px; overflow-x: auto; scrollbar-color: #353540 transparent; scrollbar-width: thin; }
.thumb-card { position: relative; flex: 0 0 96px; height: 66px; overflow: hidden; border: 1px solid #282831; border-radius: 8px; background: #09090b; transition: 130ms ease; }
.thumb-card:hover { border-color: #6a6a7a; }
.thumb-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(25,201,242,.22); }
.thumb-open { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: transparent; cursor: pointer; }
.thumb-open img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.thumb-index { position: absolute; right: 4px; bottom: 4px; min-width: 18px; padding: 2px 4px; border-radius: 4px; background: rgba(0,0,0,.72); color: white; font-size: 11px; line-height: 1.1; }
.thumb-edited { position: absolute; bottom: 6px; left: 6px; width: 8px; height: 8px; border: 1px solid rgba(0,0,0,.6); border-radius: 50%; background: var(--accent); }
.thumb-select, .thumb-remove { position: absolute; top: 4px; display: grid; width: 22px; height: 22px; padding: 0; border: 1px solid rgba(255,255,255,.68); border-radius: 6px; background: rgba(0,0,0,.6); color: white; cursor: pointer; font-size: 12px; place-items: center; }
.thumb-select { left: 4px; }
.thumb-remove { right: 4px; opacity: 0; font-size: 15px; }
.thumb-card:hover .thumb-remove, .thumb-remove:focus-visible { opacity: 1; }
.thumb-remove:hover { border-color: var(--danger); background: var(--danger); }
.thumb-card.selected .thumb-select { border-color: transparent; background: var(--accent-2); }

/* ---------- Bảng điều chỉnh ---------- */
.panel-handle { position: absolute; z-index: 30; top: 50%; right: 0; display: grid; width: 24px; height: 64px; padding: 0; border: 1px solid #61737e; border-right: 0; border-radius: 7px 0 0 7px; background: #41474c; color: var(--accent-text); cursor: pointer; place-items: center; transform: translateY(-50%); }
.panel-handle:hover { background: #515c63; }
.panel-handle span { display: block; font-size: 20px; line-height: 1; transition: transform 190ms ease; }
body.panel-open .panel-handle span { transform: rotate(180deg); }
.control-panel { position: relative; display: grid; width: var(--panel-width, 372px); grid-template-rows: auto auto minmax(0,1fr); min-width: 0; min-height: 0; overflow: hidden; border-left: 1px solid var(--line); background: linear-gradient(180deg, #414347, #37393c 55%, #323437); box-shadow: -14px 0 40px rgba(0,0,0,.18); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px 8px 17px; border-bottom: 1px solid var(--line-soft); }
.panel-header h2 { margin: 2px 0 0; font-size: 15px; }
.panel-header-tools { display: flex; align-items: center; gap: 6px; }
.chip-button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.panel-lock-note { margin: 10px 14px 0; padding: 10px 12px; border: 1px dashed #6a7d88; border-radius: 9px; background: rgba(17,46,63,.35); color: #bcd3de; font-size: 12px; line-height: 1.45; }
.panel-body { display: grid; grid-template-rows: auto minmax(0,1fr); min-height: 0; }
.control-panel.locked .panel-body { opacity: .38; filter: grayscale(.5); pointer-events: none; user-select: none; }
.histogram-panel { margin: 10px 14px 0; padding-bottom: 8px; border-bottom: 1px solid var(--line-soft); }
.histogram-box { position: relative; height: 110px; overflow: hidden; border: 1px solid var(--line-soft); border-radius: 10px; background: #26282b; }
.histogram-box canvas { display: block; width: 100%; height: 100%; }
.clip-indicator { position: absolute; top: 6px; width: 0; height: 0; padding: 0; border: 7px solid transparent; background: transparent; cursor: pointer; opacity: .45; }
.clip-shadows { left: 6px; border-top-color: #5f6b78; border-left-color: #5f6b78; }
.clip-highlights { right: 6px; border-top-color: #5f6b78; border-right-color: #5f6b78; }
.clip-shadows.active { border-top-color: #4d8bff; border-left-color: #4d8bff; opacity: 1; }
.clip-highlights.active { border-top-color: #ff5a5a; border-right-color: #ff5a5a; opacity: 1; }
.histogram-info { display: block; margin-top: 5px; overflow: hidden; color: #c8cbd0; font-size: 11px; font-variant-numeric: tabular-nums; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.panel-scroll { min-height: 0; overflow-y: auto; scrollbar-color: #4a4d52 transparent; scrollbar-width: thin; }
.adjustment-section, .mask-section { border-bottom: 1px solid var(--line); }
.section-head { display: flex; align-items: center; gap: 8px; padding-right: 14px; }
.section-head .section-heading { flex: 1; min-width: 0; }
.section-dot { display: none; width: 6px; height: 6px; margin-left: 7px; border-radius: 50%; background: var(--accent); vertical-align: middle; }
[data-section].modified .section-dot { display: inline-block; }
.section-bypass { display: grid; flex: 0 0 auto; width: 28px; height: 28px; padding: 0; place-items: center; border: 1px solid var(--line); border-radius: 7px; background: #44464a; color: var(--muted); cursor: pointer; font-size: 14px; }
.section-bypass:hover { border-color: var(--accent); color: var(--accent-text); }
.section-bypass[aria-pressed="true"] { border-color: #e2a33c; background: rgba(226,163,60,.16); color: #ffcf7a; }
[data-section].bypassed > :not(.section-head) { opacity: .45; }
[data-section].bypassed .section-heading h2::after { margin-left: 8px; padding: 1px 6px; border-radius: 4px; background: rgba(226,163,60,.2); color: #ffcf7a; content: "ĐANG TẮT"; font-size: 10px; letter-spacing: .08em; vertical-align: middle; }
html[lang="en"] [data-section].bypassed .section-heading h2::after { content: "OFF"; }
.section-bypass svg { width: 16px; height: 16px; vertical-align: middle; }
.head-tools { display: flex; gap: 6px; }
.section-heading { display: flex; width: 100%; align-items: center; justify-content: space-between; margin: 0; border: 0; background: transparent; text-align: left; }
.section-toggle { padding: 15px 17px 10px; cursor: pointer; }
.section-heading h2, .dialog-header h2 { margin: 2px 0 0; font-size: 15px; letter-spacing: -.01em; }
.section-heading h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-heading > div { min-width: 0; }
.eyebrow { color: var(--subtle); font-size: 11px; font-weight: 850; letter-spacing: .14em; }
.chevron { color: var(--subtle); transition: transform 180ms ease; }
.section-toggle[aria-expanded="false"] .chevron { transform: rotate(-90deg); }
.section-toggle[aria-expanded="false"] + .controls-list,
.section-toggle[aria-expanded="false"] + .section-content,
.section-head:has(.section-toggle[aria-expanded="false"]) + .controls-list,
.section-head:has(.section-toggle[aria-expanded="false"]) + .section-content { display: none; }
.section-help { margin: 6px 17px 0; color: var(--subtle); font-size: 11px; line-height: 1.45; }
.hsl-content { padding: 0 0 12px; }
.hsl-tabs, .segmented { display: grid; grid-template-columns: repeat(4,1fr); margin: 0 17px 8px; border-bottom: 1px solid var(--line); }
.hsl-tab, .segment { min-height: 30px; padding: 0 3px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; }
.hsl-tab:hover, .segment:hover { color: white; }
.hsl-tab.active, .segment.active { border-bottom-color: var(--accent); color: var(--accent-text); }
.segment.modified::after { display: inline-block; width: 5px; height: 5px; margin-left: 5px; border-radius: 50%; background: var(--accent); content: ""; vertical-align: middle; }
.hsl-controls { padding: 0 17px; }
.curve-content { padding-bottom: 14px; }
.curve-canvas { display: block; width: calc(100% - 34px); height: 210px; margin: 4px 17px 0; border-radius: 8px; cursor: crosshair; touch-action: none; }
.grade-content { padding: 0 17px 14px; }
.grade-wheels { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px 14px; }
.grade-wheel { display: grid; justify-items: center; gap: 5px; }
.grade-title { color: #d6d7db; font-size: 12px; font-weight: 700; }
.wheel-canvas { width: 112px; height: 112px; border-radius: 50%; cursor: crosshair; touch-action: none; }
.grade-readout { color: var(--subtle); font-size: 11px; font-variant-numeric: tabular-nums; }
.grade-lum { width: 100%; }
.grade-sliders { margin-top: 10px; padding: 0; }
.controls-list { padding: 0 17px 16px; }
.control-row { display: grid; grid-template-columns: 96px minmax(0,1fr) 48px; align-items: center; gap: 9px; min-height: 32px; }
.control-row label { overflow: hidden; color: #cfd0d5; cursor: default; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; user-select: none; }
.control-row.changed label { color: white; }
.control-value { width: 48px; height: 25px; padding: 0; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; text-align: center; }
.control-row.changed .control-value { color: var(--accent-text); }
.control-value:focus, .control-value:hover { border-color: var(--line); background: var(--surface); color: white; }
.control-value:focus-visible { box-shadow: var(--focus); }
input[type="range"] { width: 100%; height: 22px; margin: 0; appearance: none; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: linear-gradient(90deg,#2c2c35 0 var(--range-from,0%),var(--accent) var(--range-from,0%) var(--range-to,50%),#2c2c35 var(--range-to,50%) 100%); }
input[type="range"]::-webkit-slider-thumb { width: 13px; height: 13px; margin-top: -5px; appearance: none; border: 2px solid #101014; border-radius: 50%; background: white; box-shadow: 0 0 0 1px rgba(255,255,255,.24); }
input[type="range"]::-moz-range-track { height: 3px; border: 0; border-radius: 3px; background: linear-gradient(90deg,#2c2c35 0 var(--range-from,0%),var(--accent) var(--range-from,0%) var(--range-to,50%),#2c2c35 var(--range-to,50%) 100%); }
input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border: 2px solid #101014; border-radius: 50%; background: white; }
input[type="range"]:disabled { cursor: not-allowed; opacity: .4; }
input.color-track::-webkit-slider-runnable-track { background: var(--track-background) !important; box-shadow: inset 0 0 0 1px rgba(0,0,0,.26); }
input.color-track::-moz-range-track { background: var(--track-background) !important; box-shadow: inset 0 0 0 1px rgba(0,0,0,.26); }

.mask-section { padding-bottom: 17px; }
.mask-heading { padding: 17px 17px 12px; }
.mask-type-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; padding: 0 17px; }
.mask-type { min-height: 34px; padding: 0 7px; border-color: var(--line); background: #44464a; color: var(--muted); font-size: 12px; font-weight: 700; }
.mask-type:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-text); }
.mask-list { display: grid; gap: 4px; margin: 10px 17px 0; padding: 0; list-style: none; }
.mask-item { display: flex; align-items: center; gap: 2px; border: 1px solid var(--line-soft); border-radius: 8px; background: #3b3d41; }
.mask-item.active { border-color: var(--accent); background: var(--accent-soft); }
.mask-item.muted .mask-name { color: var(--subtle); text-decoration: line-through; }
.mask-select { display: flex; flex: 1; min-width: 0; align-items: center; gap: 8px; min-height: 34px; padding: 0 10px; border: 0; background: transparent; color: #e3e3e6; cursor: pointer; font-size: 12px; text-align: left; }
.mask-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mask-flag { padding: 1px 5px; border-radius: 4px; background: rgba(255,255,255,.1); color: var(--muted); font-size: 11px; }
.mask-dot { flex: 0 0 10px; width: 10px; height: 10px; border-radius: 50%; }
.mask-dot-sky { background: #5aa8ff; }
.mask-dot-brush { background: #ff7aa2; }
.mask-dot-linear { background: linear-gradient(180deg,#fff,#555); }
.mask-dot-radial { border: 2px solid #f2c230; }
.mask-dot-luma { background: linear-gradient(90deg,#111,#fff); }
.mask-dot-color { background: conic-gradient(#f44,#fd4,#4d6,#4cf,#64f,#f4c,#f44); }
.range-refine { margin: 2px 17px 8px; padding: 9px 10px 4px; border: 1px solid var(--line-soft); border-radius: 9px; background: rgba(0,0,0,.1); }
.range-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.range-head select { width: auto; height: 32px; }
.range-color { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.range-swatch { width: 28px; height: 28px; border: 2px solid rgba(255,255,255,.7); border-radius: 50%; box-shadow: 0 0 0 1px #000; }
.range-controls { padding: 6px 0 4px; }
.mask-icon { width: 30px; height: 30px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; }
.mask-icon:hover { background: rgba(255,255,255,.08); color: white; }
.mask-icon.danger:hover { color: var(--danger); }
.mask-help { margin: 10px 17px 8px; color: var(--subtle); font-size: 12px; line-height: 1.45; }
.mask-actions, .brush-options { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 9px 12px; padding: 4px 17px 9px; }
.toggle-label { display: flex; align-items: center; gap: 6px; color: #c9c9d1; cursor: pointer; font-size: 12px; }
.toggle-label input { accent-color: var(--accent); }
.brush-options { display: grid; gap: 4px; padding-top: 2px; }
.mini-control { display: grid; grid-template-columns: 72px minmax(0,1fr) 34px; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.mini-control output { text-align: right; font-variant-numeric: tabular-nums; }
.mask-controls { padding-top: 7px; border-top: 1px solid var(--line-soft); }

/* ---------- Hộp thoại ---------- */
.app-dialog { width: min(460px,calc(100vw - 28px)); padding: 0; border: 1px solid #66686d; border-radius: 15px; background: linear-gradient(160deg,#4a4c50,#333538); color: var(--text); box-shadow: 0 30px 100px rgba(0,0,0,.58); }
.app-dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(7px); }
.app-dialog form { padding: 22px; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.dialog-close { width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px; background: var(--surface); color: var(--muted); cursor: pointer; font-size: 20px; }
.dialog-text { margin: 0 0 12px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.field-label-row, .export-summary { display: flex; align-items: center; justify-content: space-between; }
.field-label { display: block; margin: 14px 0 7px; color: #d2d2d8; font-size: 12px; font-weight: 700; }
.field-label-row .field-label { margin-bottom: 4px; }
#qualityValue { margin-top: 12px; color: var(--muted); font-size: 12px; }
select, .text-input { width: 100%; height: 40px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: white; }
select:focus, .text-input:focus { border-color: var(--accent); }
.checkbox-stack { display: grid; gap: 8px; margin-top: 14px; }
.export-summary { margin-top: 12px; padding: 12px 0; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 12px; }
.export-summary strong { color: #dedee3; font-weight: 650; }
.export-progress { display: grid; gap: 7px; margin-top: 4px; color: var(--muted); font-size: 12px; }
.progress-track { height: 6px; overflow: hidden; border-radius: 4px; background: #26282b; }
.progress-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width 160ms ease; }
.dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.dialog-actions .spacer { flex: 1; }
.group-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 12px; }
.shortcut-list { display: grid; grid-template-columns: auto 1fr; gap: 9px 14px; max-height: 60vh; margin: 0; overflow-y: auto; font-size: 13px; }
.shortcut-list dt { color: var(--muted); white-space: nowrap; }
.shortcut-list dd { margin: 0; color: #e5e5e8; }
#shortcutsDialog { width: min(560px, calc(100vw - 28px)); }

.toast { position: absolute; z-index: 100; bottom: 46px; left: 50%; display: flex; align-items: center; gap: 12px; width: max-content; max-width: min(520px,calc(100% - 32px)); padding: 11px 14px; border: 1px solid #3b3b46; border-radius: 9px; background: #16161c; color: white; box-shadow: 0 16px 44px rgba(0,0,0,.55); font-size: 13px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: 180ms ease; }
.toast { transform: translate(-50%, 8px); }
.toast.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.toast-action { flex: 0 0 auto; padding: 5px 9px; border: 1px solid var(--accent); border-radius: 6px; background: transparent; color: var(--accent-text); cursor: pointer; font-size: 12px; font-weight: 700; }

/* ---------- Menu, filmstrip, lịch sử, xuất ---------- */
.menu-button span { margin-left: 4px; font-size: 10px; }
.menu-popover { position: fixed; z-index: 120; min-width: 280px; margin: 0; padding: 6px; border: 1px solid #66686d; border-radius: 11px; background: #2f3134; box-shadow: 0 18px 50px rgba(0,0,0,.55); list-style: none; }
.menu-popover button { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 16px; min-height: 36px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; color: #e6e6ea; cursor: pointer; font-size: 13px; text-align: left; }
.menu-popover button:hover:not(:disabled), .menu-popover button:focus-visible { background: var(--accent-soft); color: white; box-shadow: none; }
.menu-popover button.danger:hover { background: rgba(239,107,116,.16); color: #ffb8be; }
.menu-popover kbd { color: var(--subtle); font-size: 10px; white-space: nowrap; }
.menu-separator { height: 1px; margin: 5px 4px; background: var(--line); }
.lang-toggle { width: 42px; font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.frame-overlay .crop-angle rect { fill: rgba(5,6,8,.78); stroke: rgba(255,255,255,.35); }
.frame-overlay .crop-angle text, .frame-overlay .crop-size { fill: white; font: 700 13px Inter, system-ui, sans-serif; }
.frame-overlay .crop-size { fill: rgba(255,255,255,.85); font-size: 11px; paint-order: stroke; stroke: rgba(0,0,0,.8); stroke-width: 3px; }
.filmstrip-header { gap: 10px; }
.filmstrip-info { flex-wrap: wrap; min-width: 0; }
.filmstrip-tools { display: flex; align-items: center; gap: 12px; }
.filter-field { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.filter-field select { width: auto; height: 28px; padding: 0 8px; font-size: 12px; }
.folder-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 360px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; color: #d6d7db; font-size: 11px; }
.folder-chip #folderChipName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-chip .toggle-label { font-size: 11px; white-space: nowrap; }
.folder-icon { color: var(--accent-text); }
.thumb-meta { position: absolute; bottom: 4px; left: 4px; display: flex; gap: 4px; align-items: center; pointer-events: none; }
.thumb-stars { padding: 1px 4px; border-radius: 4px; background: rgba(0,0,0,.72); color: #ffd25e; font-size: 10px; letter-spacing: -1px; line-height: 1.3; }
.thumb-flag { display: grid; width: 16px; height: 16px; border-radius: 4px; font-size: 10px; place-items: center; }
.thumb-flag.pick { background: #e8eef2; color: #111; }
.thumb-flag.reject { background: #d44; color: white; }
.thumb-card.rejected img { opacity: .38; filter: grayscale(.8); }
.thumb-edited { top: 30px; bottom: auto; left: 8px; }
.filmstrip-empty { margin: 8px 0 4px; color: var(--muted); font-size: 12px; }
.storage-info { color: var(--subtle); font-variant-numeric: tabular-nums; }
.storage-info.warn { color: #ffcf7a; }
.history-content { padding: 0 17px 14px; }
.subhead { margin: 6px 0 6px; color: var(--subtle); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.history-list, .snapshot-list { display: grid; gap: 2px; max-height: 260px; margin: 0 0 10px; padding: 0; overflow-y: auto; list-style: none; }
.snapshot-item { display: flex; align-items: center; gap: 4px; }
.history-step { display: block; width: 100%; min-height: 30px; padding: 0 10px; overflow: hidden; border: 1px solid transparent; border-radius: 7px; background: transparent; color: #d6d7db; cursor: pointer; font-size: 12px; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.history-step:hover { background: rgba(255,255,255,.06); }
.history-step.current { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); cursor: default; }
.history-step.future { color: var(--subtle); font-style: italic; }
.snapshot-list .history-step { border-color: var(--line-soft); }
.inline-row { display: flex; gap: 6px; }
.inline-row select { flex: 1; }
.inline-row .button { min-height: 40px; }
.token-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.token { padding: 3px 7px; border: 1px solid var(--line); border-radius: 6px; background: #3b3d41; color: #cfe9f3; cursor: pointer; font: 11px ui-monospace, Consolas, monospace; }
.token:hover { border-color: var(--accent); }
.template-preview { min-height: 16px; margin: 7px 0 0; color: var(--subtle); font-size: 12px; word-break: break-all; }
.export-dialog { width: min(520px, calc(100vw - 28px)); max-height: calc(100vh - 28px); }

/* ---------- Chế độ xem: Lưới / So sánh ---------- */
.view-modes { display: flex; flex: 0 0 auto; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #393b3e; }
.view-modes .mode-button { min-width: 50px; }
.stage-panel > .canvas-viewport, .grid-view, .survey-view { grid-row: 2; grid-column: 1; }
.stage-panel.view-grid .filmstrip, .stage-panel.view-grid .preview-modes, .stage-panel.view-survey .preview-modes,
.stage-panel.view-grid .zoom-controls, .stage-panel.view-survey .zoom-controls { display: none; }
.grid-view { display: grid; grid-template-rows: auto minmax(0,1fr); min-height: 0; }
.grid-view[hidden], .survey-view[hidden] { display: none; }
.grid-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 15px 8px 34px; border-bottom: 1px solid var(--line-soft); color: var(--subtle); font-size: 11px; }
.grid-size { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.grid-size input { width: 120px; }
.grid-list { --grid-size: 200px; display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--grid-size), 1fr)); align-content: start; gap: 12px; min-height: 0; padding: 14px 34px 18px; overflow-y: auto; outline: none; }
.grid-card { display: grid; grid-template-rows: auto auto; overflow: hidden; border: 1px solid #2a2b31; border-radius: 10px; background: #26272b; cursor: pointer; transition: border-color 120ms ease, box-shadow 120ms ease; }
.grid-card:hover { border-color: #6a6a7a; }
.grid-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(25,201,242,.25); }
.grid-card.selected .grid-name::before { content: "✓ "; color: var(--accent-text); }
.grid-card.rejected .grid-thumb img { opacity: .38; }
.grid-thumb { position: relative; display: grid; min-height: 0; overflow: hidden; aspect-ratio: 4 / 3; background: #101114; place-items: center; }
.grid-thumb img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.grid-flag { position: absolute; top: 6px; right: 6px; padding: 2px 6px; border-radius: 5px; background: rgba(0,0,0,.7); font-size: 12px; }
.grid-flag.pick { color: #8fe08f; }
.grid-flag.reject { color: #ff8a8a; }
.grid-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; padding: 6px 8px; color: var(--muted); font-size: 11px; }
.grid-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid-stars { display: flex; flex: 0 0 auto; }
.grid-star { width: 15px; padding: 0; border: 0; background: transparent; color: #5f6168; cursor: pointer; font-size: 12px; line-height: 1; }
.grid-star.on { color: #f2c230; }
.grid-star:hover { color: #ffe08a; }
.survey-view { display: grid; grid-template-rows: minmax(0,1fr) auto; min-height: 0; padding: 12px 34px; }
.survey-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); grid-auto-rows: minmax(0,1fr); gap: 10px; min-height: 0; }
.survey-grid[data-count="2"] { grid-template-rows: minmax(0,1fr); }
.survey-cell { position: relative; display: grid; grid-template-rows: minmax(0,1fr) auto; min-height: 0; margin: 0; overflow: hidden; border: 1px solid #2a2b31; border-radius: 10px; background: #18191c; cursor: pointer; }
.survey-cell.active { border-color: var(--accent); }
.survey-cell.loading::after { content: ""; position: absolute; top: 10px; right: 10px; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.25); border-top-color: var(--accent); border-radius: 50%; animation: spin 800ms linear infinite; }
.survey-cell img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.survey-cell figcaption { display: flex; justify-content: space-between; gap: 8px; padding: 6px 10px; color: var(--muted); font-size: 12px; }
.survey-stars { color: #f2c230; }
.survey-hint { margin: 8px 4px 0; color: var(--subtle); font-size: 12px; text-align: center; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- So sánh với mốc, lưới căn ---------- */
.compare-badge { position: absolute; z-index: 6; bottom: 13px; left: 50%; display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 10px; border: 1px solid rgba(25,201,242,.5); border-radius: 6px; background: rgba(4,12,18,.82); color: var(--accent-text); font-size: 11px; font-weight: 700; transform: translateX(-50%); backdrop-filter: blur(10px); }
.compare-badge button { width: 22px; height: 22px; padding: 0; border: 1px solid rgba(255,255,255,.25); border-radius: 5px; background: rgba(255,255,255,.08); color: white; cursor: pointer; }
.history-row { display: flex; align-items: center; gap: 2px; }
.compare-icon { display: grid; flex: 0 0 auto; width: 26px; height: 26px; opacity: .55; place-items: center; }
.history-row:hover .compare-icon, .snapshot-item .compare-icon, .compare-icon.active, .compare-icon:focus-visible { opacity: 1; }
.compare-icon.active { background: var(--accent-soft); color: var(--accent-text); }
.frame-overlay .guide-grid { stroke: rgba(255,255,255,.28); stroke-width: 1; }
.guide-toggle { margin: 0 17px 6px; }

/* ---------- LUT, đường cong tham số, bút ---------- */
.lut-content .inline-row { margin: 0 17px 8px; }
.lut-content .inline-row select { height: 34px; }
.lut-content .inline-row .button { min-height: 34px; padding: 0 10px; }
.section-warning { margin: 0 17px 8px; padding: 7px 9px; border: 1px solid rgba(242,194,48,.45); border-radius: 7px; background: rgba(242,194,48,.08); color: #f2d27a; font-size: 11px; line-height: 1.4; }
.disabled-controls { opacity: .45; pointer-events: none; }
.sub-details { margin: 10px 0 0; border-top: 1px solid var(--line-soft); }
.sub-details summary { padding: 9px 17px 6px; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 700; list-style-position: inside; }
.sub-details.modified summary::after { content: " •"; color: var(--accent); }
.pressure-field select { width: auto; height: 30px; font-size: 12px; }

/* ---------- Watermark ---------- */
.watermark-field { margin: 12px 0 0; padding: 8px 12px 10px; border: 1px solid var(--line-soft); border-radius: 10px; }
.watermark-field legend { padding: 0 4px; }
.watermark-body { display: grid; gap: 8px; margin-top: 6px; }
.watermark-body .mini-control { grid-template-columns: 56px minmax(0,1fr) 40px; }
.watermark-logo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.watermark-logo-row img { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 6px; background: repeating-conic-gradient(#555 0 25%, #333 0 50%) 0 0 / 10px 10px; object-fit: contain; }
.watermark-logo-row input[type="color"] { width: 28px; height: 22px; padding: 0; border: 0; background: transparent; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: minmax(0,1fr) 340px; }
  .brand-subtitle { display: none; }
}
@media (max-width: 850px) {
  .workspace, body.panel-open .workspace { grid-template-columns: minmax(0,1fr) 0; }
  .control-panel { position: fixed; z-index: 70; top: 62px; right: 0; bottom: 0; width: min(380px, 92vw); box-shadow: -24px 0 70px rgba(0,0,0,.5); transform: translateX(105%); transition: transform 190ms ease; }
  body.panel-open .control-panel { transform: translateX(0); }
  .panel-handle { position: fixed; z-index: 71; top: auto; right: 0; bottom: 90px; transform: none; transition: right 190ms ease; }
  body.panel-open .panel-handle { right: min(380px, 92vw); }
  .footer-hints, .folder-chip { display: none; }
}
@media (max-width: 650px) {
  .workspace, .stage-panel, .control-panel { min-width: 0; max-width: 100vw; }
  .stage-toolbar { padding: 6px 9px; }
  .file-meta { flex-basis: 100%; }
  .zoom-controls { justify-content: space-between; width: 100%; }
  #zoomValue { min-width: 0; }
  .fit-button { padding: 0 5px; }
  .tool-toggle { padding: 0 8px; }
  .stage-panel { min-height: 70vh; }
  .crop-bar { bottom: 6px; gap: 8px; padding: 8px; }
  .histogram-panel { height: 100px; }
  .thumb-remove { opacity: 1; }
  .drawer-handle { top: auto; bottom: 18px; height: 48px; }
  .preset-actions { opacity: 1; }
  .topbar { padding: 0 9px; }
  .brand-name { display: none; }
  .file-dimensions { display: none; }
  .button { padding: 0 10px; }
  .preview-modes { width: 100%; order: 3; }
  .mode-button { flex: 1; }
  .crop-straighten input { width: 110px; }
  .field-grid, .group-checks { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
