
:root {
  color-scheme: light;
  --bg: #f5f8ff;
  --surface: #ffffff;
  --surface-soft: #f0f5ff;
  --ink: #14213d;
  --muted: #687895;
  --line: #dfe7f5;
  --accent: #1769f5;
  --accent-strong: #0758e8;
  --accent-soft: #e8f0ff;
  --on-accent: #ffffff;
  --danger: #d83b55;
  --danger-soft: #fff0f2;
  --shadow: 0 12px 34px rgba(32,69,130,.08);
  --shadow-small: 0 4px 14px rgba(32,69,130,.07);
  --stage: #eaf0fa;
  --canvas-shadow: 0 10px 32px rgba(30,48,80,.14);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111923;
  --surface: #1a2633;
  --surface-soft: #202e3d;
  --ink: #edf4ff;
  --muted: #a1b1c5;
  --line: #304154;
  --accent: #68baff;
  --accent-strong: #8ac9ff;
  --accent-soft: #203d58;
  --on-accent: #071b2c;
  --danger: #ff8392;
  --danger-soft: #452934;
  --shadow: 0 12px 34px rgba(0,0,0,.18);
  --shadow-small: 0 4px 14px rgba(0,0,0,.16);
  --stage: #172330;
  --canvas-shadow: 0 10px 32px rgba(0,0,0,.35);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 Inter, ui-sans-serif, system-ui, sans-serif;
  transition: background .2s, color .2s;
}

