/* ==========================================================================
   md.achraf.tn
   1. Tokens   2. Base   3. Controls   4. App shell   5. Panes
   6. Document (shared by preview and PDF export)   7. Overlays   8. Responsive
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  color-scheme: dark;
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --bg: #0a0a0a;
  --surface: #0f0f10;
  --elevated: #161617;
  --desk: #0c0c0d;
  --hover: rgb(255 255 255 / 0.06);
  --pressed: rgb(255 255 255 / 0.1);
  --line: rgb(255 255 255 / 0.08);
  --line-strong: rgb(255 255 255 / 0.14);
  --text: #fafafa;
  --text-2: rgb(250 250 250 / 0.68);
  --text-3: rgb(250 250 250 / 0.48);
  --ink: #fafafa;
  --on-ink: #0a0a0a;
  --accent: #8b5cf6;
  --accent-text: #b8a1ff;
  --accent-soft: rgb(139 92 246 / 0.2);
  --glow: rgb(139 92 246 / 0.1);
  --success: #4ade80;
  --danger: #f87171;

  --shadow-paper: 0 1px 2px rgb(0 0 0 / 0.5), 0 24px 64px -16px rgb(0 0 0 / 0.7);
  --shadow-pop: 0 16px 48px -12px rgb(0 0 0 / 0.7);
  --radius: 14px;
  --radius-sm: 9px;
  --bar-h: 60px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme='light'] {
  color-scheme: light;
  --bg: #f5f5f6;
  --surface: #ffffff;
  --elevated: #ffffff;
  --desk: #ebebed;
  --hover: rgb(0 0 0 / 0.05);
  --pressed: rgb(0 0 0 / 0.08);
  --line: rgb(0 0 0 / 0.08);
  --line-strong: rgb(0 0 0 / 0.14);
  --text: #0a0a0a;
  --text-2: rgb(10 10 10 / 0.68);
  --text-3: rgb(10 10 10 / 0.54);
  --ink: #0a0a0a;
  --on-ink: #fafafa;
  --accent: #7c3aed;
  --accent-text: #6d28d9;
  --accent-soft: rgb(124 58 237 / 0.14);
  --glow: rgb(139 92 246 / 0.12);
  --success: #15803d;
  --danger: #dc2626;
  --shadow-paper: 0 1px 2px rgb(0 0 0 / 0.06), 0 20px 48px -20px rgb(0 0 0 / 0.22);
  --shadow-pop: 0 16px 48px -16px rgb(0 0 0 / 0.25);
}

/* 2. Base ------------------------------------------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  font: 400 14px/1.5 var(--font-sans);
  color: var(--text);
  background: radial-gradient(ellipse 80% 50% at 50% 0%, var(--glow), transparent), var(--bg);
  -webkit-font-smoothing: antialiased;
}

body:has(> .app) {
  overflow: hidden;
}

::selection {
  background: var(--accent-soft);
}

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

* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.i {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 3. Controls -------------------------------------------------------------- */
.btn,
.icon-btn,
.seg button,
.switch {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  border-radius: 10px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s, color 0.2s;
}

.btn--primary {
  background: var(--ink);
  color: var(--on-ink);
}

.btn--primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px -6px color-mix(in srgb, var(--ink) 45%, transparent);
}

.btn--primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn--ghost {
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--text);
}

.btn--ghost:hover {
  background: var(--hover);
}

.btn--link {
  height: auto;
  padding: 4px 6px;
  color: var(--text-2);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 4px;
}

.btn--link:hover {
  color: var(--text);
  text-decoration-color: currentColor;
}

