/* ==========================================================================
   Photo Graphique — feuille de style principale
   Interface d'atelier photo : sombre par défaut, claire en option.
   ========================================================================== */

:root {
  --bg: #0b0f16;
  --bg-soft: #0f141d;
  --panel: #141a24;
  --panel-2: #1a2230;
  --panel-3: #212b3b;
  --border: #273244;
  --border-strong: #36445b;
  --text: #e9eef7;
  --text-soft: #b8c4d6;
  --muted: #8494ab;
  --accent: #ff8a4c;
  --accent-2: #8b5cf6;
  --accent-soft: rgba(255, 138, 76, .14);
  --blue: #4c9aff;
  --green: #3ecf8e;
  --danger: #ff5d6c;
  --shadow: 0 18px 60px rgba(0, 0, 0, .45);
  --shadow-soft: 0 6px 18px rgba(0, 0, 0, .28);
  --radius: 10px;
  --radius-sm: 7px;
  --topbar-h: 52px;
  --options-h: 44px;
  --tabbar-h: 38px;
  --status-h: 28px;
  --dock-w: 310px;
  --rail-w: 58px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

[data-theme="light"] {
  --bg: #e9eef6;
  --bg-soft: #f1f5fa;
  --panel: #ffffff;
  --panel-2: #f4f7fc;
  --panel-3: #e9eff8;
  --border: #d8e1ee;
  --border-strong: #c2cfe0;
  --text: #1b2534;
  --text-soft: #3f4d61;
  --muted: #6b7c92;
  --accent: #f2702a;
  --accent-2: #7c4dff;
  --accent-soft: rgba(242, 112, 42, .12);
  --blue: #2f7ef0;
  --shadow: 0 18px 60px rgba(37, 55, 84, .22);
  --shadow-soft: 0 6px 18px rgba(37, 55, 84, .12);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button { cursor: pointer; }

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

[hidden] { display: none !important; }

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--text-soft);
  font-family: var(--font);
  font-size: 11px;
  text-align: center;
  line-height: 1.5;
}

::selection { background: rgba(76, 154, 255, .35); }

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* Scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 2px solid transparent;
  background-clip: content-box;
  border-radius: 9px;
}

/* ==========================================================================
   Structure générale
   ========================================================================== */

#app {
  height: 100vh;
  display: grid;
  grid-template-rows: var(--topbar-h) var(--options-h) minmax(0, 1fr);
}

/* --------------------------------------------------------------------------
   Barre supérieure
   -------------------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 0 12px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-soft) 100%);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 60;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
  user-select: none;
}

.brand-mark {
  width: 30px;
  height: 30px;
  color: var(--text);
  stroke: none;
  filter: drop-shadow(0 2px 8px rgba(255, 138, 76, .25));
}

.brand-text {
  font-size: 16px;
  font-weight: 300;
  letter-spacing: .2px;
  white-space: nowrap;
}

.brand-accent {
  font-weight: 700;
  margin-left: .16em;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid rgba(255, 138, 76, .45);
  background: var(--accent-soft);
  padding: 1px 5px;
  border-radius: 20px;
  transform: translateY(-5px);
}

.menubar {
  display: flex;
  align-items: stretch;
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow: visible;
}

.menu {
  position: relative;
  display: flex;
  align-items: stretch;
}

.menu-title {
  background: none;
  border: 0;
  padding: 0 9px;
  color: var(--text-soft);
  font-size: 12.5px;
  border-radius: 6px;
  white-space: nowrap;
}

.menu-title:hover,
.menu.open > .menu-title {
  background: var(--panel-2);
  color: var(--text);
}

.dropdown {
  display: none;
  position: absolute;
  top: calc(100% - 3px);
  left: 0;
  min-width: 272px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 500;
  animation: pop .12s ease-out;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(-4px) scale(.99); }
  to { opacity: 1; transform: none; }
}

.menu.open > .dropdown { display: block; }

.dropdown button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text-soft);
  text-align: left;
  white-space: nowrap;
}

.dropdown button:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--text);
}

.dropdown button:disabled {
  opacity: .38;
  cursor: default;
}

.dropdown .shortcut {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .02em;
}

.dropdown .sep {
  height: 1px;
  margin: 5px 8px;
  background: var(--border);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.history-buttons {
  display: flex;
  gap: 2px;
  padding-right: 6px;
  border-right: 1px solid var(--border);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-soft);
  transition: background .15s, color .15s, border-color .15s;
}

.icon-btn svg { width: 18px; height: 18px; }

.icon-btn:hover {
  background: var(--panel-2);
  border-color: var(--border);
  color: var(--text);
}

.icon-btn:disabled {
  opacity: .32;
  cursor: default;
  background: transparent;
  border-color: transparent;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 13px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #ff6b6b 55%, var(--accent-2));
  color: #fff;
  font-weight: 600;
  font-size: 12.5px;
  box-shadow: 0 4px 16px rgba(255, 138, 76, .22);
  transition: transform .12s, box-shadow .15s, filter .15s;
}

.primary-btn:hover { filter: brightness(1.07); box-shadow: 0 6px 20px rgba(255, 138, 76, .32); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn svg { width: 16px; height: 16px; stroke-width: 2; }

/* --------------------------------------------------------------------------
   Barre d'options contextuelles
   -------------------------------------------------------------------------- */

.optionsbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  min-width: 0;
  z-index: 40;
}

.options-tool {
  flex: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  padding-right: 14px;
  border-right: 1px solid var(--border);
  min-width: 92px;
}

.options-content {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  height: 100%;
}

.options-content::-webkit-scrollbar { display: none; }

.options-right {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: none;
}

.color-chip {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  box-shadow: inset 0 0 0 2px var(--panel);
  cursor: pointer;
}

.opt {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  flex: none;
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}

.opt > label,
.opt .opt-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.opt select,
.opt input[type="number"],
.opt input[type="text"] {
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  outline: none;
}

.opt select { padding-right: 24px; }
.opt select:hover, .opt input:hover { border-color: var(--border-strong); }
.opt select:focus, .opt input:focus { border-color: var(--blue); }

.opt input[type="range"] {
  width: 104px;
  accent-color: var(--accent);
}

.opt .value-badge {
  min-width: 34px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.segmented {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border-radius: 7px;
  background: var(--panel);
  border: 1px solid var(--border);
}

.segmented button {
  height: 22px;
  padding: 0 9px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
}

.segmented button:hover { color: var(--text); }
.segmented button.is-active {
  background: var(--panel-3);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  white-space: nowrap;
}

.check input { accent-color: var(--accent); margin: 0; }

.opt-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex: none;
}

.opt-hint {
  color: var(--muted);
  font-size: 11.5px;
  font-style: italic;
}

/* --------------------------------------------------------------------------
   Espace de travail
   -------------------------------------------------------------------------- */

.workspace {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--dock-w);
  min-height: 0;
  background: var(--bg);
  overflow: hidden;
}

body.dock-hidden .workspace { grid-template-columns: var(--rail-w) minmax(0, 1fr) 0; }
body.dock-hidden .dock { display: none; }

/* Palette d'outils */
.toolrail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: visible;
  z-index: 30;
}

.tool-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 3px 0 8px;
  position: relative;
}

.tool-group + .tool-group { border-top: 1px solid var(--border); padding-top: 8px; }

.tool-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-soft);
  transition: background .12s, color .12s, border-color .12s;
}

.tool-btn svg { width: 19px; height: 19px; }

.tool-btn:hover {
  background: var(--panel-2);
  color: var(--text);
}

.floating-tip {
  position: fixed;
  z-index: 1500;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-3);
  color: var(--text);
  font-size: 11.5px;
  white-space: nowrap;
  box-shadow: var(--shadow-soft);
  pointer-events: none;
  animation: fade-in .1s ease-out;
}

