[data-theme="dark"] {
--bg-primary: #0A0A12;
--bg-secondary: #10101C;
--bg-tertiary: #161628;
--bg-surface: #12121E;
--bg-hover: #1E1E38;
--bg-active: #282850;
--text-primary: #EAEAF4;
--text-secondary: #9898B4;
--text-muted: #606078;
--border-primary: #252544;
--border-secondary: #303056;
--accent: #3B82F6;
--accent-hover: #2563EB;
--accent-glow: rgba(59, 130, 246, 0.12);
--accent-text: #FFFFFF;
--success: #22C55E;
--error: #EF4444;
--warning: #F59E0B;
--shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
--shadow: 0 4px 16px rgba(0,0,0,0.6);
--shadow-lg: 0 8px 32px rgba(0,0,0,0.7);
--glass-bg: rgba(14,14,24,0.92);
--glass-border: rgba(255,255,255,0.05);
--glass-blur: blur(20px);
--checker-a: #1A1A30;
--checker-b: #22223A;
--canvas-bg: #000000;
--toast-bg: #161628;
--modal-bg: rgba(0,0,0,0.75);
--scrollbar-track: #10101C;
--scrollbar-thumb: #303056;
--scrollbar-thumb-hover: #484870;
--ruler-bg: #10101C;
--ruler-text: #606078;
--ruler-line: #303056;
--workspace-bg: #08080F;
--selection-bg: rgba(59,130,246,0.2);
}

[data-theme="light"] {
--bg-primary: #F8F8FC;
--bg-secondary: #FFFFFF;
--bg-tertiary: #F0F0F8;
--bg-surface: #FFFFFF;
--bg-hover: #E8E8F2;
--bg-active: #D8D8EA;
--text-primary: #1A1A2E;
--text-secondary: #555570;
--text-muted: #8888A0;
--border-primary: #D0D0E0;
--border-secondary: #C0C0D4;
--accent: #3B82F6;
--accent-hover: #2563EB;
--accent-glow: rgba(59, 130, 246, 0.08);
--accent-text: #FFFFFF;
--success: #16A34A;
--error: #DC2626;
--warning: #D97706;
--shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
--shadow: 0 4px 16px rgba(0,0,0,0.08);
--shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
--glass-bg: rgba(255,255,255,0.94);
--glass-border: rgba(0,0,0,0.06);
--glass-blur: blur(20px);
--checker-a: #E4E4F0;
--checker-b: #D4D4E8;
--canvas-bg: #FFFFFF;
--toast-bg: #FFFFFF;
--modal-bg: rgba(0,0,0,0.25);
--scrollbar-track: #F0F0F8;
--scrollbar-thumb: #C0C0D4;
--scrollbar-thumb-hover: #A0A0B8;
--ruler-bg: #F0F0F8;
--ruler-text: #8888A0;
--ruler-line: #D0D0E0;
--workspace-bg: #E4E4EE;
--selection-bg: rgba(59,130,246,0.15);
}

*, *::before, *::after {
margin: 0;
padding: 0;
box-sizing: border-box;
}

html, body {
width: 100%;
height: 100%;
overflow: hidden;
font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
background: var(--bg-primary);
color: var(--text-primary);
user-select: none;
-webkit-user-select: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

.hidden { display: none !important; }

#app { width: 100%; height: 100%; display: flex; flex-direction: column; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); border-radius: 3px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; transition: background 0.2s ease; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }
::-webkit-scrollbar-corner { background: var(--scrollbar-track); border-radius: 3px; }
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track); }

#welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 14px;
  padding: 28px 16px;
  overflow-y: auto;
  background: var(--workspace-bg);
}
.welcome-logo img { width: 90px; height: 90px; border-radius: 20px; object-fit: cover; box-shadow: var(--shadow-lg); }
#welcome-screen h1 { font-size: 26px; font-weight: 700; color: var(--text-primary); margin-top: 6px; letter-spacing: -0.5px; }
#welcome-screen > p { color: var(--text-secondary); font-size: 13px; }
.welcome-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; justify-content: center; }
.welcome-btn {
display: flex;
align-items: center;
gap: 7px;
padding: 9px 18px;
border: 1px solid var(--border-primary);
border-radius: 8px;
background: var(--bg-surface);
color: var(--text-primary);
font-size: 12px;
font-weight: 500;
cursor: pointer;
transition: all 0.15s ease;
}
.welcome-btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.welcome-btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.welcome-btn.primary:hover { background: var(--accent-hover); }
.welcome-presets { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; justify-content: center; align-items: center; }
.welcome-presets-label { font-size: 11px; color: var(--text-muted); }
.preset-quick-btn {
padding: 5px 10px;
border: 1px solid var(--border-secondary);
border-radius: 5px;
background: var(--bg-tertiary);
color: var(--text-secondary);
font-size: 10px;
cursor: pointer;
transition: all 0.12s ease;
}
.preset-quick-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--accent); }
.welcome-shortcuts { display: flex; gap: 10px; margin-top: 12px; color: var(--text-muted); font-size: 10px; }
.welcome-shortcuts span { padding: 2px 7px; background: var(--bg-tertiary); border-radius: 3px; border: 1px solid var(--border-secondary); }

