/* Saraskala Photo Editor — Design System (restored)
   Client-side photo, signature & PDF preparation for exams.
   Bluish-black + cyan, aligned with homepage site-v3 • No uploads */

/* ---------- Design Tokens ---------- */
:root {
  --bg:#04060e;
  --bg2:#070a15;
  --panel:#101733cc;
  --panel-strong:#101733;
  --text:#f4f6ff;
  --muted:#b6bed8;
  --magenta:#38d9f0;
  --cyan:#38d9f0;
  --violet:#5b8cff;
  --gold:#f2b544;
  --steel:#6b7280;
  --line:rgba(255,255,255,.08);
  --glow:0 0 0 1px rgba(255,255,255,.03),0 24px 80px rgba(0,0,0,.52);
  --glow-strong:0 0 0 1px rgba(255,255,255,.06),0 32px 100px rgba(0,0,0,.62);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  color-scheme: dark;
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  background:
    radial-gradient(ellipse 62% 46% at 14% -4%, rgba(56, 217, 240, .16), transparent 62%),
    radial-gradient(ellipse 58% 44% at 88% 2%, rgba(91, 140, 255, .16), transparent 60%),
    radial-gradient(ellipse 74% 48% at 50% 104%, rgba(56, 217, 240, .10), transparent 64%),
    radial-gradient(ellipse 40% 30% at 80% 68%, rgba(242, 181, 68, .07), transparent 62%),
    linear-gradient(168deg, #04060e 0%, #070a15 48%, #070a1c 100%) !important;
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.6;
}

body:before {
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  opacity:.22;
  background-image:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size:42px 42px;
  mask-image:radial-gradient(circle at center, black, transparent 82%);
}

[hidden]{display:none !important;}

.sr-only{
  position:absolute!important;
  width:1px!important;
  height:1px!important;
  padding:0!important;
  margin:-1px!important;
  overflow:hidden!important;
  clip:rect(0,0,0,0)!important;
  white-space:nowrap!important;
  border:0!important;
}

/* ---------- Layout ----------
   The shell is sized from the MEASURED masthead height, published by
   js/chrome-height.js as --saras-chrome-h on <html>. The previous rule hardcoded
   `calc(100vh - 86px)`; the masthead actually renders 59px, and 86px was never
   derived from anything. Because that value was larger than the real header the
   row was too short, while a 180px padding-bottom inflated it past the viewport,
   so `.main` measured a constant 1073px at every window size and the canvas
   (absolutely positioned, sized from this box) drew ~221px below the fold.

   `100dvh` tracks the visible area on mobile browsers with a collapsing URL bar,
   which `100vh` does not. The fallback keeps older engines working. */
.main {
  display: flex;
  min-height: calc(100vh - var(--saras-chrome-h, 59px));
  min-height: calc(100dvh - var(--saras-chrome-h, 59px));
  /* The row must be allowed to be SHORTER than its tallest child, otherwise the
     properties column's content (which is long and scrolls internally) stretches
     the whole row and the canvas inherits that height. max-height lets the row
     shrink to the viewport while min-height keeps it filling short content. */
  max-height: calc(100vh - var(--saras-chrome-h, 59px));
  max-height: calc(100dvh - var(--saras-chrome-h, 59px));
  margin-top:0;
  overflow: hidden;
}

.workspace {
  flex: 1 1 auto;
  /* min-width:0 lets the flex child actually shrink instead of being sized by
     its content, which is what let the canvas push the row wider than the page */
  min-width: 0;
  position: relative;
  background:
    radial-gradient(circle at 30% 20%, #101733 0%, #070a15 55%, #04060e 100%);
  touch-action: manipulation;
  /* No bottom padding. This is the single cause of the canvas overflowing the
     viewport: js/upload.js sizes the canvas from this element's offsetHeight,
     and 180px of padding was added to that measurement. */
  padding-bottom: 0 !important;
  transition: all 0.3s ease;
}

#editor-workspace {
  padding-bottom: 0 !important;
  transition: all 0.3s ease;
}

/* ---------- Canvas ----------
   The container fills the workspace rather than being absolutely positioned at
   the origin. Absolutely positioning it detached the canvas from the flow, so
   nothing constrained it to the visible area and it simply drew past the fold.
   It stays `relative` so the overlay children (drop zone, tool-context header,
   history controls) can still anchor to it. */
canvas {
  display: block;
  max-width: 100%;
}

.canvas-container {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* ---------- Context header ---------- */
.tool-context-header{
  position:absolute;
  top:18px;
  left:50%;
  transform:translateX(-50%);
  z-index:4;
  padding:10px 18px;
  border-radius:999px;
  background:rgba(26,22,32,.90);
  border:1px solid rgba(91,140,255),.30);
  color:#fff;
  font-weight:900;
  letter-spacing:.01em;
  box-shadow:var(--glow);
  backdrop-filter:blur(12px);
  -webkit-backdrop-filter:blur(12px);
}

/* ---------- Canvas history ---------- */
.canvas-history-controls{
  position:absolute;
  left:50%;
  bottom:16px;
  transform:translateX(-50%);
  z-index:3;
  display:flex;
  gap:8px;
  background:rgba(26,22,32,.88);
  border:1px solid rgba(255,255,255,.08);
  border-radius:14px;
  padding:8px 12px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow:var(--glow);
}

.canvas-history-controls button {
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.08);
  color:#fff;
  padding:8px 14px;
  border-radius:10px;
  cursor:pointer;
  font-size:.85rem;
  font-weight:600;
  transition:all .2s;
}