.tool-btn.is-active {
  background: var(--accent-soft);
  border-color: rgba(255, 138, 76, .38);
  color: var(--accent);
}

.tool-btn.is-active::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(var(--accent), var(--accent-2));
}

.tool-group-colors {
  margin-top: auto;
  border-top: 0;
  align-items: center;
}

.mini-colors {
  position: relative;
  width: 38px;
  height: 38px;
  margin-bottom: 2px;
}

.mini-color {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 2px solid var(--panel);
  border-radius: 6px;
  box-shadow: 0 0 0 1px var(--border-strong), 0 2px 6px rgba(0, 0, 0, .3);
  padding: 0;
}

.mini-fg { left: 0; top: 0; z-index: 2; }
.mini-bg { right: 0; bottom: 0; }

.tool-mini { width: 30px; height: 26px; color: var(--muted); }
.tool-mini svg { width: 15px; height: 15px; }

/* Zone d'édition */
.editor-area {
  display: grid;
  grid-template-rows: var(--tabbar-h) minmax(0, 1fr) var(--status-h);
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.doc-tabbar {
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 0 10px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}

.doc-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 420px;
  padding: 0 8px 0 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  align-self: flex-end;
  height: calc(var(--tabbar-h) - 1px);
  color: var(--text-soft);
  font-size: 12px;
}

.doc-tab-icon { width: 14px; height: 14px; color: var(--accent); }

#doc-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dirty-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.tab-close:hover { background: var(--panel-3); color: var(--text); }
.tab-close svg { width: 12px; height: 12px; }

.tab-spacer { flex: 1; }

.doc-meta {
  align-self: center;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.canvas-viewport {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 35%, rgba(76, 154, 255, .045), transparent 55%),
    var(--bg);
  touch-action: none;
}

#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.drop-hint {
  position: absolute;
  inset: 16px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--accent);
  border-radius: 14px;
  background: rgba(11, 15, 22, .78);
  backdrop-filter: blur(3px);
  z-index: 20;
  pointer-events: none;
}

body.dragging .drop-hint { display: flex; }

.drop-hint-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  color: var(--text);
  text-align: center;
}

.drop-hint-inner svg { width: 44px; height: 44px; color: var(--accent); stroke-width: 1.3; }
.drop-hint-inner strong { font-size: 16px; }
.drop-hint-inner span { color: var(--muted); font-size: 12px; }

.viewport-tools {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-soft);
  z-index: 15;
}

.vp-btn, .vp-zoom, .vp-fit {
  height: 26px;
  min-width: 26px;
  padding: 0 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-soft);
  font-size: 12px;
}

.vp-btn { font-size: 16px; line-height: 1; }
.vp-btn:hover, .vp-zoom:hover { background: var(--panel-3); color: var(--text); }

.vp-zoom {
  min-width: 58px;
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
}

.status-left, .status-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.status-left { overflow: hidden; }
.status-right { flex: none; }

.status-item {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-sep {
  width: 1px;
  height: 10px;
  background: var(--border-strong);
  flex: none;
}

.status-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border-radius: 2px;
  border: 1px solid var(--border-strong);
  vertical-align: -1px;
  background: transparent;
}

#status-color { display: inline-flex; align-items: center; }

/* --------------------------------------------------------------------------
   Panneaux (dock de droite)
   -------------------------------------------------------------------------- */