.btn--danger:hover,
.btn--danger[data-confirm] {
  color: var(--danger);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover,
.icon-btn:popover-open,
.icon-btn[aria-expanded='true'] {
  background: var(--hover);
  color: var(--text);
}

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

.icon-btn--sm {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.icon-btn--sm .i {
  width: 16px;
  height: 16px;
}

/* Segmented control */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 11px;
  background: var(--hover);
  box-shadow: inset 0 0 0 1px var(--line);
}

.seg button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  transition: color 0.15s, background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.seg button:hover {
  color: var(--text);
}

.seg button[aria-pressed='true'] {
  color: var(--text);
  background: var(--elevated);
  box-shadow: 0 0 0 1px var(--line-strong), 0 1px 3px rgb(0 0 0 / 0.2);
}

.seg--sm button {
  height: 26px;
  padding: 0 10px;
  font-size: 12.5px;
}

/* Switch */
.switch {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 99px;
  background: var(--line-strong);
  transition: background 0.2s var(--ease);
}

.switch::after {
  content: '';
  position: absolute;
  inset: 2px auto 2px 2px;
  width: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.3);
  transition: transform 0.25s var(--ease);
}

.switch[aria-checked='true'] {
  background: var(--accent);
}

.switch[aria-checked='true']::after {
  transform: translateX(14px);
}

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 5px;
  border-radius: 5px;
  font: 500 11.5px/1.5 var(--font-mono);
  text-align: center;
  color: var(--text);
  background: var(--hover);
  box-shadow: inset 0 0 0 1px var(--line-strong), inset 0 -1px 0 var(--line-strong);
}

/* 4. App shell ------------------------------------------------------------- */
.app {
  display: grid;
  grid-template-rows: var(--bar-h) 1fr;
  height: 100dvh;
  padding: 0 12px 12px;
}

.bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 4px 0 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  transition: transform 0.6s var(--ease);
}

.brand:hover img {
  transform: rotate(-24deg) scale(1.08);
}

.seg--views {
  position: absolute;
  left: 50%;
  translate: -50% 0;
}

.bar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.bar-actions .btn {
  margin-left: 6px;
  min-width: 128px;
}

#export-btn[data-state='busy'] .i {
  animation: spin 0.9s linear infinite;
}

#export-btn[data-state='done'] {
  background: var(--success);
  color: #fff;
}

#export-btn:disabled {
  cursor: progress;
}

@keyframes spin {
  to {
    rotate: 360deg;
  }
}

/* 5. Panes ----------------------------------------------------------------- */
.workspace {
  display: flex;
  min-height: 0;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), 0 24px 60px -30px rgb(0 0 0 / 0.5);
  overflow: hidden;
}

.pane {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.pane--editor {
  flex: 0 0 var(--split, 50%);
  min-width: 300px;
}

.pane--preview {
  flex: 1;
  min-width: 340px;
  background: radial-gradient(ellipse 70% 38% at 50% 0%, var(--glow), transparent), var(--desk);
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 44px;
  flex: none;
  padding: 0 8px 0 20px;
  border-bottom: 1px solid var(--line);
}

.pane-title {
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  text-overflow: ellipsis;
  white-space: nowrap;
}

#doc-name {
  font-family: var(--font-mono);
  font-size: 12px;
}

.pane-tools {
  display: flex;
  gap: 2px;
}

.chip {
  flex: none;
  margin-right: 12px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-3);
  box-shadow: inset 0 0 0 1px var(--line);
  font-variant-numeric: tabular-nums;
}

/* Editor */
.editor {
  position: relative;
  flex: 1;
  min-height: 0;
}

#md-input {
  display: block;
  width: 100%;
  height: 100%;
  padding: 24px max(24px, calc((100% - 84ch) / 2));
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--text);
  caret-color: var(--accent);
  font: 400 13.5px/1.75 var(--font-mono);
  tab-size: 2;
}