.canvas-history-controls button:hover {
  background:rgba(255,255,255,.08);
  border-color:rgba(91,140,255),.28);
}

.canvas-history-controls button:disabled {
  opacity:.4;
  cursor:not-allowed;
}

/* ---------- Properties sidebar ---------- */
.properties {
  width: 360px;
  background: linear-gradient(180deg, #08121f, #0d1828 22%, #0a1525 100%);
  color: var(--muted);
  padding: 14px 12px 18px;
  overflow-y: auto;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
  scrollbar-color: #5b8cff #0a1528;
  border-left: 1px solid rgba(255,255,255,.06);
  font-size:13px;
  transition: width 0.2s ease, opacity 0.2s ease;
}

.properties::-webkit-scrollbar{width:14px}
.properties::-webkit-scrollbar-thumb{
  background: linear-gradient(180deg, #38d9f0, #5b8cff);
  border-radius: 10px;
  border: 3px solid #0a1528;
  min-height: 48px;
}
.properties::-webkit-scrollbar-thumb:hover{
  background: linear-gradient(180deg, #7fe3f4, #7c9dff);
}
.properties::-webkit-scrollbar-track{background:#08121f;border-left:1px solid rgba(255,255,255,.06)}

/* Collapsed state */
.properties.is-collapsed,
body[data-collapsed-properties="1"] .properties {
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  padding: 0 !important;
  border-left: none !important;
  opacity: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
}

/* ---------- Editor panel sections ---------- */
.editor-panel-section {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--magenta);
  margin: 18px 0 10px;
  padding-left: 4px;
}

/* Accordion details */
.properties details[data-accordion-group="editor-panels"] {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(8, 24, 42, 0.92), rgba(7, 16, 32, 0.92));
  margin-bottom: 10px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.properties details[data-accordion-group="editor-panels"][open] {
  border-color: rgba(138, 92, 255, 0.32);
  box-shadow: 0 0 0 1px rgba(138, 92, 255, 0.16);
}

.properties details[data-accordion-group="editor-panels"] summary {
  /* 44px minimum touch target. `10px 14px` padding produced a 41px row, which is
     under the accessible minimum and hard to hit on a phone. Padding is raised
     and min-height guarantees the target even if the label wraps. */
  padding: 12px 14px;
  min-height: 44px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  list-style: none;
  font-weight: 800;
  font-size: 0.82rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.02);
  transition: background 0.2s, color 0.2s;
  outline: none;
}

.properties details[data-accordion-group="editor-panels"] summary:hover {
  background: rgba(138, 92, 255, 0.10);
}

/* Collapsed panels are progressively disclosed, but they must still read as
   interactive and must be reachable by keyboard. The focus ring was removed
   above for the default state and is restored here. */
.properties details[data-accordion-group="editor-panels"] summary:focus-visible {
  outline: 3px solid var(--cyan, #2be4ff);
  outline-offset: -3px;
  border-radius: 11px;
}

.properties details[data-accordion-group="editor-panels"] summary::-webkit-details-marker {
  display: none;
}

.properties details[data-accordion-group="editor-panels"] summary:before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--magenta);
  border-bottom: 2px solid var(--magenta);
  transform: rotate(45deg);
  margin-right: 8px;
  transition: transform 0.2s;
}

.properties details[data-accordion-group="editor-panels"][open] summary:before {
  transform: rotate(-135deg);
}

.summary-kicker {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--magenta);
  margin-right: 8px;
}

.summary-title {
  color: #fff;
}