.dock {
  background: var(--panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

.panel { border-bottom: 1px solid var(--border); }
.panel:last-child { border-bottom: 0; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px 8px 13px;
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 2;
}

.panel-head h2 {
  margin: 0;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel-actions { display: flex; align-items: center; gap: 2px; }

.mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
}

.mini-btn:hover { background: var(--panel-2); border-color: var(--border); color: var(--text); }
.mini-btn svg { width: 14px; height: 14px; }

.panel-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  padding: 0;
  transition: transform .18s;
}

.panel-toggle:hover { background: var(--panel-2); color: var(--text); }
.panel-toggle svg { width: 13px; height: 13px; }

.panel.collapsed .panel-body { display: none; }
.panel.collapsed .panel-toggle { transform: rotate(180deg); }

.panel-body { padding: 0 12px 13px; }

/* Couleurs */
.color-editor {
  display: flex;
  gap: 14px;
  align-items: center;
}

.swatch-stack {
  position: relative;
  width: 76px;
  height: 70px;
  flex: none;
}

.big-swatch {
  position: absolute;
  width: 48px;
  height: 48px;
  border: 2px solid var(--panel);
  border-radius: 9px;
  padding: 0;
  box-shadow: 0 0 0 1px var(--border-strong), 0 4px 10px rgba(0, 0, 0, .28);
}

.big-swatch.fg { left: 0; top: 0; z-index: 2; }
.big-swatch.bg { right: 0; bottom: 0; }

.swap-btn {
  position: absolute;
  left: 52px;
  top: 0;
  z-index: 3;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--panel-2);
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1;
}

.swap-btn:hover { color: var(--accent); border-color: var(--accent); }

.color-fields { flex: 1; min-width: 0; }

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
}

.field-row input {
  width: 82px;
  height: 25px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
}

.field-row input:focus { border-color: var(--blue); outline: none; }

.color-actions { display: flex; gap: 5px; margin-top: 8px; }

.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 25px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-soft);
  font-size: 11.5px;
}

.ghost-btn:hover { background: var(--panel-2); border-color: var(--border-strong); color: var(--text); }
.ghost-btn svg { width: 13px; height: 13px; }
.ghost-btn:disabled { opacity: .4; cursor: default; }

.palette {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 3px;
  margin-top: 12px;
}

.palette button {
  aspect-ratio: 1;
  min-height: 16px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, .18);
  border-radius: 3px;
  transition: transform .1s;
}

.palette button:hover { transform: scale(1.18); outline: 1px solid var(--text); z-index: 1; }

.recent-colors {
  display: flex;
  gap: 4px;
  margin-top: 9px;
  min-height: 14px;
  flex-wrap: wrap;
}

.recent-colors button {
  width: 15px;
  height: 15px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
}

/* Calques */
.layer-controls {
  display: grid;
  gap: 9px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.blend-select {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.blend-select select {
  height: 26px;
  max-width: 165px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 11.5px;
}

.opacity-control { display: grid; gap: 4px; color: var(--muted); font-size: 11px; }
.opacity-control span { display: flex; justify-content: space-between; }
.opacity-control b { color: var(--text-soft); font-weight: 500; font-variant-numeric: tabular-nums; }
.opacity-control input { width: 100%; accent-color: var(--accent); }

.layer-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 236px;
  overflow-y: auto;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 6px;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  user-select: none;
}

.layer-item:hover { background: var(--panel-2); }
.layer-item.is-active {
  background: var(--accent-soft);
  border-color: rgba(255, 138, 76, .32);
}

.layer-eye {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  flex: none;
}

.layer-eye:hover { background: var(--panel-3); color: var(--text); }
.layer-eye svg { width: 14px; height: 14px; }
.layer-item.is-hidden .layer-eye { color: var(--border-strong); }
.layer-item.is-hidden .layer-name { opacity: .45; }

.layer-thumb {
  width: 34px;
  height: 30px;
  flex: none;
  border-radius: 4px;
  border: 1px solid var(--border);
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #d6dbe3 25%, transparent 25%, transparent 75%, #d6dbe3 75%),
    linear-gradient(45deg, #d6dbe3 25%, transparent 25%, transparent 75%, #d6dbe3 75%);
  background-size: 8px 8px;
  background-position: 0 0, 4px 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.layer-thumb canvas { max-width: 100%; max-height: 100%; display: block; }

.layer-name {
  flex: 1;
  min-width: 0;
  font-size: 11.5px;
  color: var(--text-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-item.is-active .layer-name { color: var(--text); font-weight: 600; }

.layer-badge {
  font-size: 9px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
  flex: none;
}

.layer-footer {
  display: flex;
  gap: 5px;
  margin-top: 9px;
  flex-wrap: wrap;
}

.layer-footer .ghost-btn { flex: 1; padding: 0 6px; font-size: 10.5px; }

/* Historique */
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column-reverse;
  gap: 1px;
  max-height: 190px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border-radius: 5px;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
}

.history-item:hover { background: var(--panel-2); color: var(--text-soft); }
.history-item.is-current { background: var(--panel-3); color: var(--text); }
.history-item.is-future { opacity: .42; }

.history-item .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--border-strong);
  flex: none;
}

.history-item.is-current .dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.history-empty {
  padding: 12px 6px;
  color: var(--muted);
  font-size: 11.5px;
  font-style: italic;
  text-align: center;
}

/* Informations */
.info-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  margin: 0;
  font-size: 11.5px;
}

.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; color: var(--text-soft); text-align: right; font-variant-numeric: tabular-nums; }