.status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 34px;
  flex: none;
  padding: 0 20px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.status-local {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-local .i {
  width: 14px;
  height: 14px;
}

/* Empty state: echoes the original hero; clicks fall through to the textarea */
.empty {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  padding: 32px clamp(24px, 7%, 64px);
  pointer-events: none;
}

.workspace[data-empty] .empty {
  display: flex;
  animation: rise 0.7s var(--ease) both;
}

.empty-title {
  max-width: 13ch;
  margin: 0;
  font-size: clamp(30px, 4.2vw, 52px);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.empty-title img {
  width: 1.05em;
  height: auto;
  vertical-align: -0.16em;
  margin: 0 0.04em;
}

.empty-text {
  max-width: 46ch;
  margin: 0;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-2);
  text-wrap: pretty;
}

.empty-text code {
  font: 500 0.9em var(--font-mono);
  color: var(--text);
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  pointer-events: auto;
}

@keyframes rise {
  from {
    opacity: 0;
    translate: 0 8px;
  }
}

/* Resizer */
.resizer {
  position: relative;
  flex: 0 0 1px;
  background: var(--line);
  cursor: col-resize;
  touch-action: none;
  outline: 0;
}

.resizer::before {
  content: '';
  position: absolute;
  inset: 0 -5px;
  z-index: 2;
}

.resizer::after {
  content: '';
  position: absolute;
  inset: 0 -1px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.2s;
}

.resizer:hover::after,
.resizer:focus-visible::after,
.workspace[data-resizing] .resizer::after {
  opacity: 1;
}

.workspace[data-resizing] {
  cursor: col-resize;
  user-select: none;
}

/* Preview desk and paper */
.desk {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 32px 28px 56px;
  container-type: inline-size;
}

.paper {
  width: min(100%, 210mm);
  aspect-ratio: 210 / 297;
  margin: 0 auto;
  padding: clamp(18px, 7.14cqw, 15mm);
  border-radius: 3px;
  background: #fff;
  box-shadow: var(--shadow-paper);
}

.paper-empty {
  display: none;
  margin: 0;
  padding: 20px;
  font-size: 14px;
  color: #8a8f98;
}

.workspace[data-empty] .paper-empty {
  display: block;
}

/* The one authored moment: a light band sweeps the sheet while exporting */
.scan {
  position: absolute;
  inset: 45px 0 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.scan::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 160px;
  background: linear-gradient(to bottom, transparent, var(--glow) 70%, rgb(139 92 246 / 0.28) 99%, var(--accent));
  translate: 0 -160px;
}

.workspace[data-printing] .scan {
  opacity: 1;
}

.workspace[data-printing] .scan::before {
  animation: sweep 1.5s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

@keyframes sweep {
  to {
    translate: 0 100cqh;
  }
}

.pane--preview {
  container-type: size;
}

/* Views */
.workspace[data-view='write'] :is(.pane--preview, .resizer),
.workspace[data-view='preview'] :is(.pane--editor, .resizer) {
  display: none;
}

.workspace[data-view='write'] .pane--editor {
  flex: 1;
}

/* 6. Document (shared by preview and PDF export) --------------------------- */
/* html2pdf clones #preview, so rules here also shape the exported PDF.      */
#preview {
  padding: 20px;
  font-size: 14px;
  line-height: 1.6;
}

#preview:empty {
  display: none;
}

#preview :is(h1, h2, h3, h4, h5, h6) {
  margin-top: 24px;
  margin-bottom: 12px;
  padding-top: 8px;
}

.workspace[data-density='compact'] #preview {
  font-size: 13px;
  line-height: 1.5;
}

.workspace[data-density='compact'] #preview :is(p, li) {
  margin-bottom: 0.5em;
}

.workspace[data-density='compact'] #preview :is(h1, h2, h3, h4, h5, h6) {
  margin-top: 1em;
  margin-bottom: 0.5em;
}

.markdown-body {
  color: #24292f;
}

.markdown-body :is(h1, h2, h3, h4) {
  color: #24292f;
}

.markdown-body :is(code, pre) {
  border-radius: 10px;
}

.katex-display {
  margin: 1.2em 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 0;
}

.katex {
  font-size: 1.1em !important;
}

/* 7. Overlays -------------------------------------------------------------- */
.popover {
  inset: calc(var(--bar-h) - 4px) 16px auto auto;
  width: 320px;
  margin: 0;
  padding: 6px;
  border: 0;
  border-radius: var(--radius);
  color: var(--text);
  background: var(--elevated);
  box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-pop);
  opacity: 0;
  translate: 0 -6px;
  transition: opacity 0.2s var(--ease), translate 0.3s var(--ease), display 0.2s allow-discrete, overlay 0.2s allow-discrete;
}

.popover:popover-open {
  opacity: 1;
  translate: 0;
}

@starting-style {
  .popover:popover-open {
    opacity: 0;
    translate: 0 -6px;
  }
}

.option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 0 10px;
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
}