/* Welcome feature grid */
.welcome-features { width: min(760px, 92vw); margin-top: 22px; }
.wf-head { font-size: 12px; font-weight: 600; color: var(--text-primary); margin-bottom: 10px; letter-spacing: 0.3px; }
.wf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.wf-card {
  text-align: left; background: var(--bg-surface); border: 1px solid var(--border-secondary);
  border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 6px;
  transition: border-color 0.12s ease, transform 0.12s ease;
}
.wf-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.wf-card-icon { color: var(--accent); display: flex; }
.wf-card-title { font-size: 11px; font-weight: 700; color: var(--text-primary); }
.wf-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.wf-list li { font-size: 9px; color: var(--text-secondary); padding-left: 8px; position: relative; }
.wf-list li::before { content: ''; position: absolute; left: 0; top: 5px; width: 3px; height: 3px; border-radius: 50%; background: var(--accent); }
.wf-list li.wf-hidden { opacity: 0.4; text-decoration: line-through; }
#btn-welcome-features { margin: 14px auto 0; }

/* Enriched features panel */
.feat-summary { font-size: 10px; color: var(--text-muted); margin-bottom: 10px; line-height: 1.4; }
.feat-search { margin-bottom: 8px; }
.feat-actions { margin-bottom: 10px; }
.feat-actions .acct-btn { width: 100%; }
.feat-item.feat-hidden { opacity: 0.4; }
.feat-item.feat-hidden .feat-name::after { content: ' (hidden)'; color: var(--text-muted); font-size: 8px; }

#workspace { display: flex; flex-direction: column; height: 100%; overflow: hidden; }