button, input, select {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* HEADER */

.topbar {
  height: 68px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 1180px;
  height: 100%;
  padding: 0 28px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  border: 0;
  background: none;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 1.18rem;
  font-weight: 800;
  letter-spacing: -.04em;
  cursor: pointer;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(145deg,#4caaff,#1262ee);
  display: grid;
  place-items: center;
  color: white;
  font-size: 23px;
  box-shadow: 0 5px 12px rgba(23,105,245,.2);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 22px;
}

.privacy-note {
  font-size: .83rem;
  color: var(--muted);
}

.theme-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 13px;
  display: flex;
  gap: 8px;
  align-items: center;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 650;
}

.theme-toggle:hover {
  background: var(--surface-soft);
}

.theme-icon {
  font-size: 1.1rem;
  color: var(--accent);
}

/* COMMON */

.home-view,
.editor-view {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 28px;
}

h1, h2, h3, p {
  margin-top: 0;
}

.eyebrow,
.section-kicker {
  font-size: .72rem;
  letter-spacing: .14em;
  font-weight: 800;
  color: var(--accent);
}

/* HOME HERO */

.hero {
  min-height: 340px;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  align-items: center;
  padding: 44px 7% 34px;
  background: radial-gradient(
    ellipse at 80% 35%,
    var(--accent-soft),
    transparent 48%
  );
  border-radius: 0 0 28px 28px;
}

.hero-copy {
  max-width: 560px;
}

.hero h1 {
  font-size: clamp(2.35rem,5vw,3.65rem);
  line-height: 1.08;
  letter-spacing: -.065em;
  margin: 15px 0 16px;
  font-weight: 820;
}

.hero h1 span {
  color: var(--accent);
}

.hero-copy > p {
  max-width: 490px;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.75;
  margin: 0;
}

/* DOCUMENT ILLUSTRATION */

.hero-art {
  height: 260px;
  position: relative;
  display: grid;
  place-items: center;
}

.art-glow {
  width: 240px;
  height: 200px;
  background: var(--accent-soft);
  border-radius: 48%;
  filter: blur(2px);
  position: absolute;
}

.paper {
  position: absolute;
  width: 142px;
  height: 184px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.paper-back {
  transform: rotate(11deg) translate(17px,1px);
  background: var(--surface-soft);
}

.paper-front {
  transform: rotate(-7deg);
  padding: 45px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.paper-front i {
  height: 7px;
  border-radius: 10px;
  background: var(--line);
  width: 100%;
}

.paper-front i:nth-of-type(2) {
  width: 82%;
}

.paper-front i:nth-of-type(3) {
  width: 68%;
}

.paper-front b {
  width: 48px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(120deg,#5daeff,#1769f5);
  margin-top: 4px;
}

.paper-fold {
  position: absolute;
  right: 0;
  top: 0;
  border-style: solid;
  border-width: 0 35px 35px 0;
  border-color: transparent var(--accent-soft) transparent transparent;
}

.art-spark {
  position: absolute;
  color: var(--accent);
  font-size: 2rem;
}

.spark-one {
  top: 26px;
  right: 25%;
}

.spark-two {
  bottom: 32px;
  left: 22%;
  font-size: 1.5rem;
}

.art-chip {
  position: absolute;
  bottom: 18px;
  right: 15%;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-small);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  color: var(--accent);
}

/* TOOL CARDS */

.start-section {
  padding: 34px 4% 10px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.section-heading h2 {
  font-size: 1.55rem;
  letter-spacing: -.04em;
  margin: 5px 0 0;
}

.section-hint {
  font-size: .85rem;
  color: var(--muted);
  padding-bottom: 4px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 14px;
}

.tile {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 17px;
  text-align: left;
  padding: 19px;
  min-height: 154px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 48px 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  align-content: start;
  box-shadow: var(--shadow-small);
  transition: transform .18s, border-color .18s, box-shadow .18s;
}

.tile:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.ico {
  grid-row: 1/3;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.35rem;
  font-weight: 700;
}

.tile b {
  font-size: 1rem;
  align-self: end;
  margin: 1px 0 4px;
  letter-spacing: -.02em;
}

.tile span:not(.ico) {
  font-size: .84rem;
  color: var(--muted);
  line-height: 1.5;
}

/* BENEFITS */

.trust-row {
  margin: 32px 4% 22px;
  padding: 19px 24px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 17px;
  display: flex;
  justify-content: space-around;
  gap: 18px;
  box-shadow: var(--shadow-small);
}

.trust-item {
  display: flex;
  align-items: center;
  gap: 11px;
}

.trust-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
}

.trust-item b,
.trust-item small {
  display: block;
}

.trust-item b {
  font-size: .84rem;
}

.trust-item small {
  font-size: .75rem;
  color: var(--muted);
}

.home-footer {
  text-align: center;
  color: var(--muted);
  font-size: .78rem;
  padding: 0 0 26px;
}

/* EDITOR */

.editor-view {
  padding-top: 20px;
  padding-bottom: 48px;
}

.editor-heading {
  margin-bottom: 18px;
}

.back-link {
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  padding: 6px 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.button-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.editor-title h1 {
  font-size: 1.8rem;
  letter-spacing: -.05em;
  margin: 3px 0 2px;
}

.editor-title p {
  color: var(--muted);
  margin: 0;
  font-size: .9rem;
}

/* UPLOAD */

.upload-panel {
  min-height: 370px;
  border: 2px dashed var(--line);
  border-radius: 22px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  padding: 38px 18px;
  box-shadow: var(--shadow-small);
}

.upload-panel.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-illustration {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 2rem;
  margin-bottom: 16px;
}

.upload-panel h2 {
  font-size: 1.25rem;
  margin: 0 0 6px;
}

.upload-panel p {
  color: var(--muted);
  margin: 0 0 20px;
}

.upload-footnote {
  font-size: .76rem;
  color: var(--muted);
  margin-top: 13px;
}

/* BUTTONS */

.btn {
  min-height: 42px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0 15px;
  border-radius: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-weight: 650;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 750;
}

.btn.primary:hover {
  background: var(--accent-strong);
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* WORKSPACE */

.workspace {
  display: grid;
  grid-template-columns: 205px minmax(280px,1fr) 250px;
  gap: 16px;
  align-items: start;
}

.pane {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 17px;
  padding: 15px;
  box-shadow: var(--shadow-small);
}

.page-pane {
  min-height: 450px;
}

.pane-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.pane-heading h2,
.export-heading h2 {
  font-size: 1rem;
  margin: 0 0 2px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: .75rem;
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1.2rem;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-button:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.add-page {
  color: var(--accent);
  font-size: 1.4rem;
}

.page-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  max-height: 570px;
  overflow: auto;
  padding: 2px;
}

.card {
  position: relative;
  border: 2px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
  padding: 7px;
  cursor: pointer;
  min-width: 0;
}

.card.sel {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.card canvas {
  display: block;
  width: 100%;
  height: 132px;
  object-fit: contain;
  background: #fff;
  border-radius: 5px;
}

.no {
  position: absolute;
  left: 12px;
  top: 12px;
  min-width: 23px;
  padding: 1px 7px;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  font-size: .72rem;
  font-weight: 800;
}

.add-page-wide {
  width: 100%;
  margin-top: 12px;
  min-height: 39px;
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--accent);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
}

/* PREVIEW */

.preview-column {
  min-width: 0;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 3px 11px;
}

.preview-label {
  font-size: .69rem;
  font-weight: 800;
  letter-spacing: .12em;
  color: var(--muted);
}

.preview-page-label {
  font-size: .76rem;
  color: var(--muted);
}

.preview-stage {
  min-height: 450px;
  padding: 24px;
  background: var(--stage);
  border: 1px solid var(--line);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#previewCanvas {
  display: block;
  max-width: 100%;
  max-height: 650px;
  width: auto;
  height: auto;
  object-fit: contain;
  background: white;
  box-shadow: var(--canvas-shadow);
}

/* NAVIGATION */

.preview-navigation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 17px;
  padding: 14px;
  color: var(--muted);
  font-size: .85rem;
}

.preview-navigation .icon-button {
  border-radius: 50%;
}

/* EDITING TOOLS */

.settings-pane {
  position: sticky;
  top: 84px;
}

.tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 14px;
}

.tool-action {
  min-height: 76px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  font-size: .77rem;
  font-weight: 650;
}

.tool-action:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.action-icon {
  font-size: 1.35rem;
  color: var(--accent);
}

.tool-action.delete-action {
  grid-column: 1/-1;
  min-height: 43px;
  flex-direction: row;
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

.delete-action .action-icon {
  color: var(--danger);
}

.settings-divider {
  height: 1px;
  background: var(--line);
  margin: 18px 0;
}

/* EXPORT */

.export-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.export-lock {
  font-size: .68rem;
  font-weight: 750;
  color: #159b70;
  background: rgba(39,184,135,.12);
  padding: 4px 8px;
  border-radius: 999px;
}

.field-label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.field-control {
  width: 100%;
  height: 43px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--ink);
}

.quality-label {
  display: flex;
  justify-content: space-between;
  margin: 16px 0 5px;
  font-size: .78rem;
  font-weight: 700;
}

.quality-label b {
  color: var(--accent);
}

.quality-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.quality-help {
  font-size: .72rem;
  color: var(--muted);
  margin: 1px 0 17px;
}

.save-button {
  width: 100%;
  min-height: 48px;
}

/* CROP DIALOG */

.crop-dialog {
  width: min(94vw,760px);
  max-height: 90vh;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.crop-dialog::backdrop {
  background: rgba(4,12,25,.65);
  backdrop-filter: blur(3px);
}

.dialog-heading h2 {
  font-size: 1.1rem;
  margin: 0;
}

.dialog-heading p {
  font-size: .82rem;
  color: var(--muted);
  margin: 2px 0 12px;
}

.crop {
  height: 58vh;
  margin-bottom: 14px;
}

.crop img {
  display: block;
  max-width: 100%;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

/* NOTIFICATIONS */

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%,18px);
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--ink);
  color: var(--bg);
  padding: 11px 17px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  z-index: 30;
  box-shadow: var(--shadow);
  transition: opacity .18s, transform .18s;
  max-width: calc(100vw - 30px);
}

#toast.show {
  opacity: 1;
  transform: translate(-50%,0);
  pointer-events: auto;
}

#toast button {
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  font-weight: 800;
  text-decoration: underline;
  cursor: pointer;
}