.popover-foot {
  margin-top: 6px;
  padding: 12px 10px 6px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-3);
}

.popover-foot p {
  margin: 0 0 10px;
  line-height: 1.5;
}

.popover-foot nav {
  display: flex;
  gap: 16px;
}

.popover-foot a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-2);
  text-decoration: none;
}

.popover-foot a:hover {
  color: var(--text);
}

.popover-foot .i {
  width: 13px;
  height: 13px;
}

/* History drawer */
.drawer {
  width: min(400px, 100vw);
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  color: var(--text);
  background: var(--elevated);
  box-shadow: -1px 0 0 var(--line-strong), var(--shadow-pop);
  translate: 100% 0;
  transition: translate 0.35s var(--ease), display 0.35s allow-discrete, overlay 0.35s allow-discrete;
}

.drawer[open] {
  translate: 0;
}

.drawer::backdrop {
  background: rgb(0 0 0 / 0);
  transition: background 0.35s, display 0.35s allow-discrete, overlay 0.35s allow-discrete;
}

.drawer[open]::backdrop {
  background: rgb(0 0 0 / 0.45);
}

@starting-style {
  .drawer[open] {
    translate: 100% 0;
  }

  .drawer[open]::backdrop {
    background: rgb(0 0 0 / 0);
  }
}

.drawer-body {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 10px 20px;
}

.drawer-head h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.count {
  padding: 1px 8px;
  border-radius: 99px;
  font-size: 12px;
  color: var(--text-3);
  background: var(--hover);
  font-variant-numeric: tabular-nums;
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 16px 8px;
  padding: 0 12px;
  height: 38px;
  border-radius: 10px;
  color: var(--text-3);
  background: var(--hover);
  box-shadow: inset 0 0 0 1px var(--line);
}

.search:focus-within {
  box-shadow: inset 0 0 0 1px var(--accent);
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  color: var(--text);
  font: inherit;
}

.search input::placeholder {
  color: var(--text-3);
}

.history-list {
  flex: 1;
  margin: 0;
  padding: 4px 8px 12px;
  overflow: auto;
  list-style: none;
}

.history-item {
  position: relative;
  border-radius: 10px;
}

.history-item:hover,
.history-item:focus-within {
  background: var(--hover);
}

.history-open {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 12px 48px 12px 12px;
  border: 0;
  border-radius: inherit;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.history-open > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-title {
  font-weight: 500;
}

.history-excerpt {
  font-size: 13px;
  color: var(--text-2);
}

.history-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.history-item.is-current .history-meta::after {
  content: 'Open';
  padding: 0 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-text);
  background: var(--accent-soft);
}

.history-delete {
  position: absolute;
  top: 10px;
  right: 8px;
  opacity: 0;
}

.history-item:hover .history-delete,
.history-delete:focus-visible {
  opacity: 1;
}

@media (hover: none) {
  .history-delete {
    opacity: 1;
  }
}

.history-delete:hover {
  color: var(--danger);
}

.versions {
  padding: 0 12px 10px;
}

.versions summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: -4px;
  padding: 2px 8px 2px 2px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  list-style: none;
  cursor: pointer;
}

.versions summary::-webkit-details-marker {
  display: none;
}

.versions summary:hover {
  color: var(--text);
  background: var(--hover);
}

.versions summary .i {
  width: 14px;
  height: 14px;
  transition: rotate 0.25s var(--ease);
}

.versions[open] summary .i {
  rotate: 90deg;
}

.versions ol {
  margin: 6px 0 0 3px;
  padding: 0 0 0 9px;
  border-left: 1px solid var(--line-strong);
  list-style: none;
}

.version {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  text-align: left;
  cursor: pointer;
}

.version:hover {
  color: var(--text);
  background: var(--hover);
}

.version-time {
  flex: 1;
}

.version.is-current .version-time::after {
  content: 'Current';
  margin-left: 8px;
  padding: 0 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-text);
  background: var(--accent-soft);
}

.delta {
  min-width: 5ch;
  text-align: right;
  color: var(--text-3);
}

.delta.up {
  color: var(--success);
}

.delta.down {
  color: var(--danger);
}