header#top-bar {
display: flex;
align-items: center;
justify-content: space-between;
height: 38px;
padding: 0 6px;
background: var(--glass-bg);
backdrop-filter: var(--glass-blur);
-webkit-backdrop-filter: var(--glass-blur);
border-bottom: 1px solid var(--glass-border);
z-index: 100;
flex-shrink: 0;
}
.top-left, .top-center, .top-right { display: flex; align-items: center; gap: 2px; }
.top-center { flex: 1; justify-content: center; min-width: 0; }
.app-brand { font-size: 11px; font-weight: 600; color: var(--accent); letter-spacing: 0.5px; white-space: nowrap; }
.separator { width: 1px; height: 14px; background: var(--border-secondary); margin: 0 2px; opacity: 0.5; }
#doc-title {
font-size: 11px;
color: var(--text-primary);
padding: 2px 5px;
border-radius: 3px;
outline: none;
max-width: 160px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
border: 1px solid transparent;
transition: border-color 0.12s ease, background 0.12s ease;
}
#doc-title:focus { border-color: var(--accent); background: var(--bg-hover); }
.dim-text { font-size: 9px; color: var(--text-muted); margin-left: 3px; white-space: nowrap; }
.zoom-text { font-size: 10px; color: var(--text-secondary); min-width: 36px; text-align: center; cursor: pointer; font-variant-numeric: tabular-nums; }
.icon-btn {
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
border: none;
background: transparent;
color: var(--text-secondary);
border-radius: 5px;
cursor: pointer;
transition: all 0.12s ease;
flex-shrink: 0;
position: relative;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn:active { background: var(--bg-active); }
.icon-btn:disabled { opacity: 0.2; cursor: default; pointer-events: none; }
.icon-btn.active-tool { background: var(--accent); color: var(--accent-text); }
.mobile-only { display: none; }

.preset-dropdown {
position: relative;
}
.preset-dropdown select {
padding: 2px 5px;
border: 1px solid var(--border-secondary);
border-radius: 3px;
background: var(--bg-tertiary);
color: var(--text-primary);
font-size: 10px;
outline: none;
cursor: pointer;
}

#main-layout { display: flex; flex: 1; overflow: hidden; position: relative; }

#sidebar {
display: flex;
flex-direction: column;
width: 46px;
background: var(--glass-bg);
backdrop-filter: var(--glass-blur);
-webkit-backdrop-filter: var(--glass-blur);
border-right: 1px solid var(--glass-border);
overflow-y: auto;
overflow-x: hidden;
flex-shrink: 0;
z-index: 50;
}
.tool-group { display: flex; flex-direction: column; align-items: center; padding: 3px 0; gap: 1px; }
.tool-separator { width: 20px; height: 1px; background: var(--border-secondary); margin: 2px 0; opacity: 0.4; }
.tool-btn {
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
border: none;
background: transparent;
color: var(--text-secondary);
border-radius: 6px;
cursor: pointer;
transition: all 0.12s ease;
position: relative;
}
.tool-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.tool-btn.active { background: var(--accent); color: var(--accent-text); box-shadow: 0 0 0 1px var(--accent); }
.tool-btn.active:hover { background: var(--accent-hover); }
.color-group { margin-top: auto; padding-bottom: 4px; }
.color-controls { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0 3px; }
.color-pair { position: relative; width: 34px; height: 34px; }
.color-chip {
width: 24px;
height: 24px;
border-radius: 5px;
border: 2px solid var(--border-primary);
cursor: pointer;
position: absolute;
transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.color-chip:hover { transform: scale(1.08); box-shadow: var(--shadow-sm); }
.color-chip.primary { top: 0; left: 0; z-index: 2; }
.color-chip.secondary { bottom: 0; right: 0; z-index: 1; }
.swap-btn {
position: absolute;
top: -3px;
right: -3px;
width: 14px;
height: 14px;
border: none;
background: var(--bg-surface);
color: var(--text-secondary);
border-radius: 50%;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
z-index: 3;
border: 1px solid var(--border-secondary);
transition: all 0.12s ease;
}
.swap-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.palette-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; padding: 2px; }
.palette-swatch {
width: 100%;
aspect-ratio: 1;
border-radius: 2px;
border: 1px solid rgba(0,0,0,0.12);
cursor: pointer;
transition: transform 0.1s ease;
}
.palette-swatch:hover { transform: scale(1.2); z-index: 1; }
.small-btn {
font-size: 8px;
padding: 2px 4px;
border: 1px solid var(--border-secondary);
border-radius: 3px;
background: transparent;
color: var(--text-secondary);
cursor: pointer;
width: 100%;
transition: all 0.12s ease;
display: flex;
align-items: center;
justify-content: center;
gap: 3px;
}
.small-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

#canvas-area { flex: 1; position: relative; overflow: hidden; background: var(--workspace-bg); }
#canvas-wrapper { width: 100%; height: 100%; overflow: hidden; position: relative; cursor: crosshair; touch-action: none; -ms-touch-action: none; overscroll-behavior: none; }
#canvas-container { position: absolute; transform-origin: 0 0; }
#checkerboard {
position: absolute;
top: 0; left: 0;
width: 100%; height: 100%;
background-image: linear-gradient(45deg, var(--checker-a) 25%, transparent 25%),
linear-gradient(-45deg, var(--checker-a) 25%, transparent 25%),
linear-gradient(45deg, transparent 75%, var(--checker-a) 75%),
linear-gradient(-45deg, transparent 75%, var(--checker-a) 75%);
background-size: 16px 16px;
background-position: 0 0, 0 8px, 8px -8px, -8px 0;
background-color: var(--checker-b);
pointer-events: none;
}
#main-canvas { position: absolute; top: 0; left: 0; image-rendering: auto; }
#overlay-canvas { position: absolute; top: 0; left: 0; pointer-events: none; }
#grid-canvas { position: absolute; top: 0; left: 0; pointer-events: none; }
#text-input {
position: absolute;
background: rgba(255,255,255,0.05);
border: 2px dashed var(--accent);
color: var(--text-primary);
font-size: 16px;
padding: 4px;
outline: none;
resize: both;
min-width: 60px;
min-height: 28px;
z-index: 10;
border-radius: 2px;
}
#selection-marquee {
position: absolute;
pointer-events: none;
border: 1px dashed var(--accent);
background: var(--selection-bg);
}
#brush-cursor {
  position: fixed;
  pointer-events: none;
  border: 1.5px solid var(--accent-text);
  border-radius: 50%;
  z-index: 999;
  opacity: 0.9;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1.5px var(--accent), 0 0 4px rgba(0,0,0,0.4);
  background: rgba(59,130,246,0.15);
}

