:root {
  color-scheme: dark;
  --bg: #111421;
  --bg-2: #171b2b;
  --bg-3: #20263a;
  --panel: rgba(22, 27, 42, .94);
  --panel-2: rgba(28, 34, 52, .94);
  --text: #f3f6ff;
  --muted: #9aa7c1;
  --line: rgba(255, 255, 255, .11);
  --accent: #46b3ff;
  --accent-2: #00d084;
  --danger: #ff5d6c;
  --shadow: 0 24px 70px rgba(0, 0, 0, .38);
  --radius: 18px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 0%, rgba(70, 179, 255, .13), transparent 32rem),
    radial-gradient(circle at 80% 10%, rgba(0, 208, 132, .09), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.noscript {
  padding: 1rem;
  background: #49151d;
  color: #fff;
}

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  min-width: 320px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 15, 25, .86);
  backdrop-filter: blur(16px);
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 210px;
  gap: .65rem;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #07101b;
  font-weight: 900;
  box-shadow: 0 14px 30px rgba(70, 179, 255, .22);
}
.brand strong, .brand span { display: block; }
.brand strong { font-size: 1.02rem; letter-spacing: .01em; }
.brand div span { color: var(--muted); font-size: .75rem; margin-top: .07rem; }

.menu-strip {
  display: flex;
  flex: 1;
  align-items: center;
  gap: .45rem;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: .1rem;
}

.btn, .mini, .tool {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .055);
  color: var(--text);
  border-radius: 12px;
  min-height: 36px;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.btn {
  padding: .45rem .72rem;
  white-space: nowrap;
}
.btn:hover, .mini:hover, .tool:hover,
.btn:focus-visible, .mini:focus-visible, .tool:focus-visible {
  border-color: rgba(70, 179, 255, .65);
  background: rgba(70, 179, 255, .12);
  outline: none;
}
.btn:active, .mini:active, .tool:active { transform: translateY(1px); }
.btn-primary {
  border-color: rgba(70, 179, 255, .5);
  background: linear-gradient(135deg, rgba(70, 179, 255, .95), rgba(0, 208, 132, .85));
  color: #06111c;
  font-weight: 800;
}
.export-group { display: inline-flex; align-items: center; gap: .45rem; margin-left: auto; }
select, input[type="text"], input[type="number"] {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(7, 10, 17, .6);
  color: var(--text);
  min-height: 36px;
  padding: .35rem .55rem;
}
input[type="color"] {
  width: 42px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  padding: 2px;
}
input[type="range"] { accent-color: var(--accent); min-width: 84px; }
.check-option { gap: .35rem !important; }
.check-option input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.fill-actions { align-items: center; gap: .35rem; }

.main-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 330px;
}

.toolbox {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  padding: .85rem .6rem;
  border-right: 1px solid var(--line);
  background: rgba(16, 20, 32, .78);
  overflow-y: auto;
}
.tool {
  display: grid;
  place-items: center;
  gap: .12rem;
  width: 100%;
  padding: .5rem .25rem;
  border-radius: 16px;
  min-height: 56px;
}
.tool span { font-size: 1.2rem; line-height: 1; font-weight: 800; }
.tool small { color: var(--muted); font-size: .68rem; }
.tool.active {
  background: rgba(70, 179, 255, .16);
  border-color: rgba(70, 179, 255, .72);
  box-shadow: inset 0 0 0 1px rgba(70, 179, 255, .2);
}
.tool.active small { color: #dff4ff; }

.workspace-shell {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
}
.contextbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .65rem;
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--line);
  background: rgba(18, 23, 36, .82);
  overflow: hidden;
}
.contextbar .context-item { display: none; }
.contextbar .context-item.is-visible { display: inline-flex; }
.contextbar label {
  align-items: center;
  gap: .4rem;
  color: var(--muted);
  font-size: .79rem;
  white-space: nowrap;
}
.contextbar output, .zoom-label {
  min-width: 42px;
  color: var(--text);
  font-family: var(--mono);
  font-size: .78rem;
}
.text-option input { width: 210px; }