/* TABLET */

@media(max-width:980px) {
  .workspace {
    grid-template-columns: 180px minmax(0,1fr);
  }

  .settings-pane {
    position: static;
    grid-column: 1/-1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 22px;
  }

  .settings-pane > .pane-heading {
    grid-column: 1/-1;
  }

  .settings-divider {
    display: none;
  }

  .tools {
    margin-top: 0;
  }
}

/* MOBILE */

@media(max-width:680px) {
  .topbar {
    height: 60px;
  }

  .topbar-inner {
    padding: 0 16px;
  }

  .privacy-note,
  .theme-label {
    display: none;
  }

  .theme-toggle {
    width: 38px;
    height: 38px;
    justify-content: center;
    padding: 0;
  }

  .home-view,
  .editor-view {
    padding-left: 16px;
    padding-right: 16px;
  }

  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 42px 10px 12px;
    text-align: center;
  }

  .hero-copy {
    margin: auto;
  }

  .hero-copy > p {
    font-size: .94rem;
  }

  .hero-art {
    height: 205px;
  }

  .hero h1 {
    font-size: 2.55rem;
  }

  .start-section {
    padding: 25px 0 8px;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
    gap: 4px;
  }

  .section-heading h2 {
    font-size: 1.35rem;
  }

  .tool-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .tile {
    padding: 14px;
    min-height: 152px;
    grid-template-columns: 40px 1fr;
    column-gap: 10px;
  }

  .ico {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    font-size: 1.1rem;
  }

  .tile b {
    font-size: .9rem;
  }

  .tile span:not(.ico) {
    font-size: .76rem;
  }

  .trust-row {
    margin: 22px 0 17px;
    padding: 14px 10px;
    gap: 8px;
  }

  .trust-item {
    gap: 7px;
  }

  .trust-icon {
    width: 30px;
    height: 30px;
    font-size: .95rem;
  }

  .trust-item b {
    font-size: .72rem;
  }

  .trust-item small {
    font-size: .65rem;
  }

  .editor-view {
    padding-top: 12px;
  }

  .editor-title h1 {
    font-size: 1.55rem;
  }

  .editor-title p {
    font-size: .82rem;
  }

  .upload-panel {
    min-height: 330px;
    padding: 25px 16px;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .page-pane {
    min-height: 0;
    order: 1;
  }

  .page-list {
    display: flex;
    max-height: none;
    overflow-x: auto;
    padding-bottom: 5px;
  }

  .card {
    flex: 0 0 100px;
  }

  .card canvas {
    height: 112px;
  }

  .add-page-wide {
    display: none;
  }

  .preview-column {
    order: 2;
  }

  .preview-stage {
    min-height: 340px;
    padding: 12px;
  }

  .settings-pane {
    order: 3;
    grid-column: auto;
    display: block;
  }

  .settings-divider {
    display: block;
    margin: 17px 0;
  }

  .tools {
    margin-top: 12px;
  }

  .save-button {
    position: sticky;
    bottom: 10px;
    box-shadow: 0 6px 20px rgba(23,105,245,.2);
  }

  .crop {
    height: 52vh;
  }
}