/* ---------- Form controls ---------- */
.control-label {
  display: block;
  font-size: 0.78rem;
  color: #a79dd6;
  margin: 12px 0 6px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.control-input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid rgba(122,100,190,.32);
  background: linear-gradient(180deg, rgba(8,28,48,.95), rgba(7,18,34,.96));
  color: #efeaff;
  font-size: 0.9rem;
  box-sizing: border-box;
  transition: all 0.2s;
}

.control-input:focus {
  outline: none;
  border-color: rgba(91,140,255),.42);
  box-shadow: 0 0 0 3px rgba(91,140,255),.08);
}

.control-input::placeholder {
  color: rgba(148, 163, 184, 0.45);
}

.control-input.no-spin::-webkit-outer-spin-button,
.control-input.no-spin::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

.control-input.no-spin {
  appearance: textfield;
  -moz-appearance: textfield;
}

.properties,
.properties select,
.properties option {
  color-scheme: dark;
}
.properties select.control-input,
.properties select {
  background: #0b1220 !important;
  color: #f4f6ff !important;
  min-height: 40px;
}
.properties select option,
.tray-export select option {
  background-color: #0b1220 !important;
  color: #f4f6ff !important;
}

.properties input[type="range"],
.properties input[type="range"].control-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  min-height: 28px !important;
  padding: 0 !important;
  margin: 0 0 10px;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  cursor: pointer;
}
.properties input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #132238, #38d9f0 50%, #5b8cff);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.properties input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border-radius: 50%;
  background: #f4f6ff;
  border: 2px solid #38d9f0;
  box-shadow: 0 0 10px rgba(56, 217, 240, 0.45);
}
.properties input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #132238, #38d9f0 50%, #5b8cff);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.properties input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f4f6ff;
  border: 2px solid #38d9f0;
}

.control-btn {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid rgba(122,100,190,.32);
  background: linear-gradient(180deg, rgba(8,28,48,.95), rgba(7,18,34,.96));
  color: #efeaff;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  box-sizing: border-box;
  transition: all 0.2s;
}

.control-btn:hover {
  border-color: var(--magenta);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(138, 92, 255, 0.18);
}

.control-btn:active {
  transform: translateY(0);
}

.control-btn.small {
  width: auto;
  padding: 7px 14px;
  font-size: 0.8rem;
}

.control-btn.export-shortcut,
.control-btn.pdf-primary-action,
.control-btn.export-primary-btn {
  width: auto;
  background: linear-gradient(135deg, var(--magenta), var(--violet) 50%, var(--cyan));
  color: #fff;
  border: none;
  box-shadow: 0 12px 28px rgba(138, 92, 255, 0.22);
  padding: 12px 24px;
  font-weight: 800;
  font-size: 0.95rem;
}

.control-btn.export-shortcut:hover,
.control-btn.pdf-primary-action:hover,
.control-btn.export-primary-btn:hover {
  box-shadow: 0 16px 36px rgba(138, 92, 255, 0.28);
  transform: translateY(-2px);
}

/* ---------- Rows ---------- */
.row {
  display: flex;
  gap: 8px;
}
.row.wrap { flex-wrap: wrap; }
.row.two-up > * { flex: 1 1 calc(50% - 4px); }
.row.three-up > * { flex: 1 1 calc(33.33% - 6px); }
.row.two-up { align-items: flex-start; }

/* ---------- Upload box ---------- */
.upload-box {
  position: absolute;
  width: 340px;
  height: 130px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed rgba(91,140,255),.32);
  border-radius: 16px;
  color: #d8cbff;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  background: rgba(138, 92, 255, 0.06);
  z-index: 2;
  transition: all .2s ease;
  letter-spacing:.02em;
}

.upload-box:hover {
  border-color: var(--magenta);
  background: rgba(138, 92, 255, 0.10);
  box-shadow:0 0 0 4px rgba(138, 92, 255,.12);
}

.workspace.dragover .upload-box {
  border-color:#cdbfff;
  background: rgba(138, 92, 255, 0.16);
  box-shadow: 0 0 0 4px rgba(138, 92, 255, 0.24), 0 12px 32px rgba(138, 92, 255, 0.18);
}

/* ---------- Drag drop overlay ---------- */
.drag-drop-overlay{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(7,5,9,.88);
  backdrop-filter:blur(8px);
  z-index:4;
}

.drag-drop-overlay-card{
  min-width:min(90vw,380px);
  padding:30px 26px;
  border-radius:20px;
  border:1px solid rgba(212,179,94,.32);
  background:linear-gradient(180deg,rgba(26,22,32,.98),rgba(15,12,26,.96));
  box-shadow:0 28px 60px rgba(0,0,0,.42);
  text-align:center;
  color:#f8fafc;
}