.tips {
  margin-top: 12px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--panel-2);
}

.tips strong {
  display: block;
  margin-bottom: 3px;
  color: var(--accent);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.tips p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; }

/* ==========================================================================
   Notifications
   ========================================================================== */

.toast-wrap {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1200;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 240px;
  max-width: 380px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.4;
  pointer-events: auto;
  animation: toast-in .2s ease-out;
}

.toast::before {
  content: "";
  width: 4px;
  align-self: stretch;
  border-radius: 4px;
  background: var(--blue);
  flex: none;
}

.toast.is-success::before { background: var(--green); }
.toast.is-error::before { background: var(--danger); }
.toast.is-warn::before { background: var(--accent); }
.toast.is-leaving { animation: toast-out .2s ease-in forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(6px); }
}

/* ==========================================================================
   Modales et formulaires
   ========================================================================== */

.modal-root { position: relative; z-index: 1000; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5, 8, 13, .62);
  backdrop-filter: blur(5px);
  animation: fade-in .15s ease-out;
  z-index: 1000;
}

@keyframes fade-in { from { opacity: 0; } }

.dialog {
  width: var(--dialog-w, 460px);
  max-width: 100%;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow);
  animation: dialog-in .18s cubic-bezier(.2, .8, .2, 1);
  overflow: hidden;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
}

.dialog-title { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.dialog-sub { margin: 3px 0 0; color: var(--muted); font-size: 11.5px; }

.dialog-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex: none;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.dialog-close:hover { background: var(--panel-2); color: var(--text); }
.dialog-close svg { width: 15px; height: 15px; }

.dialog-body {
  padding: 16px 18px;
  overflow-y: auto;
  min-height: 0;
}

.dialog-body p { margin: 0 0 10px; color: var(--text-soft); line-height: 1.55; }
.dialog-body p.muted, .muted { color: var(--muted); }
.dialog-body a { color: var(--blue); }

.dialog-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
}

.dialog-foot .spacer { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text-soft);
  font-weight: 500;
  transition: background .12s, border-color .12s, color .12s;
}

.btn:hover { background: var(--panel-3); border-color: var(--border-strong); color: var(--text); }

.btn-primary {
  border: 0;
  background: linear-gradient(135deg, var(--accent), #ff6b6b 60%, var(--accent-2));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(255, 138, 76, .2);
}

.btn-primary:hover { filter: brightness(1.07); color: #fff; }
.btn-danger { border-color: rgba(255, 93, 108, .4); color: var(--danger); background: rgba(255, 93, 108, .08); }
.btn-danger:hover { background: rgba(255, 93, 108, .16); border-color: var(--danger); }
.btn svg { width: 15px; height: 15px; }

.form-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px 12px;
}

.form-grid label { color: var(--muted); font-size: 12px; }

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  height: 33px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text);
  outline: none;
}