@media(max-width:390px) {
  .tool-grid {
    grid-template-columns: 1fr;
  }

  .tile {
    min-height: 105px;
    grid-template-columns: 44px 1fr;
  }

  .trust-item small {
    display: none;
  }
}


/* =====================================
   FIX 1: PAGE NAVIGATION ARROW ALIGNMENT
===================================== */

.preview-navigation .icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  padding: 0;
  line-height: 1;
  font-family: Arial, sans-serif;
  font-size: 21px;
  font-weight: 500;
  box-sizing: border-box;
}

.preview-navigation .icon-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}


/* =====================================
   FIX 2: PROPER TRASH ICON
===================================== */

.trash-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 20px;
}


/* =====================================
   FIX 3: FORMAT DROPDOWN ALIGNMENT
===================================== */

.format-field {
  position: relative;
  width: 100%;
  min-width: 0;
}

.format-field::after {
  content: "";
  position: absolute;
  right: 15px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

/* Hide arrow when only one format exists */
.format-field.is-fixed::after {
  display: none;
}

.field-control {
  display: block;
  width: 100%;
  height: 44px;
  min-width: 0;
  box-sizing: border-box;

  appearance: none;
  -webkit-appearance: none;

  padding: 0 42px 0 12px;

  border: 1px solid var(--line);
  border-radius: 10px;

  background: var(--surface-soft);
  color: var(--ink);

  line-height: normal;
  cursor: pointer;
}

.field-control:disabled {
  opacity: 1;
  cursor: default;
}

/* Tablet layout: keep dropdown in the correct column */
@media (min-width: 681px) and (max-width: 980px) {
  .field-label,
  .format-field,
  .quality-label,
  .quality-slider,
  .quality-help,
  .save-button {
    grid-column: 2;
  }
}


/* RESET, REORDER, NOTICES */

.tool-action.reset-action {
  grid-column: 1/-1;
  min-height: 43px;
  flex-direction: row;
}

.tool-action:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.tool-action:disabled:hover {
  border-color: var(--line);
  background: var(--surface-soft);
}

.card {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.card.dragging {
  opacity: .5;
  cursor: grabbing;
}

.card.drop-target {
  border-color: var(--accent);
  border-style: dashed;
  background: var(--accent-soft);
}

.raster-note {
  margin: -6px 0 12px;
}

/* ===== Toolkit additions ===== */
.tool-search { width: 100%; max-width: 520px; margin: 4px 0 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: .9rem; }
.chip.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.chip-edit { border-style: dashed; color: var(--muted); }
.group-title { margin: 22px 0 10px; font-size: 1.02rem; color: var(--muted); font-weight: 700; letter-spacing: .02em; }
.empty-state { text-align: center; padding: 48px 12px; color: var(--muted); }
.empty-state h2 { color: var(--ink); }

.gen-layout { display: grid; grid-template-columns: minmax(0,1fr) 320px; gap: 22px; align-items: start; }
@media (max-width: 860px) { .gen-layout { grid-template-columns: 1fr; } }
.gen-drop { cursor: pointer; }
.gen-drop-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.gen-files, .gen-results { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow-small); }
.file-list { list-style: none; margin: 8px 0 0; padding: 0; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.file-row:first-child { border-top: 0; }
.file-thumb { width: 44px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: var(--surface-soft); flex: none; }
.file-thumb-empty { display: grid; place-items: center; font-size: .7rem; font-weight: 700; color: var(--muted); }
.file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-meta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta small, .muted { color: var(--muted); }
.file-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.small-btn { padding: 6px 12px; font-size: .85rem; min-height: 0; }
.gen-opts { display: flex; flex-direction: column; gap: 14px; margin: 14px 0; }
.opt { display: flex; flex-direction: column; gap: 6px; }
.opt label { display: flex; justify-content: space-between; font-weight: 600; font-size: .9rem; }
.opt-check { flex-direction: row; align-items: center; gap: 8px; font-weight: 600; flex-wrap: wrap; }
.opt-help { color: var(--muted); font-weight: 400; }
.gen-progress .bar { height: 8px; background: var(--surface-soft); border-radius: 99px; overflow: hidden; margin-bottom: 6px; }
.gen-progress .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.gen-error { background: var(--danger-soft); color: var(--danger); border-radius: 12px; padding: 10px 12px; margin: 10px 0; }
.result-head { display: flex; gap: 12px; align-items: center; }
.result-head h2 { margin: 0; font-size: 1.1rem; }
.result-tick { width: 36px; height: 36px; border-radius: 50%; background: #3a9d5d; color: #fff; display: grid; place-items: center; font-weight: 800; }
.result-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.result-text { width: 100%; margin-top: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-soft); color: var(--ink); padding: 10px; font: inherit; resize: vertical; }
.save-button + .save-button { margin-top: 8px; }
#gCancel { margin-top: 8px; width: 100%; }

.lib-toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.lib-search { flex: 1; min-width: 200px; }
.lib-h { font-size: 1.05rem; margin: 26px 0 6px; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.doc-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 10px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow-small); }
.doc-thumb { border: 0; background: var(--stage); border-radius: 10px; height: 150px; display: grid; place-items: center; overflow: hidden; cursor: pointer; font-weight: 700; color: var(--muted); }
.doc-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.doc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-actions { display: flex; gap: 6px; margin-top: 6px; justify-content: space-between; }
.usage { margin-top: 10px; }
.link-btn { background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 0; }
#libDlg { max-width: min(560px, 94vw); }
.pv-stage { max-height: 60vh; overflow: auto; display: grid; place-items: center; padding: 10px; border-radius: 12px; }
.pv-stage canvas { max-width: 100%; height: auto; box-shadow: var(--canvas-shadow); }
.menu-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.danger-text, .btn.danger { color: var(--danger); }
.name-form .field-control { width: 100%; }
.lib-pick { max-height: 50vh; overflow: auto; }
.pick-row { display: flex; gap: 12px; align-items: center; width: 100%; cursor: pointer; }
@media (max-width: 640px) { .top-actions .theme-label { display: none; } .privacy-note { display: none; } }

/* ===== PDF editor ===== */
.annot-bar { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.annot-tools { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.atool { flex: none; min-width: 64px; border: 1px solid var(--line); background: var(--surface-soft); border-radius: 12px; padding: 6px 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 0; }
.atool span { font-size: 1.15rem; line-height: 1.3; }
.atool small { font-size: .7rem; color: var(--muted); }
.atool.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.atool.on small { color: var(--on-accent); }
.annot-opts { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.annot-opt { display: flex; align-items: center; gap: 6px; font-size: .9rem; font-weight: 600; }
.annot-opt input[type=color] { width: 34px; height: 30px; border: 1px solid var(--line); border-radius: 8px; padding: 0; background: none; }
.annot-stage { margin: 12px 0; background: var(--stage); border-radius: 16px; padding: 12px; overflow: auto; display: flex; justify-content: center; max-height: 72vh; }
.annot-page { position: relative; box-shadow: var(--canvas-shadow); background: #fff; line-height: 0; }
.annot-page canvas { display: block; }
#annotOver { position: absolute; inset: 0; touch-action: pan-y; }
.annot-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.annot-save { display: flex; gap: 8px; }

.scan-stage { display: grid; place-items: center; background: var(--stage); border-radius: 12px; padding: 10px; }
#scanCanvas { max-width: 100%; touch-action: none; cursor: crosshair; }
.scan-controls { display: flex; gap: 12px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.scan-filter { display: flex; gap: 8px; align-items: center; font-weight: 600; }

.lib-deep { align-self: center; }