.drag-drop-overlay-card strong{
  display:block;
  font-size:1.25rem;
  margin-bottom:10px;
  color:#f4e1a3;
  font-weight:900;
}

.drag-drop-overlay-card span{
  display:block;
  color:#a99fb8;
  font-size:.95rem;
}

/* ---------- Wizard bar ---------- */
.wizard-bar {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  margin-bottom:12px;
  padding:10px 12px;
  border:1px solid rgba(91,140,255),.22);
  border-radius:14px;
  background:linear-gradient(180deg, rgba(30,18,61,.95), rgba(20,12,41,.95));
  box-shadow:0 8px 20px rgba(0,0,0,.24);
}

#wizardStep {
  font-size:.82rem;
  font-weight:800;
  color:#f4edff;
  text-transform:uppercase;
  letter-spacing:.08em;
}

.safety-badge {
  font-size:.72rem;
  padding:5px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.08);
  color:#e9ddff;
  background:rgba(255,255,255,.04);
  font-weight:700;
}
.safety-badge.ok { background:rgba(27,127,70,.18); border-color:#1b7f46; color:#b8ffd6; }
.safety-badge.warn { background:rgba(167,95,42,.18); border-color:#a75d2a; color:#ffd9b0; }

/* ---------- Mode switcher ---------- */
.mode-switcher {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.mode-pill {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(138, 92, 255, 0.32);
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.mode-pill.active {
  background: linear-gradient(135deg, var(--magenta), var(--violet));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(138, 92, 255, 0.24);
}

.mode-pill:hover:not(.active) {
  border-color: rgba(138, 92, 255, 0.55);
  background: rgba(255, 255, 255, 0.05);
}

.mode-pill span {
  display: block;
  font-weight: 800;
  margin-bottom: 2px;
}
.mode-pill small {
  font-size: 0.7rem;
  opacity: 0.8;
}

/* ---------- Mini status ---------- */
.mini-status {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 6px 0;
}

/* ---------- Processing status ---------- */
.processing-status {
  margin-top: 14px;
  padding: 14px;
  border-radius: 12px;
  background: rgba(26, 22, 32, 0.90);
  border: 1px solid var(--line);
}

.processing-title {
  font-weight: 800;
  color: #fff;
  margin-bottom: 4px;
}

.processing-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
  margin: 8px 0;
}

.processing-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--magenta), var(--cyan));
  width: 0%;
  transition: width 0.3s ease;
}

/* ---------- Live preview card ---------- */
.live-preview-card {
  margin-top: 14px;
  padding: 16px;
  border-radius: 12px;
  background: rgba(26, 22, 32, 0.90);
  border: 1px solid var(--line);
}

.live-preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.preview-label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--magenta);
  margin-bottom: 8px;
}

.live-preview-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0a0d14;
}

/* ---------- Validation card ---------- */
.validation-card {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0f172a;
}

.validation-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.validation-card__header strong {
  color: #fff;
  font-size: 0.9rem;
}

.validation-list {
  display: grid;
  gap: 7px;
}

.validation-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.validation-item.idle { color: rgba(148, 163, 184, 0.5); }

.validation-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--magenta);
  box-shadow: 0 0 8px var(--magenta);
}

/* ---------- Export section ---------- */
.export-gate {
  margin-bottom: 12px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(220, 38, 38, 0.10);
  border: 1px solid rgba(220, 38, 38, 0.30);
  color: #fecaca;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.export-gate #exportGateMessage {
  flex: 1;
}

.export-status-card {
  margin-top: 10px;
  padding: 16px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(8, 24, 42, 0.95), rgba(7, 16, 32, 0.95));
  border: 1px solid var(--line);
  box-shadow: var(--glow);
}

.export-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.export-status-row span { color: var(--muted); }
.export-status-row strong { color: #fff; font-weight: 800; }

.export-requirements {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  font-size: 0.8rem;
}

.export-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #1b7f46;
  font-weight: 700;
}

.export-primary-flow {
  margin-top: 14px;
  padding: 14px;
  border-radius: 12px;
  background: rgba(26, 22, 32, 0.85);
  border: 1px solid var(--line);
}

.export-primary-card {
  margin-bottom: 12px;
}

.export-target-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.export-target-row .control-input {
  flex: 1;
  max-width: 120px;
}

.export-chip-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.export-chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(138, 92, 255, 0.32);
  background: rgba(255, 255, 255, 0.03);
  color: #e5edf8;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
}

.export-chip:hover {
  border-color: var(--magenta);
  background: rgba(138, 92, 255, 0.12);
  color: #fff;
}

.export-flow-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.6;
}