.form-grid textarea { height: auto; min-height: 76px; padding: 8px 9px; resize: vertical; line-height: 1.45; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { border-color: var(--blue); }
.form-grid input[type="checkbox"],
.form-grid input[type="radio"],
.check input[type="checkbox"],
.check input[type="radio"] {
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  margin: 0;
  accent-color: var(--accent);
  flex: none;
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid .hint { grid-column: 1 / -1; color: var(--muted); font-size: 11px; margin-top: -3px; }

.inline-fields { display: flex; align-items: center; gap: 7px; }
.inline-fields input { width: 88px; }
.inline-fields .x { color: var(--muted); }

.ratio-row { display: flex; align-items: center; }
.ratio-row .check { font-size: 11.5px; }

.slider-rows { display: grid; gap: 13px; margin-bottom: 4px; }

.slider-row { display: grid; gap: 5px; }
.slider-row .slider-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--text-soft); }
.slider-row .slider-head b { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; min-width: 38px; text-align: right; }
.slider-row input[type="range"] { width: 100%; accent-color: var(--accent); }
.slider-row .range-ends { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; }

.dialog-split { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; align-items: start; }
.dialog-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.preview-frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #cfd6df 25%, transparent 25%, transparent 75%, #cfd6df 75%),
    linear-gradient(45deg, #cfd6df 25%, transparent 25%, transparent 75%, #cfd6df 75%);
  background-size: 18px 18px;
  background-position: 0 0, 9px 9px;
}

.preview-frame canvas { max-width: 100%; max-height: 100%; display: block; }
.preview-frame .preview-empty { color: #5c6b80; font-size: 11px; text-align: center; padding: 20px; }

.preview-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; }
.preview-hint { color: var(--muted); font-size: 10.5px; line-height: 1.45; }

.seg-row { display: flex; gap: 4px; flex-wrap: wrap; }

.swatches-row { display: flex; gap: 5px; flex-wrap: wrap; }
.swatches-row button {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
}

.range-inline { display: flex; align-items: center; gap: 8px; }
.range-inline input[type="range"] { flex: 1; accent-color: var(--accent); }

/* Galerie */
.dialog.dialog-wide { --dialog-w: 920px; width: 920px; }
.dialog.dialog-lg { --dialog-w: 680px; width: 680px; }

.gallery-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.gallery-bar input[type="search"] {
  flex: 1;
  min-width: 180px;
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  outline: none;
}

.gallery-bar input[type="search"]:focus { border-color: var(--blue); }

.gallery-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 20px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 10.5px;
}

.gallery-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

.gallery-badge.is-local .dot { background: var(--accent); }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.gallery-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel-2);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}

.gallery-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}

.gallery-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #fff;
  overflow: hidden;
  cursor: pointer;
}

.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.gallery-thumb .gallery-open {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(8, 12, 18, .55);
  color: #fff;
  opacity: 0;
  transition: opacity .15s;
  font-size: 12px;
  font-weight: 600;
}

.gallery-thumb:hover .gallery-open { opacity: 1; }
.gallery-open svg { width: 18px; height: 18px; }

.gallery-info { padding: 8px 10px 9px; display: grid; gap: 2px; }
.gallery-title { font-size: 12px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery-meta { font-size: 10.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }
.gallery-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.gallery-card-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity .15s;
}

.gallery-card:hover .gallery-card-actions { opacity: 1; }

.gallery-card-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 6px;
  background: rgba(10, 14, 21, .7);
  color: #fff;
  backdrop-filter: blur(4px);
}