.history-empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 72px 24px;
  text-align: center;
  color: var(--text-3);
}

.history-empty .i {
  width: 28px;
  height: 28px;
  margin-bottom: 8px;
  stroke-width: 1.5;
}

.history-empty p {
  margin: 0;
  font-weight: 500;
  color: var(--text);
}

.drawer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 12px 20px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-3);
}

/* Drop zone */
.dropzone {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgb(10 10 10 / 0.55);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.dropzone > div {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  width: 100%;
  height: 100%;
  border: 1.5px dashed var(--accent);
  border-radius: 18px;
  color: #fafafa;
  scale: 0.98;
  transition: scale 0.4s var(--ease);
}

.dropzone .i {
  width: 32px;
  height: 32px;
  margin-bottom: 8px;
  stroke-width: 1.5;
  color: var(--accent-text);
}

.dropzone strong {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.dropzone span {
  font-size: 13px;
  color: rgb(250 250 250 / 0.6);
}

body[data-dropping] .dropzone {
  opacity: 1;
  visibility: visible;
}

body[data-dropping] .dropzone > div {
  scale: 1;
}

/* Toasts */
.toasts {
  position: fixed;
  bottom: 60px;
  left: 50%;
  z-index: 30;
  display: grid;
  justify-items: center;
  gap: 8px;
  translate: -50% 0;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(440px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--on-ink);
  background: var(--ink);
  box-shadow: var(--shadow-pop);
  pointer-events: auto;
  animation: toast-in 0.45s var(--ease) both;
}

.toast.is-leaving {
  animation: toast-out 0.25s ease-in both;
}

.toast--success .i {
  color: #22c55e;
}

.toast--error .i {
  color: #ef4444;
}

.toast-action {
  margin: -4px -8px -4px 4px;
  padding: 4px 8px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: #8b5cf6;
  font: inherit;
  cursor: pointer;
}

.toast-action:hover {
  background: color-mix(in srgb, var(--on-ink) 10%, transparent);
}

@keyframes toast-in {
  from {
    opacity: 0;
    translate: 0 12px;
    scale: 0.96;
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    translate: 0 6px;
  }
}

/* 8. Responsive ------------------------------------------------------------ */
@media (max-width: 1080px) {
  .seg--views button span {
    display: none;
  }
}

@media (max-width: 800px) {
  :root {
    --bar-h: 56px;
  }

  .app {
    padding: 0 8px 8px;
  }

  .brand span {
    display: none;
  }

  .seg--views {
    position: static;
    translate: none;
  }

  .seg--views [data-value='split'],
  .resizer {
    display: none;
  }

  .seg--views button span {
    display: inline;
  }

  .pane--editor,
  .pane--preview {
    flex: 1;
    min-width: 0;
  }

  .desk {
    padding: 16px 12px 40px;
  }

  .status-local {
    display: none;
  }

  .popover {
    inset: calc(var(--bar-h) - 4px) 8px auto auto;
  }
}

@media (max-width: 480px) {
  .bar {
    gap: 8px;
    padding: 0;
  }

  .bar-actions .btn-label {
    display: none;
  }

  .bar-actions .btn {
    min-width: 0;
    width: 40px;
    padding: 0;
  }

  .empty-actions .btn--primary {
    flex: 1 1 100%;
  }
}

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

  .scan {
    display: none;
  }
}

/* Standalone text pages (privacy) ----------------------------------------- */
.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px 96px;
}

.page .bar {
  height: var(--bar-h);
  padding: 0;
  margin-bottom: 72px;
}

.page h1 {
  margin: 0 0 12px;
  font-size: clamp(36px, 6vw, 56px);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.page h2 {
  margin: 48px 0 12px;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.page :is(p, li) {
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--text-2);
}

.page ul {
  padding-left: 20px;
}

.page a:not(.btn, .brand) {
  color: var(--accent-text);
  text-underline-offset: 3px;
}

.page .lede {
  margin: 32px 0 0;
  padding: 20px 22px;
  border-radius: var(--radius);
  font-weight: 500;
  color: var(--text);
  background: var(--accent-soft);
}

.page footer {
  margin-top: 72px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--text-3);
}