#zoom-slider-container {
position: absolute;
bottom: 6px;
right: 6px;
background: var(--glass-bg);
backdrop-filter: var(--glass-blur);
border-radius: 6px;
padding: 4px 6px;
border: 1px solid var(--glass-border);
z-index: 40;
display: flex;
align-items: center;
gap: 3px;
}
#zoom-slider {
width: 80px;
height: 2px;
-webkit-appearance: none;
appearance: none;
background: var(--border-secondary);
border-radius: 1px;
outline: none;
}
#zoom-slider::-webkit-slider-thumb {
-webkit-appearance: none;
width: 10px;
height: 10px;
background: var(--accent);
border-radius: 50%;
cursor: pointer;
border: 1.5px solid var(--accent-text);
box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.ruler-container {
position: absolute;
background: var(--ruler-bg);
z-index: 30;
overflow: hidden;
}
.ruler-h { top: 0; left: 0; right: 0; height: 20px; border-bottom: 1px solid var(--ruler-line); }
.ruler-v { top: 0; left: 0; bottom: 0; width: 20px; border-right: 1px solid var(--ruler-line); }
.ruler-canvas { width: 100%; height: 100%; }

#options-panel {
width: 180px;
background: var(--glass-bg);
backdrop-filter: var(--glass-blur);
-webkit-backdrop-filter: var(--glass-blur);
border-left: 1px solid var(--glass-border);
overflow-y: auto;
padding: 8px;
flex-shrink: 0;
z-index: 50;
}
#options-content { display: flex; flex-direction: column; gap: 6px; }
.opt-row { display: flex; flex-direction: column; gap: 2px; }
.opt-label { font-size: 9px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.opt-input {
width: 100%;
padding: 4px 6px;
border: 1px solid var(--border-secondary);
border-radius: 4px;
background: var(--bg-tertiary);
color: var(--text-primary);
font-size: 11px;
outline: none;
transition: border-color 0.12s ease;
}
.opt-input:focus { border-color: var(--accent); }
.opt-range {
width: 100%;
height: 2px;
-webkit-appearance: none;
appearance: none;
background: var(--border-secondary);
border-radius: 1px;
outline: none;
margin: 3px 0;
}
.opt-range::-webkit-slider-thumb {
-webkit-appearance: none;
width: 10px;
height: 10px;
background: var(--accent);
border-radius: 50%;
cursor: pointer;
border: 1.5px solid var(--accent-text);
}
.opt-select {
width: 100%;
padding: 4px 6px;
border: 1px solid var(--border-secondary);
border-radius: 4px;
background: var(--bg-tertiary);
color: var(--text-primary);
font-size: 11px;
outline: none;
cursor: pointer;
}
.opt-btn {
padding: 4px 8px;
border: 1px solid var(--border-secondary);
border-radius: 4px;
background: var(--bg-tertiary);
color: var(--text-primary);
font-size: 10px;
cursor: pointer;
transition: all 0.12s ease;
}
.opt-btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.opt-btn.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.opt-btn.danger { border-color: var(--error); color: var(--error); }
.opt-btn.danger:hover { background: var(--error); color: white; }
.opt-row-inline { display: flex; align-items: center; gap: 5px; }
.opt-row-inline .opt-range { flex: 1; }
.opt-row-inline span { font-size: 9px; color: var(--text-muted); min-width: 24px; text-align: right; }

#layers-panel {
width: 200px;
background: var(--glass-bg);
backdrop-filter: var(--glass-blur);
-webkit-backdrop-filter: var(--glass-blur);
border-left: 1px solid var(--glass-border);
display: flex;
flex-direction: column;
flex-shrink: 0;
z-index: 50;
transition: width 0.15s ease;
}
#layers-panel.collapsed { width: 0; overflow: hidden; border: none; }
.panel-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 5px 8px;
font-size: 10px;
font-weight: 600;
color: var(--text-secondary);
border-bottom: 1px solid var(--border-secondary);
flex-shrink: 0;
}
.panel-actions { display: flex; gap: 1px; }
.small-icon-btn {
width: 20px;
height: 20px;
border: none;
background: transparent;
color: var(--text-secondary);
border-radius: 3px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.12s ease;
}
.small-icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
#layers-list { flex: 1; overflow-y: auto; padding: 2px; }
.layer-item {
display: flex;
align-items: center;
gap: 4px;
padding: 4px 5px;
border-radius: 4px;
cursor: pointer;
transition: all 0.12s ease;
border: 1px solid transparent;
}
.layer-item:hover { background: var(--bg-hover); }
.layer-item.active { background: var(--bg-active); border-color: var(--accent); }
.layer-item.locked { opacity: 0.5; }
.layer-visibility {
width: 16px;
height: 16px;
border: none;
background: transparent;
color: var(--text-secondary);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
border-radius: 2px;
flex-shrink: 0;
transition: all 0.12s ease;
}
.layer-visibility:hover { background: var(--bg-hover); }
.layer-visibility.hidden-layer { opacity: 0.2; }
.layer-thumb {
width: 26px;
height: 26px;
border-radius: 3px;
border: 1px solid var(--border-secondary);
background-image: linear-gradient(45deg, var(--checker-a) 25%, transparent 25%),
linear-gradient(-45deg, var(--checker-a) 25%, transparent 25%),
linear-gradient(45deg, transparent 75%, var(--checker-a) 75%),
linear-gradient(-45deg, transparent 75%, var(--checker-a) 75%);
background-size: 6px 6px;
background-position: 0 0, 0 3px, 3px -3px, -3px 0;
background-color: var(--checker-b);
flex-shrink: 0;
overflow: hidden;
}
.layer-thumb canvas { width: 100%; height: 100%; object-fit: contain; }
.layer-info { flex: 1; min-width: 0; }
.layer-name { font-size: 9px; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-meta { font-size: 8px; color: var(--text-muted); }
.layer-lock {
width: 12px; height: 12px; border: none; background: transparent;
color: var(--text-muted); cursor: pointer; display: flex;
align-items: center; justify-content: center; border-radius: 2px;
flex-shrink: 0; opacity: 0; transition: opacity 0.12s ease;
}
.layer-item:hover .layer-lock { opacity: 1; }
.layer-lock:hover { color: var(--warning); }
.layer-lock.locked { opacity: 1; color: var(--warning); }
.layer-delete {
width: 16px; height: 16px; border: none; background: transparent;
color: var(--text-muted); cursor: pointer; display: flex;
align-items: center; justify-content: center; border-radius: 2px;
flex-shrink: 0; opacity: 0; transition: opacity 0.12s ease;
}
.layer-item:hover .layer-delete { opacity: 1; }
.layer-delete:hover { background: var(--bg-hover); color: var(--error); }
.layer-opacity-row { display: flex; align-items: center; gap: 3px; padding: 2px 5px; }
.layer-opacity-row label { font-size: 8px; color: var(--text-muted); }
.layer-opacity-row input[type="range"] { flex: 1; height: 2px; }
.layer-opacity-row span { font-size: 8px; color: var(--text-muted); min-width: 22px; text-align: right; }
.layer-blend { padding: 2px 5px; }
.layer-blend select { width: 100%; padding: 2px 3px; font-size: 8px; border: 1px solid var(--border-secondary); border-radius: 2px; background: var(--bg-tertiary); color: var(--text-primary); outline: none; }

footer#status-bar {
display: flex;
align-items: center;
height: 20px;
padding: 0 8px;
background: var(--glass-bg);
backdrop-filter: var(--glass-blur);
border-top: 1px solid var(--glass-border);
font-size: 9px;
color: var(--text-muted);
gap: 2px;
flex-shrink: 0;
z-index: 100;
font-variant-numeric: tabular-nums;
}
.status-sep { width: 1px; height: 8px; background: var(--border-secondary); opacity: 0.4; }
.status-spacer { flex: 1; }
#status-color-preview {
width: 8px; height: 8px; border-radius: 2px;
border: 1px solid var(--border-secondary);
display: inline-block;
}