/* ---------- Advanced accordion ---------- */
.export-advanced-accordion summary {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--magenta);
  cursor: pointer;
  margin-top: 10px;
  padding: 8px 0;
}

.export-advanced-body {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(138, 92, 255, 0.12);
}

/* ---------- Compliance ---------- */
.compliance-empty {
  padding: 16px;
  text-align: center;
  color: rgba(148, 163, 184, 0.5);
  font-size: 0.85rem;
}

.compliance-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.compliance-foot {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.compliance-verdict {
  font-weight: 800;
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.compliance-verdict.ok { color: #1b7f46; }
.compliance-verdict.warn { color: #d97706; }
.compliance-verdict.bad { color: #dc2626; }

/* ---------- Toast ---------- */
.app-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 340px;
  background: linear-gradient(135deg, #08121f, #070a15);
  color: #efeaff;
  border: 1px solid rgba(138, 92, 255, 0.28);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 0.85rem;
  box-shadow: var(--glow-strong);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 9999;
  pointer-events: none;
  font-weight: 600;
}

.app-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Collapse toggle ---------- */
.collapse-toggle {
  position: absolute;
  top: 8px;
  z-index: 40;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all 0.2s;
}

.collapse-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(138, 92, 255, 0.28);
}

.collapse-toggle:focus-visible {
  outline: 2px solid #2be4ff;
  outline-offset: 2px;
}

.collapse-toggle--left { left: 8px; }
.collapse-toggle--right { right: 8px; }

/* ---------- Page thumbnail rail (left, never over the canvas) ---------- */
.workspace { --page-tray-w: 132px; }
body.tray-collapsed .workspace { --page-tray-w: 44px; }
.pages-tray.thumbnail-tray {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--page-tray-w);
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 8px 10px;
  background: linear-gradient(180deg, rgba(7, 16, 32, 0.98), rgba(4, 6, 14, 0.99));
  border-right: 1px solid rgba(91, 140, 255, 0.22);
  box-shadow: 8px 0 24px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}
.pages-tray.collapsed {
  width: 44px;
}
.pages-tray.collapsed .pages-list,
.pages-tray.collapsed .tray-export { display: none; }
.tray-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.pages-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  overflow-x: hidden;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  padding: 2px 2px 8px;
  scrollbar-width: auto;
  scrollbar-color: #5b8cff #0a1528;
}
.pages-list::-webkit-scrollbar { width: 10px; }
.pages-list::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #38d9f0, #5b8cff);
  border-radius: 8px;
}
.thumb-item {
  position: relative;
  flex: 0 0 96px;
  width: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: grab;
  color: #c9d6ef;
  font-size: 11px;
  text-align: center;
}
.thumb-item.active img,
.thumb-item.active .thumb-placeholder {
  border-color: #38d9f0;
  box-shadow: 0 0 0 1px rgba(56, 217, 240, 0.45);
}
.thumb-item img,
.thumb-placeholder {
  width: 88px;
  height: 88px;
  object-fit: contain;
  display: block;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #0b1220;
}
.thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8aa0c4;
  font-weight: 800;
}
.thumb-page-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #38d9f0;
  color: #04121a;
  font-size: 10px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.thumb-item span { max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb-actions { display: flex; gap: 3px; }
.thumb-actions button {
  min-width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: #fff;
  cursor: pointer;
  font-size: 11px;
}
.tray-export {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  flex: 0 0 auto;
}
.tray-export label { font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #8aa0c4; }
.tray-export select,
.tray-export button {
  height: 32px;
  width: 100%;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.12);
  background: #0b1220;
  color: #e8eefc;
  font-size: 11px;
}
.tray-export button {
  padding: 0 8px;
  background: linear-gradient(126deg, #1f9fd6, #3f6ef0);
  border: none;
  font-weight: 800;
  cursor: pointer;
}
.workspace .canvas-container {
  left: var(--page-tray-w) !important;
  right: 0 !important;
  top: 0 !important;
  bottom: 0 !important;
}
.pdf-page-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}
.pdf-page-thumb {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.12);
  background: #0b1220;
  display: block;
  flex: 0 0 52px;
}

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  .properties { width: 320px; }
  .live-preview-grid { grid-template-columns: 1fr; }
  .live-preview-card img { height: 120px; }
}

@media (max-width: 640px) {
  .properties {
    width: 100%;
    max-width: 100%;
    border-left: none;
    border-top: 1px solid var(--line);
  }
  .workspace { padding-bottom: 220px !important; }
  .live-preview-grid { grid-template-columns: 1fr; }
  .mode-switcher { flex-direction: column; }
  .upload-box { width: 90vw !important; height: auto !important; padding: 24px 16px !important; }
}

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