.workspace {
  position: relative;
  min-height: 0;
  overflow: auto;
  background:
    radial-gradient(circle at 50% 32%, rgba(70, 179, 255, .10), transparent 34rem),
    #252b3a;
}
.stage {
  position: relative;
  margin: 80px auto;
  width: 1200px;
  height: 800px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(255,255,255,.22), 0 0 0 10px rgba(6,10,18,.34);
  transform-origin: top left;
  background-color: #e8edf5;
  background-image:
    linear-gradient(45deg, rgba(20, 28, 42, .16) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(20, 28, 42, .16) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(20, 28, 42, .16) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(20, 28, 42, .16) 75%);
  background-size: 32px 32px;
  background-position: 0 0, 0 16px, 16px -16px, -16px 0;
}
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}
#mainCanvas {
  background: transparent;
}
#overlayCanvas { pointer-events: none; }
.drop-hint {
  position: fixed;
  left: 50%;
  bottom: 2.2rem;
  transform: translateX(-50%) translateY(20px);
  padding: .7rem 1rem;
  border-radius: 999px;
  background: rgba(70, 179, 255, .13);
  border: 1px solid rgba(70, 179, 255, .34);
  color: #dff4ff;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  box-shadow: var(--shadow);
}
.workspace.dragging .drop-hint {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 36px;
  padding: .4rem .75rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: .76rem;
  background: rgba(13, 17, 28, .92);
}

.panels {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: .8rem;
  padding: .85rem;
  border-left: 1px solid var(--line);
  background: rgba(15, 19, 31, .86);
  overflow-y: auto;
}
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 16px 45px rgba(0, 0, 0, .18);
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .75rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .035);
}
.panel h2 {
  margin: 0;
  font-size: .88rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #dce9ff;
}
.mini {
  min-width: 32px;
  min-height: 32px;
  padding: .25rem .45rem;
  font-weight: 800;
}
.mini.danger { color: #ffd7dc; border-color: rgba(255, 93, 108, .3); }
.mini.danger:hover { background: rgba(255, 93, 108, .12); border-color: rgba(255, 93, 108, .7); }

.properties-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: .65rem;
  padding: .75rem;
}
.properties-grid label {
  display: grid;
  gap: .28rem;
  color: var(--muted);
  font-size: .78rem;
}
.properties-grid input[type="text"], .properties-grid input[type="number"], .properties-grid select { width: 100%; }
.properties-grid output { font-family: var(--mono); color: var(--text); }
.transform-grid, .mask-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .45rem;
  padding: .55rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.035);
}
.transform-grid label, .mask-grid label { margin: 0; }
.transform-grid .check-option { grid-column: 1 / -1; display: flex; align-items: center; color: var(--muted); }
.mask-grid span { grid-column: 1 / -1; color: var(--muted); font-family: var(--mono); font-size: .72rem; }
.mask-grid .mini, .transform-grid .mini { width: 100%; }