#mobile-overlay {
position: fixed;
inset: 0;
background: rgba(0,0,0,0.5);
z-index: 55;
display: none;
}
#mobile-overlay:not(.hidden) { display: block; }

#context-menu {
position: fixed;
background: var(--bg-surface);
border: 1px solid var(--border-secondary);
border-radius: 6px;
padding: 2px;
min-width: 160px;
z-index: 1000;
box-shadow: var(--shadow-lg);
}
#context-menu button {
display: flex;
align-items: center;
gap: 5px;
width: 100%;
padding: 5px 8px;
border: none;
background: transparent;
color: var(--text-primary);
font-size: 10px;
text-align: left;
cursor: pointer;
border-radius: 3px;
transition: background 0.1s ease;
}
#context-menu button:hover { background: var(--bg-hover); }
#context-menu button .ctx-shortcut { margin-left: auto; color: var(--text-muted); font-size: 9px; }
.ctx-sep { height: 1px; background: var(--border-secondary); margin: 2px 5px; opacity: 0.4; }

#toast-container {
position: fixed;
top: 48px;
right: 10px;
z-index: 2000;
display: flex;
flex-direction: column;
gap: 4px;
pointer-events: none;
}
.toast {
padding: 6px 12px;
border-radius: 6px;
background: var(--toast-bg);
border: 1px solid var(--border-secondary);
color: var(--text-primary);
font-size: 11px;
box-shadow: var(--shadow);
display: flex;
align-items: center;
gap: 6px;
max-width: 280px;
pointer-events: auto;
opacity: 0;
transform: translateX(20px);
transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.visible { opacity: 1; transform: translateX(0); }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--error); }
.toast.info { border-color: var(--accent); }
.toast-icon { flex-shrink: 0; }
.toast-msg { flex: 1; }