.gallery-card-actions button:hover { background: rgba(10, 14, 21, .92); }
.gallery-card-actions button svg { width: 13px; height: 13px; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 42px 20px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg { width: 44px; height: 44px; opacity: .5; stroke-width: 1.3; }
.empty-state strong { color: var(--text-soft); font-size: 13px; }
.empty-state span { font-size: 11.5px; max-width: 340px; line-height: 1.5; }

.loading-line {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 0;
  color: var(--muted);
  font-size: 12px;
}

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex: none;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Aide / raccourcis */
.shortcut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 22px; }
.shortcut-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 4px 0; border-bottom: 1px dashed var(--border); font-size: 12px; color: var(--text-soft); }
.shortcut-row kbd { flex: none; }
.shortcut-section { margin: 15px 0 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.shortcut-section:first-child { margin-top: 0; }

.about-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.about-brand svg { width: 52px; height: 52px; stroke: none; }
.about-brand h3 { margin: 0; font-size: 20px; font-weight: 700; }
.about-brand p { margin: 3px 0 0; color: var(--muted); font-size: 11.5px; }

.badge-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.badge-list span { font-size: 10.5px; padding: 3px 7px; border: 1px solid var(--border); border-radius: 20px; color: var(--muted); }

/* Barre de progression d'export */
.progress-track { height: 4px; border-radius: 4px; background: var(--panel-3); overflow: hidden; margin-top: 8px; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .2s; }

/* Formulaires : compléments */
.anchor-grid {
  display: grid;
  grid-template-columns: repeat(3, 27px);
  grid-template-rows: repeat(3, 27px);
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  width: max-content;
}

.anchor-cell {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel);
  padding: 0;
}

.anchor-cell:hover { border-color: var(--border-strong); }
.anchor-cell.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.ghost-btn.is-active {
  color: var(--accent);
  border-color: rgba(255, 138, 76, .55);
  background: var(--accent-soft);
}

input.invalid { border-color: var(--danger) !important; }

.dialog .form-grid input[type="color"] {
  padding: 2px;
  height: 33px;
  cursor: pointer;
}

.dialog .form-grid input[type="range"] { padding: 0; height: 24px; accent-color: var(--accent); }

/* ==========================================================================
   Adaptations
   ========================================================================== */

@media (max-width: 1400px) {
  :root { --dock-w: 288px; }
  .menu-title { padding: 0 7px; font-size: 12px; }
  .brand-text { font-size: 15px; }
}

@media (max-width: 1210px) {
  .brand-badge { display: none; }
  .topbar-actions .primary-btn span { display: none; }
  .topbar-actions .primary-btn { padding: 0 9px; }
  .menu-title { font-size: 11.5px; padding: 0 6px; }
  .palette { grid-template-columns: repeat(10, 1fr); }
}

@media (max-width: 1040px) {
  :root { --dock-w: 260px; --rail-w: 52px; }
  .brand-text { display: none; }
  .history-buttons { border: 0; padding: 0; }
  .menu-title { padding: 0 5px; }
  .statusbar #status-selection { display: none; }
}

@media (max-width: 900px) {
  body:not(.dock-open) .dock { display: none; }
  .workspace { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  .workspace .dock { position: absolute; right: 0; top: calc(var(--topbar-h) + var(--options-h)); bottom: 0; width: 280px; z-index: 50; box-shadow: var(--shadow); }
  .workspace { position: relative; }
  .topbar-actions .icon-btn[data-action="guide"] { display: none; }
  .menu[data-menu="view"] { display: none; }
}

@media (max-width: 720px) {
  :root { --topbar-h: 48px; --options-h: 42px; --rail-w: 48px; }
  .menubar { overflow-x: auto; scrollbar-width: none; }
  .menubar::-webkit-scrollbar { display: none; }
  .menu[data-menu="tools"], .menu[data-menu="help"] { display: none; }
  .brand { display: none; }
  .topbar { gap: 4px; padding-left: 8px; }
  .dialog-split { grid-template-columns: 1fr; }
  .shortcut-grid { grid-template-columns: 1fr; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .modal-backdrop { padding: 10px; }
  .dialog-body { padding: 13px; }
}

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