.layers-panel { flex: 1 1 320px; min-height: 220px; display: flex; flex-direction: column; }
.layer-actions { display: inline-flex; gap: .35rem; }
.layer-list {
  min-height: 0;
  overflow-y: auto;
  padding: .55rem;
}
.layer-item {
  display: grid;
  grid-template-columns: 34px 54px minmax(0, 1fr) 32px 32px;
  align-items: center;
  gap: .5rem;
  padding: .5rem;
  border: 1px solid transparent;
  border-radius: 15px;
  background: rgba(255, 255, 255, .035);
  margin-bottom: .45rem;
}
.layer-item.active {
  border-color: rgba(70, 179, 255, .62);
  background: rgba(70, 179, 255, .12);
}
.layer-thumb {
  width: 54px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background:
    linear-gradient(45deg, rgba(255,255,255,.10) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,.10) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,.10) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.10) 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  overflow: hidden;
}
.layer-item canvas { width: 100%; height: 100%; display: block; }
.layer-title { min-width: 0; }
.layer-title strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .85rem;
}
.layer-title span {
  display: block;
  color: var(--muted);
  font-family: var(--mono);
  font-size: .68rem;
  margin-top: .12rem;
}
.icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, .045);
  color: var(--text);
}
.icon-btn[aria-pressed="false"] { opacity: .48; }
.help-panel {
  padding: .75rem;
  color: var(--muted);
  font-size: .82rem;
}
.help-panel summary { color: var(--text); cursor: pointer; font-weight: 700; }
kbd {
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: .05rem .28rem;
  background: rgba(255,255,255,.06);
  color: #fff;
  font-family: var(--mono);
  font-size: .72rem;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 100;
  max-width: min(420px, calc(100vw - 2rem));
  padding: .8rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(70, 179, 255, .3);
  background: rgba(18, 23, 36, .96);
  color: var(--text);
  box-shadow: var(--shadow);
  transform: translateY(12px);
  opacity: 0;
  transition: transform .18s ease, opacity .18s ease;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-color: rgba(255, 93, 108, .55); }

@media (max-width: 1100px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; }
  .main-grid { grid-template-columns: 64px minmax(0, 1fr); grid-template-rows: minmax(620px, 75vh) auto; }
  .panels { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); max-height: none; }
}

@media (max-width: 760px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .brand { min-width: 0; }
  .main-grid { grid-template-columns: 1fr; grid-template-rows: auto minmax(560px, 72vh) auto; }
  .toolbox { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .tool { min-width: 62px; }
  .text-option input { width: 170px; }
  .contextbar { max-height: 132px; overflow-y: auto; }
  .statusbar { flex-direction: column; align-items: flex-start; gap: .2rem; }
}

/* v1.0.005 refinements */
.panels > .panel { flex: 0 0 auto; }
.layers-panel { flex: 0 0 auto; max-height: none; }
.panels { overscroll-behavior: contain; padding-bottom: 1.25rem; }
.panel { overflow: visible; }
.panel-header { border-radius: var(--radius) var(--radius) 0 0; }
.properties-grid { overflow: visible; }
.workspace {
  background:
    radial-gradient(circle at 50% 32%, rgba(70, 179, 255, .08), transparent 34rem),
    #1e2432;
}
.stage {
  box-shadow: var(--shadow), 0 0 0 2px rgba(255,255,255,.34), 0 0 0 16px rgba(4,7,12,.42);
}
.transform-toggle[aria-pressed="true"] {
  border-color: rgba(0, 208, 132, .72);
  background: rgba(0, 208, 132, .15);
  color: #eafff6;
}
.layer-actions { flex-wrap: wrap; justify-content: flex-end; }
.layer-item {
  grid-template-columns: 30px 30px 30px 54px minmax(0, 1fr) 30px 30px;
  gap: .36rem;
}
.layer-item.selected:not(.active) {
  border-color: rgba(0, 208, 132, .45);
  background: rgba(0, 208, 132, .09);
}
.layer-item.locked .layer-title strong::after {
  content: "  🔒";
  font-size: .78em;
}
.select-btn[aria-pressed="true"], .lock-btn[aria-pressed="true"] {
  border-color: rgba(0, 208, 132, .62);
  background: rgba(0, 208, 132, .13);
}
.modal-backdrop[hidden] { display: none; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  background: rgba(3, 7, 14, .62);
  backdrop-filter: blur(5px);
  padding: 1rem;
}
.modal-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(22, 27, 42, .98);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-header, .modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .85rem;
  border-bottom: 1px solid var(--line);
}
.modal-actions { border-top: 1px solid var(--line); border-bottom: 0; justify-content: flex-end; }
.modal-header h2 { margin: 0; font-size: 1rem; }
.modal-body { display: grid; gap: .7rem; padding: .95rem; }
.radio-row { display: flex; align-items: center; gap: .55rem; color: var(--text); }
.radio-row input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; }
.radio-row input[type="color"] { margin-left: auto; }
@media (max-width: 1100px) {
  .layer-item { grid-template-columns: 30px 30px 30px 54px minmax(0, 1fr); }
  .layer-item .reorder-btn { display: none; }
}