.modal-backdrop { position: fixed; inset: 0; background: var(--modal-bg); z-index: 500; }
.modal-content {
position: fixed;
top: 50%; left: 50%;
transform: translate(-50%, -50%);
background: var(--bg-surface);
border: 1px solid var(--border-secondary);
border-radius: 10px;
padding: 16px;
min-width: 280px;
max-width: 400px;
z-index: 501;
box-shadow: var(--shadow-lg);
max-height: 80vh;
overflow-y: auto;
}
.modal-content h3 { font-size: 14px; margin-bottom: 12px; color: var(--text-primary); font-weight: 600; }
.form-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; gap: 8px; }
.form-row label { font-size: 11px; color: var(--text-secondary); white-space: nowrap; }
.form-row input[type="number"], .form-row select {
width: 100px; padding: 4px 6px;
border: 1px solid var(--border-secondary);
border-radius: 4px;
background: var(--bg-tertiary);
color: var(--text-primary);
font-size: 11px;
outline: none;
}
.form-row input:focus, .form-row select:focus { border-color: var(--accent); }
.form-row input[type="range"] { flex: 1; }
.modal-btns { display: flex; justify-content: flex-end; gap: 5px; margin-top: 12px; }
.modal-btn {
padding: 6px 14px;
border: 1px solid var(--border-secondary);
border-radius: 5px;
background: var(--bg-tertiary);
color: var(--text-primary);
font-size: 11px;
cursor: pointer;
transition: all 0.12s ease;
}
.modal-btn:hover { background: var(--bg-hover); }
.modal-btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.modal-btn.primary:hover { background: var(--accent-hover); }
.about-box { text-align: center; min-width: 240px; }
.about-logo { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; margin-bottom: 8px; }
.about-sub { color: var(--text-secondary); font-size: 11px; margin: 4px 0; }
.about-copy { color: var(--text-muted); font-size: 9px; margin: 2px 0; }
.about-license { color: var(--text-muted); font-size: 9px; margin: 4px 0 12px; }

#more-menu { position: fixed; top: 38px; right: 6px; z-index: 200; }
.more-menu-content {
background: var(--bg-surface);
border: 1px solid var(--border-secondary);
border-radius: 6px;
padding: 2px;
min-width: 180px;
box-shadow: var(--shadow-lg);
max-height: 70vh;
overflow-y: auto;
}
.more-menu-content button {
display: flex;
align-items: center;
gap: 5px;
width: 100%;
padding: 5px 8px;
border: none;
background: transparent;
color: var(--text-primary);
font-size: 10px;
text-align: left;
cursor: pointer;
border-radius: 3px;
transition: background 0.1s ease;
}
.more-menu-content button:hover { background: var(--bg-hover); }
.more-menu-content .ctx-sep { margin: 2px 5px; }

#filter-modal .form-row { flex-direction: column; align-items: stretch; gap: 5px; }
#filter-modal .form-row label { text-align: left; }
#filter-amount { width: 100%; }
#filter-value { font-size: 10px; color: var(--text-secondary); text-align: center; }

#shortcuts-overlay {
position: fixed; inset: 0; background: var(--modal-bg);
z-index: 600; display: flex; align-items: center; justify-content: center;
}
#shortcuts-overlay .shortcuts-box {
background: var(--bg-surface); border: 1px solid var(--border-secondary);
border-radius: 10px; padding: 16px; max-width: 480px; width: 90%;
max-height: 80vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
#shortcuts-overlay h3 { margin-bottom: 10px; font-size: 14px; }
.shortcut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.shortcut-item { display: flex; align-items: center; justify-content: space-between; padding: 3px 0; font-size: 10px; }
.shortcut-item kbd {
padding: 1px 4px; background: var(--bg-tertiary); border: 1px solid var(--border-secondary);
border-radius: 2px; font-size: 9px; font-family: inherit; color: var(--text-secondary);
}

#export-modal .export-format-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; margin-bottom: 8px; }
#export-modal .format-btn {
padding: 6px; border: 1px solid var(--border-secondary); border-radius: 5px;
background: var(--bg-tertiary); color: var(--text-primary); font-size: 10px;
cursor: pointer; text-align: center; transition: all 0.12s ease;
}
#export-modal .format-btn.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
#export-modal .format-btn:hover:not(.active) { background: var(--bg-hover); }
#export-modal .export-size-row { display: flex; gap: 3px; margin-bottom: 8px; }
#export-modal .size-btn {
flex: 1; padding: 5px; border: 1px solid var(--border-secondary); border-radius: 4px;
background: var(--bg-tertiary); color: var(--text-primary); font-size: 9px;
cursor: pointer; text-align: center; transition: all 0.12s ease;
}
#export-modal .size-btn.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

#color-wheel-container {
position: fixed;
z-index: 300;
background: var(--bg-surface);
border: 1px solid var(--border-secondary);
border-radius: 8px;
padding: 8px;
box-shadow: var(--shadow-lg);
}
#color-wheel-canvas { border-radius: 50%; cursor: crosshair; }
#color-hex-input {
width: 100%;
padding: 3px 5px;
border: 1px solid var(--border-secondary);
border-radius: 3px;
background: var(--bg-tertiary);
color: var(--text-primary);
font-size: 10px;
outline: none;
margin-top: 4px;
text-align: center;
}

.drop-zone-overlay {
position: fixed; inset: 0; z-index: 900;
background: var(--accent-glow);
border: 3px dashed var(--accent);
display: flex; align-items: center; justify-content: center;
font-size: 16px; font-weight: 600; color: var(--accent);
pointer-events: none;
}

@media (max-width: 768px) {
.mobile-only { display: flex; }
#sidebar {
position: fixed;
left: -46px;
top: 38px;
bottom: 20px;
z-index: 56;
transition: left 0.15s ease;
box-shadow: none;
}
#sidebar.mobile-open {
left: 0;
box-shadow: var(--shadow-lg);
}
#options-panel {
position: fixed;
left: 0;
top: 38px;
bottom: 20px;
z-index: 54;
box-shadow: var(--shadow-lg);
width: 160px;
display: none;
}
#layers-panel {
position: fixed;
right: -200px;
top: 38px;
bottom: 20px;
z-index: 54;
box-shadow: var(--shadow-lg);
transition: right 0.15s ease;
}
#layers-panel.mobile-open {
right: 0;
}
#layers-panel.collapsed { width: 0; }
.top-center { display: none; }
.app-brand { display: none; }
.icon-btn { width: 26px; height: 26px; }
#zoom-slider-container { bottom: 3px; right: 3px; }
#zoom-slider { width: 55px; }
.welcome-actions { flex-direction: column; width: 80%; }
.welcome-btn { width: 100%; justify-content: center; }
.ruler-h, .ruler-v { display: none !important; }
#ruler-corner { display: none !important; }
}
@media (max-width: 480px) {
#top-bar { height: 34px; }
#sidebar { width: 40px; left: -40px; }
.tool-btn { width: 30px; height: 30px; }
header#top-bar { padding: 0 3px; }
.separator { display: none; }
#layers-panel { width: 180px; right: -180px; }
.welcome-presets { flex-direction: column; align-items: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* Manual "silent / no animations" mode */
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after {
  transition: none !important;
  animation: none !important;
}

/* ---------- Side panels (Features / Account) ---------- */
#side-panel-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 150; display: none;
}
#side-panel-overlay:not(.hidden) { display: block; }

.side-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 320px; max-width: 92vw;
  background: var(--bg-secondary); border-left: 1px solid var(--border-secondary);
  z-index: 160; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); transform: translateX(100%);
  transition: transform 0.18s ease;
}
.side-panel.open { transform: translateX(0); }
.side-panel.hidden { display: flex !important; }
.side-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; font-size: 12px; font-weight: 600; color: var(--text-primary);
  border-bottom: 1px solid var(--border-secondary); flex-shrink: 0;
}
.side-panel-close {
  width: 26px; height: 26px; border: none; background: transparent; color: var(--text-secondary);
  border-radius: 5px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.side-panel-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.side-panel-body { flex: 1; overflow-y: auto; padding: 12px; }

/* ---------- Features panel ---------- */
.feat-group { margin-bottom: 14px; }
.feat-group-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--accent); margin-bottom: 6px;
}
.feat-item { display: flex; gap: 8px; align-items: flex-start; padding: 5px 6px; border-radius: 6px; }
.feat-item:hover { background: var(--bg-hover); }
.feat-item svg { color: var(--success); flex-shrink: 0; margin-top: 1px; }
.feat-text { display: flex; flex-direction: column; }
.feat-name { font-size: 11px; color: var(--text-primary); font-weight: 500; }
.feat-desc { font-size: 10px; color: var(--text-muted); }