/* v1.0.006 workspace and editing upgrades */
.lock-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .45rem;
  padding: .55rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.035);
}
.lock-grid span { grid-column: 1 / -1; color: var(--muted); font-family: var(--mono); font-size: .72rem; }
.lock-grid label { display: flex; align-items: center; gap: .42rem; }
.layer-item.clipped .layer-title strong::before { content: "↳ "; color: var(--accent); }
.modal-note { margin: 0 0 .2rem; color: var(--muted); font-size: .84rem; }
.size-modal-body label:not(.radio-row) { display: grid; gap: .32rem; color: var(--muted); font-size: .82rem; }
.size-modal-body input[type="number"], .size-modal-body select { width: 100%; }
.tool[data-tool="hand"] span { font-size: 1.05rem; }

/* v1.0.007 usability, effects, selection, and history polish */
.tool-group-label {
  margin: .25rem .1rem -.25rem;
  color: var(--muted);
  font-size: .58rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-align: center;
  opacity: .78;
}
.inline-field {
  display: inline-flex !important;
  align-items: center;
  gap: .35rem;
}
.inline-field input { width: 64px; }
.selection-actions, .transform-control, .text-control {
  align-items: center;
  gap: .35rem;
}
.transform-control input[type="number"], .text-control input[type="number"] { width: 72px; }
.transform-control[aria-pressed="true"], .text-control[aria-pressed="true"] {
  border-color: rgba(0, 208, 132, .7);
  background: rgba(0, 208, 132, .15);
}
.effects-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: .55rem;
  padding: .75rem;
}
.effects-grid label {
  display: grid;
  gap: .28rem;
  color: var(--muted);
  font-size: .78rem;
}
.effects-grid label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: .45rem;
  color: var(--text);
}
.effects-grid input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
.history-list {
  max-height: 220px;
  overflow-y: auto;
  padding: .5rem;
}
.history-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .5rem .6rem;
  margin-bottom: .35rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.035);
  color: var(--text);
  text-align: left;
}
.history-item.active {
  border-color: rgba(70, 179, 255, .65);
  background: rgba(70, 179, 255, .13);
}
.history-item small { color: var(--muted); font-family: var(--mono); }
.tool[data-tool="select-lasso"] span, .tool[data-tool="select-poly"] span { font-size: 1.05rem; }
@media (max-width: 760px) {
  .tool-group-label { display: none; }
}

/* v1.0.009 export optimizer */
.export-modal-card {
  width: min(980px, calc(100vw - 28px));
  max-height: min(88vh, 860px);
  overflow: hidden;
}
.export-modal-body {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 1rem;
  overflow: auto;
}
.export-settings {
  display: grid;
  gap: .65rem;
  align-content: start;
}
.export-settings label:not(.radio-row) {
  display: grid;
  gap: .32rem;
  color: var(--muted);
  font-size: .82rem;
}
.export-settings input,
.export-settings select {
  width: 100%;
}
.export-preview-wrap {
  display: grid;
  gap: .7rem;
  align-content: start;
}
#exportPreview {
  width: 100%;
  max-height: 280px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(45deg, rgba(255,255,255,.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,.08) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,.08) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.08) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.export-info,