/* ---------- Account panel ---------- */
.acct-section { margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border-secondary); }
.acct-section:last-child { border-bottom: none; }
.acct-section-title { font-size: 11px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.acct-hint { font-size: 9px; color: var(--text-muted); margin-bottom: 8px; line-height: 1.4; }
.acct-profile { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.acct-avatar {
  width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 18px; flex-shrink: 0;
}
.acct-input {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border-secondary); border-radius: 6px;
  background: var(--bg-tertiary); color: var(--text-primary); font-size: 11px; outline: none;
}
.acct-input:focus { border-color: var(--accent); }
.acct-swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.acct-swatch { width: 22px; height: 22px; border-radius: 6px; border: 2px solid transparent; cursor: pointer; }
.acct-swatch.active { border-color: var(--text-primary); }
.acct-row { display: flex; align-items: center; justify-content: space-between; padding: 5px 0; }
.acct-row span { font-size: 11px; color: var(--text-secondary); }
.acct-seg { display: flex; border: 1px solid var(--border-secondary); border-radius: 6px; overflow: hidden; }
.acct-seg-btn {
  padding: 4px 12px; border: none; background: var(--bg-tertiary); color: var(--text-secondary);
  font-size: 10px; cursor: pointer;
}
.acct-seg-btn.active { background: var(--accent); color: var(--accent-text); }
.acct-toggle {
  width: 38px; height: 20px; border-radius: 12px; background: var(--border-secondary); border: none;
  position: relative; cursor: pointer; transition: background 0.15s ease; flex-shrink: 0;
}
.acct-toggle.on { background: var(--accent); }
.acct-knob {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform 0.15s ease;
}
.acct-toggle.on .acct-knob { transform: translateX(18px); }
.acct-tools { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.acct-check { display: flex; align-items: center; gap: 7px; font-size: 10px; color: var(--text-secondary); cursor: pointer; padding: 2px 0; }
.acct-check input { accent-color: var(--accent); }
.acct-field { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }
.acct-field label { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.acct-actions { display: flex; gap: 6px; margin-top: 8px; }
.acct-btn {
  flex: 1; padding: 7px 10px; border: 1px solid var(--border-secondary); border-radius: 6px;
  background: var(--bg-tertiary); color: var(--text-primary); font-size: 10px; cursor: pointer;
  transition: all 0.12s ease;
}
.acct-btn:hover { background: var(--bg-hover); }
.acct-btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.acct-btn.primary:hover { background: var(--accent-hover); }
.acct-btn.danger { border-color: var(--error); color: var(--error); width: 100%; }
.acct-btn.danger:hover { background: var(--error); color: #fff; }
.acct-status { margin-top: 8px; font-size: 10px; color: var(--text-secondary); padding: 6px 8px; background: var(--bg-tertiary); border-radius: 6px; }
.acct-status.success { color: var(--success); }
.acct-status.error { color: var(--error); }
.acct-status.info { color: var(--accent); }

/* ---------- Mobile sidebar / panel fixes ---------- */
@media (max-width: 768px) {
  .top-right { overflow-x: auto; scrollbar-width: none; }
  .top-right::-webkit-scrollbar { display: none; }
  #options-panel.mobile-open {
    display: block;
    left: 0; top: 38px; bottom: 20px; right: auto; width: 170px; z-index: 54;
    box-shadow: var(--shadow-lg);
  }
  #layers-panel.mobile-open { right: 0; }
}