.export-recommendation {
  padding: .75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.04);
  color: var(--muted);
  font-size: .87rem;
  line-height: 1.4;
}
.export-recommendation strong { color: var(--text); }
.export-compare {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 12px;
  font-size: .82rem;
}
.export-compare th,
.export-compare td {
  border-bottom: 1px solid var(--line);
  padding: .55rem .6rem;
  text-align: left;
  vertical-align: top;
}
.export-compare th {
  color: var(--muted);
  background: rgba(255,255,255,.06);
  font-weight: 700;
}
.export-compare tr:last-child td { border-bottom: 0; }
@media (max-width: 820px) {
  .export-modal-body { grid-template-columns: 1fr; }
}


/* v1.0.012 builds on v1.0.011 additions plus v1.0.010 hardening, recovery, and workflow polish */
.crop-actions,
.qa-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem;
}
.crop-actions label:not(.inline-field) {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.inline-text-editor {
  position: absolute;
  z-index: 35;
  border: 1px solid rgba(70, 179, 255, .78);
  border-radius: 10px;
  background: rgba(7, 10, 17, .86);
  color: var(--text);
  box-shadow: 0 12px 36px rgba(0,0,0,.35);
  padding: .45rem .55rem;
  resize: both;
  outline: none;
  line-height: 1.2;
}
.context-menu {
  position: fixed;
  z-index: 150;
  min-width: 210px;
  padding: .35rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(18, 23, 36, .98);
  box-shadow: var(--shadow);
}
.context-menu[hidden] { display: none; }
.context-menu button {
  width: 100%;
  display: block;
  min-height: 32px;
  padding: .42rem .55rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.context-menu button:hover:not(:disabled) {
  background: rgba(70, 179, 255, .13);
}
.context-menu button:disabled { color: var(--muted); opacity: .6; }
.context-separator {
  height: 1px;
  margin: .3rem .2rem;
  background: var(--line);
}
.qa-grid {
  display: grid;
  gap: .65rem;
  padding: .75rem;
}
.qa-grid label {
  display: grid;
  gap: .32rem;
  color: var(--muted);
  font-size: .82rem;
}
.qa-report {
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .7rem;
  background: rgba(255,255,255,.035);
  color: var(--muted);
  font-family: var(--mono);
  font-size: .74rem;
  line-height: 1.45;
  max-height: 190px;
  overflow: auto;
}
.statusbar span { white-space: nowrap; }
@media (max-width: 900px) {
  .statusbar span { white-space: normal; }
}


/* v1.0.011 professional tool additions */
.gradient-actions,
.retouch-actions {
  align-items: center;
  gap: .45rem;
  flex-wrap: wrap;
}
.adjustment-grid {
  display: grid;
  gap: .55rem;
}
.adjustment-grid label,
.gradient-actions label,
.retouch-actions label {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  color: var(--muted);
  font-size: .8rem;
}
.panel-note {
  margin: .25rem 0 0;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.35;
}
.layer-item.clipped .layer-title strong::before { content: '↳ '; color: var(--accent-2); }

/* v1.0.012 vector/text/style/template/layout additions */
.ruler {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  opacity: .9;
  background: rgba(8, 13, 24, .88);
  border-color: rgba(255,255,255,.12);
  color: rgba(231,236,248,.72);
  font-family: var(--mono);
  font-size: 10px;
  overflow: hidden;
}
.ruler[hidden] { display: none; }
.ruler-top {
  left: 0;
  top: -22px;
  right: 0;
  height: 22px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  background-image: linear-gradient(90deg, rgba(255,255,255,.22) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.12) 1px, transparent 1px);
  background-size: 100px 100%, 20px 100%;
}
.ruler-left {
  left: -22px;
  top: 0;
  bottom: 0;
  width: 22px;
  border-right: 1px solid rgba(255,255,255,.12);
  background-image: linear-gradient(0deg, rgba(255,255,255,.22) 1px, transparent 1px), linear-gradient(0deg, rgba(255,255,255,.12) 1px, transparent 1px);
  background-size: 100% 100px, 100% 20px;
}
.stage.has-rulers { margin-top: 22px; margin-left: 22px; }
.guide-actions {
  align-items: center;
  gap: .45rem;
  flex-wrap: wrap;
}
.shape-control input[type="number"],
.text-control input[type="number"] { width: 72px; }
.preset-grid,
.guide-grid {
  display: grid;
  gap: .55rem;
  padding: .75rem;
}
.preset-grid .mini { justify-content: center; }
.guide-grid label {
  display: grid;
  gap: .32rem;
  color: var(--muted);
  font-size: .82rem;
}
.preset-list,
.guide-list {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.035);
  padding: .6rem;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.4;
  max-height: 160px;
  overflow: auto;
}
.template-grid label,
.layer-style-body label {
  display: grid;
  gap: .3rem;
  color: var(--muted);
  font-size: .84rem;
}
.layer-style-card { width: min(860px, calc(100vw - 24px)); }
.layer-style-body {
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  align-items: end;
}
@media (max-width: 760px) {
  .layer-style-body { grid-template-columns: 1fr; }
}


/* v1.0.013 workflow fix pass: compact tools, collapsible panels, usable rulers, and export save visibility */
.main-grid {
  grid-template-columns: 116px minmax(0, 1fr) 330px;
}
.toolbox {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: .35rem;
  padding: .6rem .45rem;
}
.tool-group-label {
  grid-column: 1 / -1;
  margin: .45rem .15rem .05rem;
  text-align: left;
  padding-left: .15rem;
}
.tool {
  min-height: 46px;
  padding: .35rem .15rem;
  border-radius: 14px;
}
.tool span { font-size: 1rem; }
.tool small { font-size: .58rem; line-height: 1.05; }

.panels > .panel.is-collapsible > .panel-header {
  cursor: pointer;
  user-select: none;
}
.panel-toggle {
  margin-left: auto;
  min-width: 28px;
  min-height: 28px;
  padding: .15rem .35rem;
}
.panels > .panel.is-collapsed > :not(.panel-header) {
  display: none !important;
}
.panels > .panel.is-collapsed .panel-header {
  border-bottom: 0;
}
.panels > .panel.is-collapsed {
  box-shadow: none;
}

/* Keep rulers from changing the centered canvas position. */
.stage.has-rulers {
  margin: 80px auto;
}
.ruler {
  box-shadow: 0 2px 8px rgba(0,0,0,.22);
}
.ruler-top {
  top: -24px;
  height: 24px;
}
.ruler-left {
  left: -24px;
  width: 24px;
}
.ruler-label {
  position: absolute;
  color: rgba(231,236,248,.82);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0,0,0,.75);
}
.ruler-top .ruler-label {
  top: 6px;
  transform: translateX(3px);
}
.ruler-left .ruler-label {
  left: 4px;
  transform-origin: 0 0;
  transform: translateY(4px) rotate(-90deg);
}

.export-modal-card {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
}
.export-modal-card .modal-header,
.export-modal-card .modal-actions {
  flex: 0 0 auto;
}
.export-modal-body {
  min-height: 0;
  overflow: auto;
}
.export-modal-card .modal-actions {
  position: sticky;
  bottom: 0;
  z-index: 4;
  background: rgba(22, 27, 42, .98);
  box-shadow: 0 -12px 24px rgba(0,0,0,.22);
}
.export-quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .55rem;
}
.export-quick-actions .export-save-inline {
  grid-column: 1 / -1;
  justify-content: center;
  min-height: 42px;
}
@media (max-width: 1100px) {
  .main-grid { grid-template-columns: 96px minmax(0, 1fr) 300px; }
  .tool small { display: none; }
  .tool { min-height: 40px; }
}
@media (max-width: 820px) {
  .main-grid { grid-template-columns: 72px minmax(0, 1fr); }
  .toolbox { grid-template-columns: 1fr; }
  .tool-group-label { display: none; }
  .panels { grid-column: 1 / -1; }
}
