/* GwG Wizard — base styles */
:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-2: #f4f1ec;
  --ink: #1a1a1a;
  --ink-2: #4a4a48;
  --ink-3: #7a7872;
  --line: #e6e1d8;
  --line-2: #d4cfc4;
  --accent: oklch(0.55 0.13 250);
  --accent-soft: oklch(0.95 0.03 250);
  --accent-ink: oklch(0.4 0.13 250);
  --success: oklch(0.55 0.13 155);
  --success-soft: oklch(0.95 0.03 155);
  --warning: oklch(0.7 0.15 65);
  --warning-soft: oklch(0.96 0.05 75);
  --danger: oklch(0.55 0.18 25);
  --danger-soft: oklch(0.96 0.04 25);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 20, 0.04), 0 1px 3px rgba(20, 20, 20, 0.06);
  --shadow-md: 0 4px 12px rgba(20, 20, 20, 0.06), 0 2px 4px rgba(20, 20, 20, 0.04);
  --shadow-lg: 0 12px 32px rgba(20, 20, 20, 0.1), 0 4px 8px rgba(20, 20, 20, 0.05);
  --gap: 24px;
  --gap-sm: 12px;
  --gap-lg: 40px;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Source Serif 4', 'Source Serif Pro', Georgia, serif;
  --density: 1;
}

[data-density="compact"] {
  --gap: 16px;
  --gap-sm: 8px;
  --gap-lg: 28px;
  --density: 0.85;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  /* Safety net for stray horizontal overflow on narrow iOS viewports.
     Uses `clip` (Safari 16+) instead of `hidden` because `overflow-x:
     hidden` on html/body changes the scrolling ancestor on iOS and
     breaks position: sticky on descendants — the .main-footer ends up
     anchored to the bottom of .main rather than the viewport, so the
     prev/next buttons disappear under the URL bar pill on b3 and
     similar short steps. `clip` clips without establishing a scroll
     container, so sticky keeps working. */
  overflow-x: clip;
}

button { font-family: inherit; }

input, textarea, select {
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
}

a { color: var(--accent-ink); }

/* ========== Layout ========== */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px 1fr;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 28px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.02em;
}
.brand-sub { color: var(--ink-3); font-weight: 400; font-size: 12px; margin-top: 2px; }

.main {
  /* No bottom padding: .main is the sticky-footer's containing block, and
     any padding-bottom here lets the footer drift up by that amount at the
     end of the scroll. .main-footer carries its own top border + padding. */
  padding: 48px 56px 0;
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  /* svh = smallest viewport height (URL bar fully shown). On iOS Safari this
     keeps .main's bottom inside the visible area at all times, so the sticky
     footer is reachable. dvh would be too large because Safari treats it as
     the URL-bar-collapsed height and doesn't reflow when the URL bar reappears,
     pushing the footer below the visible edge. */
  min-height: 100svh;
}

/* User-area mode uses the full available width — the 880px content cap is
   appropriate for the wizard's reading-line, not for tables/forms in tabs. */
.main.main-full { max-width: none; }

/* ========== Step list ========== */
.step-group { margin-bottom: 4px; }
.step-group-title {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  padding: 8px 12px 6px;
}
.step-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.step-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink-2);
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  transition: background 0.15s;
  min-height: 38px;
}
.step-item:hover { background: var(--surface-2); }
.step-item[data-active="true"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 500;
}
.step-item[data-disabled="true"] { opacity: 0.4; cursor: not-allowed; }
.step-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--line-2);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 10px;
  color: var(--ink-3);
  background: var(--surface);
}
.step-item[data-status="done"] .step-dot {
  background: var(--success);
  border-color: var(--success);
  color: white;
}
.step-item[data-status="current"] .step-dot {
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* ========== Form ========== */
.eyebrow {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  margin-bottom: 10px;
}
.h1 {
  font-family: var(--font-serif);
  font-size: 36px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
  font-weight: 500;
}
.lede {
  font-size: 16px;
  color: var(--ink-2);
  max-width: 60ch;
  margin: 0 0 32px;
  line-height: 1.55;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
[data-density="compact"] .card { padding: 20px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.field-label .req { color: var(--danger); font-weight: 600; }
.field-hint { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.field-error { font-size: 12px; color: var(--danger); margin-top: 4px; display: flex; gap: 4px; align-items: center; }

.input, .textarea, .select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 15px;
  font-family: inherit;
  line-height: 1.4;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input, .select { height: 44px; }
.select {
  /* Native <select> chrome paints its own arrow; reserve room and align text. */
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }

/* After the user clicks Weiter while the step is invalid, the App container
   gets the .show-errors class and any empty `required` field becomes :invalid
   and is painted red. Clears automatically as the user fills the field. */
.show-errors .input:invalid,
.show-errors .textarea:invalid,
.show-errors .select:invalid {
  border-color: var(--danger);
  background: oklch(0.985 0.04 25);
  box-shadow: 0 0 0 3px oklch(0.92 0.07 25);
}

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 720px) {
  .row, .row-3 { grid-template-columns: 1fr; }
}

/* ========== Choice cards (radio/checkbox) ========== */
.choice-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.choice {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 56px;
}
.choice:hover { border-color: var(--ink-3); background: var(--surface-2); }
.choice[data-selected="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent);
}
.choice-indicator {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--line-2);
  flex-shrink: 0;
  margin-top: 2px;
  position: relative;
  background: var(--surface);
}
.choice[data-shape="square"] .choice-indicator { border-radius: 5px; }
.choice[data-selected="true"] .choice-indicator {
  border-color: var(--accent);
  background: var(--accent);
}
.choice[data-selected="true"] .choice-indicator::after {
  content: '';
  position: absolute;
  inset: 0;
  display: block;
}
.choice[data-selected="true"][data-shape="round"] .choice-indicator::after {
  background: white;
  border-radius: 50%;
  inset: 5px;
}
.choice[data-selected="true"][data-shape="square"] .choice-indicator::after {
  width: 6px; height: 10px;
  border-right: 2px solid white;
  border-bottom: 2px solid white;
  transform: rotate(45deg);
  position: absolute;
  top: 2px;
  left: 6px;
}
.choice-body { flex: 1; }
.choice-title { font-weight: 500; font-size: 15px; line-height: 1.4; }
.choice-desc { color: var(--ink-3); font-size: 13px; margin-top: 4px; line-height: 1.5; }
.choice-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--ink-2);
  margin-left: 8px;
  text-transform: uppercase;
  vertical-align: middle;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 44px;
  text-decoration: none;
  background: var(--surface-2);
  color: var(--ink);
}
.btn:hover { background: var(--line); }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { filter: brightness(0.95); background: var(--accent); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 7px 14px; font-size: 13px; min-height: 34px; }

.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.main-footer {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  /* auto pushes the footer to the bottom of the .main flex column even on
     short steps — combined with sticky bottom: 0 the buttons sit at the
     visible viewport edge regardless of content length. */
  margin-top: auto;
  z-index: 5;
}
.actions-right { display: flex; gap: 12px; }

/* ========== Callout ========== */
.callout {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.55;
  margin: 16px 0;
  display: flex;
  gap: 12px;
}
.callout-info { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.callout-warn { background: var(--warning-soft); border-color: var(--warning); color: oklch(0.4 0.12 65); }
.callout-success { background: var(--success-soft); border-color: var(--success); color: oklch(0.35 0.12 155); }
.callout-icon { flex-shrink: 0; margin-top: 1px; }

/* ========== Disclosure (Gesetzestext) ========== */
.disclosure { margin: 12px 0; }
.disclosure-toggle {
  background: transparent;
  border: none;
  padding: 6px 0;
  font-size: 12px;
  color: var(--ink-3);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--line-2);
  text-underline-offset: 3px;
}
.disclosure-toggle:hover { color: var(--ink); }
.disclosure-content {
  padding: 12px 14px;
  background: var(--surface-2);
  border-left: 2px solid var(--line-2);
  border-radius: 4px;
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.6;
  margin-top: 6px;
}

/* ========== Progress bar (mobile) ========== */
.mobile-bar {
  display: none;
  position: sticky;
  top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  z-index: 10;
  align-items: center;
  gap: 12px;
}
.mobile-bar-progress {
  flex: 1;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.mobile-bar-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s;
}
.mobile-bar-counter { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.mobile-bar-menu {
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ========== Mobile sheet ========== */
.sheet-overlay {
  position: fixed; inset: 0;
  background: rgba(20,20,20,0.4);
  z-index: 50;
  display: none;
}
.sheet-overlay[data-open="true"] { display: block; }
.sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 20px;
  z-index: 51;
  max-height: 80vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s;
}
.sheet[data-open="true"] { transform: translateY(0); }
.sheet-handle {
  width: 36px; height: 4px;
  background: var(--line-2);
  border-radius: 2px;
  margin: 0 auto 16px;
}

@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-bar { display: flex; }
  .main { padding: 24px 16px 0; }
  .h1 { font-size: 28px; }
  .card { padding: 18px; }
}

/* ========== Pill / chip ========== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface-2);
  color: var(--ink-2);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.chip-accent { background: var(--accent-soft); color: var(--accent-ink); }
.chip-success { background: var(--success-soft); color: oklch(0.35 0.12 155); }
.chip-warn { background: var(--warning-soft); color: oklch(0.4 0.12 65); }

/* ========== Scan animation ========== */
.scan-frame {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  aspect-ratio: 1.586 / 1;
  background: linear-gradient(135deg, oklch(0.5 0.04 250), oklch(0.35 0.04 250));
  border-radius: 14px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.scan-corners::before, .scan-corners::after,
.scan-corners > i::before, .scan-corners > i::after {
  content: '';
  position: absolute;
  width: 24px; height: 24px;
  border: 3px solid white;
  border-radius: 4px;
}
.scan-corners::before { top: 12px; left: 12px; border-right: 0; border-bottom: 0; }
.scan-corners::after { top: 12px; right: 12px; border-left: 0; border-bottom: 0; }
.scan-corners > i::before { bottom: 12px; left: 12px; border-right: 0; border-top: 0; position: absolute; }
.scan-corners > i::after { bottom: 12px; right: 12px; border-left: 0; border-top: 0; position: absolute; }
.scan-line {
  position: absolute;
  left: 8%; right: 8%;
  height: 2px;
  background: linear-gradient(90deg, transparent, oklch(0.85 0.15 145), transparent);
  box-shadow: 0 0 12px oklch(0.85 0.15 145);
  animation: scanMove 2.4s ease-in-out infinite;
  top: 20%;
}
@keyframes scanMove {
  0%, 100% { top: 18%; }
  50% { top: 78%; }
}
.scan-id {
  position: absolute;
  inset: 18% 12%;
  background: linear-gradient(135deg, #f0e8d4, #e6dcc4);
  border-radius: 6px;
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 8px;
  padding: 10px;
  opacity: 0.85;
}
.scan-id-photo { background: oklch(0.6 0.04 60); border-radius: 3px; }
.scan-id-lines { display: flex; flex-direction: column; gap: 5px; padding-top: 4px; }
.scan-id-lines i { display: block; height: 6px; background: oklch(0.45 0.04 250); border-radius: 1px; opacity: 0.6; }
.scan-id-lines i:nth-child(1) { width: 70%; }
.scan-id-lines i:nth-child(2) { width: 50%; }
.scan-id-lines i:nth-child(3) { width: 80%; }
.scan-id-lines i:nth-child(4) { width: 40%; }

/* ========== Summary / print ========== */
.summary-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
.summary-section h3 {
  font-family: var(--font-serif);
  font-size: 18px;
  margin: 0 0 14px;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.summary-section h3 .edit-link {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-ink);
  cursor: pointer;
  text-decoration: underline;
  background: transparent;
  border: 0;
}
.kv-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 8px 20px;
  font-size: 13px;
}
.kv-grid dt { color: var(--ink-3); }
.kv-grid dd { margin: 0; color: var(--ink); }
@media (max-width: 600px) {
  .kv-grid { grid-template-columns: 1fr; gap: 2px 0; }
  .kv-grid dt { margin-top: 8px; }
}

/* ========== Print ========== */
@media print {
  .sidebar, .mobile-bar, .actions, .tweaks-panel, .no-print, .btn { display: none !important; }
  .app { grid-template-columns: 1fr; }
  body { background: white; }
  .main { padding: 0; max-width: none; }
  .summary-section { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; margin-bottom: 12px; }
  .h1 { font-size: 22px; }
  @page { margin: 18mm 16mm; }
}

/* ========== List add/remove (wB) ========== */
.entity-card {
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  background: var(--surface);
  position: relative;
}
.entity-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.entity-card-title { font-weight: 600; font-size: 14px; }

.add-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border: 1.5px dashed var(--line-2);
  background: transparent;
  border-radius: var(--radius);
  color: var(--ink-2);
  cursor: pointer;
  font-size: 14px;
  width: 100%;
  justify-content: center;
  transition: all 0.15s;
  min-height: 50px;
}
.add-btn:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }

/* Save indicator */
.save-indicator {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: white;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 20;
  box-shadow: var(--shadow-lg);
}
.save-indicator[data-show="true"] { opacity: 1; transform: translateX(-50%) translateY(0); }


/* ===== Viewport frames (Tweak: viewport) ===== */
body[data-viewport="mobile"],
body[data-viewport="tablet"] {
  background: #1a1a1a;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px;
  min-height: 100vh;
  overflow-y: auto;
}
.viewport-frame {
  background: var(--bg);
  border-radius: 36px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.45), 0 0 0 8px #2a2a2a, 0 0 0 10px #444;
  position: relative;
  overflow: hidden;
}
.viewport-frame::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 120px; height: 24px;
  background: #2a2a2a;
  border-radius: 0 0 14px 14px;
  z-index: 100;
  pointer-events: none;
}
body[data-viewport="mobile"] .viewport-frame {
  width: 390px;
  height: calc(100vh - 64px);
  max-height: 844px;
  min-height: 700px;
  border-radius: 44px;
}
body[data-viewport="tablet"] .viewport-frame {
  width: 820px;
  height: calc(100vh - 64px);
  max-height: 1100px;
  min-height: 720px;
  border-radius: 24px;
}
body[data-viewport="tablet"] .viewport-frame::before {
  width: 80px; height: 16px;
}
body[data-viewport="mobile"] .viewport-frame .app,
body[data-viewport="tablet"] .viewport-frame .app {
  width: 100%;
  height: 100%;
  overflow-y: auto;
}
/* Force mobile-bar / sheet behavior inside narrow frames */
body[data-viewport="mobile"] .viewport-frame .sidebar { display: none; }
body[data-viewport="mobile"] .viewport-frame .mobile-bar { display: flex; }
body[data-viewport="mobile"] .viewport-frame .app { display: block; padding-top: 28px; }
body[data-viewport="mobile"] .viewport-frame .main { padding: 16px; }

body[data-viewport="tablet"] .viewport-frame .sidebar { display: none; }
body[data-viewport="tablet"] .viewport-frame .mobile-bar { display: flex; }
body[data-viewport="tablet"] .viewport-frame .app { display: block; padding-top: 28px; }
body[data-viewport="tablet"] .viewport-frame .main { padding: 24px 32px; max-width: 720px; margin: 0 auto; }

body[data-viewport="desktop"] {
  background: #1a1a1a;
  padding: 24px;
}
body[data-viewport="desktop"] .viewport-frame {
  width: 1280px;
  max-width: 100%;
  margin: 0 auto;
  height: calc(100vh - 48px);
  min-height: 760px;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
body[data-viewport="desktop"] .viewport-frame::before { display: none; }
body[data-viewport="desktop"] .viewport-frame .app { width: 100%; height: 100%; overflow: hidden; }

@media print {
  body[data-viewport] { background: white; padding: 0; display: block; }
  .viewport-frame { box-shadow: none; border-radius: 0; width: auto !important; height: auto !important; }
  .viewport-frame::before { display: none; }
}


/* ===== FileUpload ===== */
.upload { display: flex; flex-direction: column; gap: 10px; }
.upload-drop {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  border: 1.5px dashed var(--line-2);
  border-radius: 12px;
  background: var(--surface-2);
  cursor: pointer;
  transition: all 0.15s ease;
}
.upload-drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.upload-drop.is-drag { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.01); }
.upload-icon { font-size: 22px; opacity: 0.7; }
.upload-label { font-weight: 600; font-size: 14px; color: var(--ink); }
.upload-hint { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.upload-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.upload-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px 8px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.upload-thumb {
  width: 44px; height: 44px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface-2);
  flex-shrink: 0;
}
.upload-thumb-doc {
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent-soft);
}
.upload-meta { flex: 1; min-width: 0; }
.upload-name { font-size: 13px; font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-sub { font-size: 11px; color: var(--ink-3); }
.upload-remove {
  background: transparent; border: 0; cursor: pointer;
  width: 28px; height: 28px; border-radius: 6px;
  font-size: 20px; color: var(--ink-3);
  display: grid; place-items: center;
}
.upload-remove:hover { background: var(--surface-2); color: var(--ink); }


/* ---------- Archive card (Compliance archiving) ---------- */
.archive-card {
  background: linear-gradient(135deg, var(--surface) 0%, var(--accent-soft) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.archive-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  pointer-events: none;
  background: radial-gradient(circle at top right, oklch(0.95 0.05 145 / 0.4), transparent 60%);
}
.archive-card-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  position: relative;
}
.archive-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px oklch(0.55 0.13 250 / 0.3);
}
.archive-title {
  margin: 0 0 4px;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.archive-sub {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
}
.archive-feats {
  list-style: none;
  margin: 18px 0 20px;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 24px;
  position: relative;
}
.archive-feats li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13.5px;
  color: var(--ink);
  line-height: 1.45;
}
.archive-feats li svg {
  color: oklch(0.5 0.13 155);
  flex-shrink: 0;
  margin-top: 1px;
}
.archive-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  position: relative;
}
.btn-archive {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-left: 18px;
  padding-right: 18px;
}
.btn-archive:hover:not(:disabled) {
  background: oklch(0.25 0 0);
  border-color: oklch(0.25 0 0);
  transform: translateY(-1px);
}
.btn-archive:disabled {
  opacity: 1;
  background: oklch(0.5 0.13 155);
  border-color: oklch(0.5 0.13 155);
  cursor: default;
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}
.btn-ghost:hover {
  background: var(--surface-2);
}
.spin {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.archive-progress {
  margin-top: 18px;
  position: relative;
}
.archive-progress-bar {
  height: 4px;
  background: oklch(0.55 0.13 155);
  border-radius: 2px;
  transition: width 0.2s ease-out;
  margin-bottom: 12px;
}
.archive-progress-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}
.archive-step {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-3);
  transition: color 0.2s;
}
.archive-step .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-2);
  flex-shrink: 0;
}
.archive-step.active {
  color: var(--ink);
  font-weight: 500;
}
.archive-step.active .dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px oklch(0.55 0.13 250 / 0.2);
  animation: pulse 1s ease-in-out infinite;
}
.archive-step.done {
  color: oklch(0.45 0.13 155);
}
.archive-step.done .dot {
  background: oklch(0.55 0.13 155);
}
.archive-step.done .dot::after {
  content: '';
  position: absolute;
}
@keyframes pulse {
  50% { box-shadow: 0 0 0 6px oklch(0.55 0.13 250 / 0.1); }
}
.archive-receipt {
  margin-top: 18px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid oklch(0.55 0.13 155 / 0.3);
  border-radius: var(--radius);
  position: relative;
}
.archive-receipt::before {
  content: '✓ Erfolgreich archiviert';
  position: absolute;
  top: -10px;
  left: 14px;
  background: oklch(0.5 0.13 155);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}
.archive-receipt-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 12px;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px dashed var(--line);
  align-items: center;
}
.archive-receipt-row:last-of-type { border-bottom: none; }
.archive-receipt-row span { color: var(--ink-3); }
.archive-receipt-row code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  color: var(--ink);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 4px;
  word-break: break-all;
  overflow-wrap: break-word;
}

@media (max-width: 720px) {
  .archive-feats { grid-template-columns: 1fr; }
  .archive-receipt-row { grid-template-columns: 1fr; gap: 2px; }
}


/* ---------- Zero-Knowledge password modal ---------- */
.zk-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 20, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: zkFade 0.2s ease-out;
}
@keyframes zkFade { from { opacity: 0; } }
.zk-modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 24px;
  animation: zkSlide 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes zkSlide { from { transform: translateY(20px); opacity: 0; } }
.zk-modal-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}
.zk-modal-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.zk-modal-title {
  margin: 0 0 2px;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.zk-modal-sub {
  margin: 0;
  font-size: 13px;
  color: var(--ink-3);
}
.zk-modal-close {
  background: transparent;
  border: 0;
  font-size: 26px;
  line-height: 1;
  color: var(--ink-3);
  cursor: pointer;
  padding: 0 4px;
}
.zk-modal-close:hover { color: var(--ink); }

.zk-warn {
  background: oklch(0.97 0.04 70);
  border: 1px solid oklch(0.85 0.1 70);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
}
.zk-warn-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: oklch(0.4 0.13 50);
  margin-bottom: 8px;
}
.zk-warn-head svg { color: oklch(0.55 0.18 50); }
.zk-warn ul {
  margin: 0;
  padding-left: 22px;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.55;
}
.zk-warn li { margin-bottom: 4px; }
.zk-warn li:last-child { margin-bottom: 0; }
.zk-warn strong { color: oklch(0.4 0.18 30); }

.zk-tip {
  background: oklch(0.97 0.04 155);
  border: 1px solid oklch(0.78 0.12 155);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 18px;
}
.zk-tip-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin-bottom: 6px;
  color: oklch(0.32 0.13 155);
}
.zk-tip-head svg { color: oklch(0.5 0.15 155); }
.zk-tip-head strong { color: oklch(0.32 0.13 155); }
.zk-tip-pill {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: oklch(0.5 0.15 155);
  color: white;
  padding: 2px 8px;
  border-radius: 999px;
}
.zk-tip p {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.55;
  color: oklch(0.28 0.04 155);
}
.zk-tip p strong { color: oklch(0.28 0.13 155); }
.zk-tip-note {
  margin-top: 10px !important;
  font-size: 12px !important;
  color: oklch(0.45 0.04 155) !important;
}
.btn-tip {
  display: inline-flex; align-items: center; gap: 8px;
  background: oklch(0.5 0.15 155);
  color: white;
  border: 1px solid oklch(0.45 0.15 155);
  padding: 9px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-tip:hover { background: oklch(0.45 0.15 155); }
.btn-tip svg { color: white; }

.zk-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 18px;
}
.zk-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.zk-input-wrap {
  position: relative;
}
.zk-input-wrap .input { padding-right: 38px; }
.zk-eye {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  font-size: 16px;
  cursor: pointer;
  color: var(--ink-3);
  padding: 4px;
}
.zk-strength {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}
.zk-strength-track {
  flex: 1;
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
}
.zk-strength-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.2s, background 0.2s;
}
.zk-strength-bar.zk-s0, .zk-strength-bar.zk-s1 { background: oklch(0.6 0.18 25); }
.zk-strength-bar.zk-s2 { background: oklch(0.7 0.15 65); }
.zk-strength-bar.zk-s3 { background: oklch(0.65 0.13 100); }
.zk-strength-bar.zk-s4, .zk-strength-bar.zk-s5 { background: oklch(0.55 0.13 155); }
.zk-strength-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  width: 80px;
  text-align: right;
}
.zk-strength-label.zk-s0, .zk-strength-label.zk-s1 { color: oklch(0.55 0.18 25); }
.zk-strength-label.zk-s2 { color: oklch(0.55 0.15 65); }
.zk-strength-label.zk-s3 { color: oklch(0.5 0.13 100); }
.zk-strength-label.zk-s4, .zk-strength-label.zk-s5 { color: oklch(0.5 0.13 155); }
.zk-mismatch { font-size: 12px; color: oklch(0.55 0.18 25); font-weight: 500; }
.zk-match { font-size: 12px; color: oklch(0.5 0.13 155); font-weight: 500; }

.zk-ack {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
  background: var(--surface-2);
  padding: 12px 14px;
  border-radius: var(--radius);
  cursor: pointer;
}
.zk-ack input { margin-top: 2px; flex-shrink: 0; }
.zk-ack strong { color: var(--ink); }

.zk-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.zk-modal-actions .btn-archive:disabled {
  background: var(--line-2);
  border-color: var(--line-2);
  color: var(--ink-3);
  cursor: not-allowed;
}

/* ---------- Reposition destructive action ---------- */
.archive-actions-secondary {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  position: relative;
}
.btn-danger-text {
  background: transparent;
  border: 0;
  color: var(--ink-3);
  font-size: 12px;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.btn-danger-text:hover {
  color: oklch(0.55 0.18 25);
  background: oklch(0.96 0.04 25);
}


/* ---------- Paywall modal ---------- */
.pw-modal { max-width: 720px; }
.pw-tier-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.pw-tier {
  position: relative;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--surface);
  display: block;
}
.pw-tier input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.pw-tier:hover { border-color: var(--line-2); }
.pw-tier.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 4px oklch(0.55 0.13 250 / 0.08);
}
.pw-tier-badge {
  position: absolute;
  top: -10px;
  right: 12px;
  background: oklch(0.55 0.13 155);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}
.pw-tier-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.pw-tier-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
}
.pw-tier-price {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.pw-tier-price small {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-3);
}
.pw-tier ul {
  margin: 0;
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.5;
}
.pw-tier ul li { margin-bottom: 2px; }

.pw-note {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-3);
  background: var(--surface-2);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
}
.pw-note svg { color: var(--accent); flex-shrink: 0; }

.pw-paying, .pw-paid {
  text-align: center;
  padding: 32px 16px;
}
.pw-paying-spinner { display: flex; justify-content: center; margin-bottom: 14px; }
.pw-paying-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 4px;
}
.pw-paying-sub {
  font-size: 12px;
  color: var(--ink-3);
}
.pw-paid-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: oklch(0.55 0.13 155);
  color: #fff;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  animation: zkSlide 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.pw-paid-text {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}
.pw-paid-sub {
  font-size: 12px;
  color: var(--ink-3);
}

@media (max-width: 640px) {
  .pw-tier-grid { grid-template-columns: 1fr; }
}


/* ---------- User area link in sidebar ---------- */
.user-area-link {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 12px;
  font-size: 13px; font-weight: 500; color: var(--ink);
  cursor: pointer; margin-bottom: 16px;
  transition: all 0.15s;
}
.user-area-link:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.user-area-link svg { color: var(--ink-3); }

/* ---------- User area overlay ---------- */
.ua-overlay {
  position: fixed; inset: 0; background: rgba(20,20,20,0.55);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  z-index: 999; display: flex; align-items: center; justify-content: center;
  padding: 16px; animation: zkFade 0.2s ease-out;
}
.ua-shell {
  background: var(--bg); border-radius: var(--radius-lg);
  width: 100%; max-width: 1100px; height: 90vh; max-height: 900px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.ua-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.ua-title { margin: 0; font-family: var(--font-serif); font-size: 22px; font-weight: 600; }
.ua-sub { margin: 2px 0 0; font-size: 13px; color: var(--ink-3); }
.ua-close {
  background: transparent; border: 0; font-size: 28px; line-height: 1;
  color: var(--ink-3); cursor: pointer; padding: 0 8px;
}
.ua-close:hover { color: var(--ink); }

.ua-tabs {
  display: flex; gap: 4px; padding: 0 24px; background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.ua-tab {
  background: transparent; border: 0; padding: 12px 16px; cursor: pointer;
  font-size: 13.5px; font-weight: 500; color: var(--ink-3);
  display: flex; align-items: center; gap: 8px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.ua-tab:hover { color: var(--ink); }
.ua-tab.on { color: var(--accent-ink); border-bottom-color: var(--accent); }
.ua-tab-count {
  background: var(--surface-2); color: var(--ink-2);
  font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 10px;
}
.ua-tab.on .ua-tab-count { background: var(--accent-soft); color: var(--accent-ink); }

.ua-body { flex: 1; overflow-y: auto; padding: 24px; }
.ua-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
  display: flex; flex-direction: column; gap: 14px;
}
.ua-card-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--ink); }
.ua-zk-banner {
  background: var(--accent-soft); border-color: oklch(0.55 0.13 250 / 0.3);
  flex-direction: row; align-items: flex-start; gap: 12px; font-size: 13px; color: var(--ink);
  line-height: 1.55;
}
.ua-zk-banner svg { color: var(--accent); flex-shrink: 0; margin-top: 2px; }
.ua-info-card { background: var(--accent-soft); border-color: oklch(0.55 0.13 250 / 0.3); font-size: 13px; }

.ua-toolbar {
  display: flex; gap: 12px; align-items: center;
  margin-bottom: 14px;
}
.ua-toolbar .input { flex: 1; }
.ua-toolbar-meta { font-size: 12px; color: var(--ink-3); white-space: nowrap; }

.ua-empty {
  text-align: center; padding: 48px 24px; color: var(--ink-3);
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius);
}
.ua-empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.6; }
.ua-empty h4 { margin: 0 0 6px; color: var(--ink); font-size: 16px; }
.ua-empty p { margin: 0; font-size: 13px; max-width: 420px; margin-inline: auto; }

.ua-table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ua-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ua-table th {
  text-align: left; padding: 10px 14px; background: var(--surface-2);
  color: var(--ink-3); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
}
.ua-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ua-table tr:last-child td { border-bottom: 0; }
.ua-table tr:hover td { background: var(--surface-2); }
.ua-file-name { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12.5px; color: var(--ink); font-weight: 500; }
.ua-file-meta { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.ua-ref { font-weight: 500; }
.ua-ref-counter { background: var(--surface-2); color: var(--ink-3); font-size: 11px; padding: 1px 6px; border-radius: 10px; margin-left: 6px; }
.ua-badge {
  display: inline-block; padding: 2px 8px; background: var(--surface-2);
  border-radius: 10px; font-size: 11px; font-weight: 500; color: var(--ink-2);
  margin-right: 4px;
}
.ua-badge-warn { background: oklch(0.95 0.05 65); color: oklch(0.4 0.13 50); }

/* whitelabel & billing */
.ua-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ua-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.ua-row { display: flex; flex-direction: column; }
.ua-label { display: block; font-size: 12px; font-weight: 500; color: var(--ink-2); margin-bottom: 4px; }
.ua-hint { font-size: 12px; color: var(--ink-3); margin: 0; line-height: 1.5; }
.ua-toggle { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; cursor: pointer; }
.ua-toggle input { width: 18px; height: 18px; }

.ua-logo-zone { display: flex; gap: 10px; align-items: center; min-height: 64px; }
.ua-logo-drop {
  flex: 1; border: 1.5px dashed var(--line-2); border-radius: var(--radius-sm);
  padding: 18px; text-align: center; cursor: pointer; font-size: 13px; color: var(--ink-3);
}
.ua-logo-drop:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.ua-logo-drop.drag-over { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); border-style: solid; transform: scale(1.01); }
.ua-logo-preview { max-height: 56px; max-width: 200px; object-fit: contain; }

.ua-pdf-preview {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 24px; box-shadow: var(--shadow-sm);
}
.ua-pdf-preview.off { opacity: 0.5; }
.ua-pdf-header { display: flex; gap: 20px; align-items: flex-start; padding-bottom: 14px; border-bottom: 2px solid #1a1a1a; margin-bottom: 14px; }
.ua-pdf-logo { max-height: 50px; max-width: 180px; object-fit: contain; }
.ua-pdf-logo-placeholder {
  width: 100px; height: 50px; background: var(--surface-2); border: 1px dashed var(--line-2);
  border-radius: 4px; display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--ink-3);
}
.ua-pdf-addr { flex: 1; font-size: 11px; color: var(--ink-2); line-height: 1.5; }
.ua-pdf-name { font-weight: 600; font-size: 13px; color: var(--ink); margin-bottom: 4px; }
.ua-pdf-meta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 4px; color: var(--ink-3); }
.ua-pdf-doc-title { font-family: var(--font-serif); font-size: 18px; font-weight: 600; }
.ua-pdf-doc-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

.ua-pay-options { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.ua-pay {
  position: relative; border: 2px solid var(--line); border-radius: var(--radius);
  padding: 14px; cursor: pointer; display: flex; gap: 12px; align-items: center;
  background: var(--surface);
}
.ua-pay input { position: absolute; opacity: 0; }
.ua-pay.on { border-color: var(--accent); background: var(--accent-soft); }
.ua-pay-icon { font-size: 22px; }
.ua-pay-label { font-weight: 600; font-size: 13.5px; color: var(--ink); }
.ua-pay-desc { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }

/* PW prompt */
.ua-pw-overlay { position: absolute; inset: 0; background: rgba(20,20,20,0.4); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.ua-pw-modal { background: var(--surface); border-radius: var(--radius); padding: 22px; max-width: 460px; width: 100%; box-shadow: var(--shadow-lg); }
.ua-pw-modal h3 { margin: 0 0 8px; font-family: var(--font-serif); font-size: 18px; }
.ua-pw-modal p { font-size: 13px; color: var(--ink-2); margin: 0 0 14px; line-height: 1.5; }
.ua-pw-modal code { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; background: var(--surface-2); padding: 2px 6px; border-radius: 4px; }
.ua-pw-err { color: oklch(0.5 0.18 25); font-size: 12px; margin-top: 6px; font-weight: 500; }
.ua-pw-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

@media (max-width: 720px) {
  .ua-grid-2, .ua-grid-3, .ua-pay-options { grid-template-columns: 1fr; }
  .ua-shell { height: 100vh; max-height: none; border-radius: 0; }
  .ua-head, .ua-tabs, .ua-body { padding-left: 14px; padding-right: 14px; }
  .ua-tabs { overflow-x: auto; }
  .ua-table thead { display: none; }
  .ua-table tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .ua-table td { display: block; padding: 4px 14px; border: 0; }
  .ua-pdf-header { flex-direction: column; }
}

/* ---------- AI disclosure (EU AI Act Art. 50) ---------- */
.ai-disclosure {
  background: linear-gradient(135deg, oklch(0.97 0.04 270) 0%, oklch(0.96 0.05 290) 100%);
  border: 1px solid oklch(0.85 0.08 280);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 14px;
  font-size: 13px;
}
.ai-disclosure-head {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; color: oklch(0.4 0.13 280); margin-bottom: 8px;
}
.ai-disclosure-head svg { color: oklch(0.55 0.13 280); }
.ai-disclosure-grid {
  display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px;
  font-size: 12px; padding: 8px 0;
}
.ai-disclosure-grid dt { color: var(--ink-3); }
.ai-disclosure-grid dd { margin: 0; color: var(--ink); font-weight: 500; }
.ai-disclosure-warn {
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed oklch(0.85 0.08 280);
  font-size: 12px; color: oklch(0.4 0.18 30); display: flex; gap: 8px; align-items: flex-start;
}
.ai-disclosure-warn svg { flex-shrink: 0; margin-top: 1px; color: oklch(0.55 0.18 50); }
.ai-disclosure-toggle {
  background: transparent; border: 0; font-size: 12px; color: var(--accent-ink);
  cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px;
}


.pw-legal {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.pw-legal-row { display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; line-height: 1.5; cursor: pointer; }
.pw-legal-row input { margin-top: 2px; flex-shrink: 0; }
.pw-legal-row a { color: var(--accent-ink); text-decoration: underline; }
.pw-legal-req { color: oklch(0.5 0.18 25); font-weight: 600; }


.archive-badge-pro {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: oklch(0.95 0.05 80);
  color: oklch(0.42 0.12 60);
  border: 1px solid oklch(0.85 0.08 80);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  vertical-align: middle;
}


/* DNFBP category card grid */
.dnfbp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}
.dnfbp-card {
  position: relative;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 14px 12px 12px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 92px;
  font-family: inherit;
  color: var(--ink);
}
.dnfbp-card:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}
.dnfbp-card.selected {
  border-color: var(--accent);
  background: oklch(from var(--accent) 0.97 calc(c * 0.3) h);
  box-shadow: 0 0 0 3px oklch(from var(--accent) 0.92 calc(c * 0.4) h);
}
.dnfbp-icon {
  color: var(--accent-ink);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: oklch(from var(--accent) 0.95 calc(c * 0.3) h);
  border-radius: 8px;
}
.dnfbp-card.selected .dnfbp-icon {
  background: var(--accent);
  color: white;
}
.dnfbp-label {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
}
.dnfbp-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 18px;
  height: 18px;
  background: var(--accent);
  color: white;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
}


/* Post-archive re-download */
.archive-redownload {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.archive-redownload-head {
  display: flex; gap: 12px; align-items: flex-start;
  margin-bottom: 12px;
  color: var(--accent-ink);
}
.archive-redownload-head > div { color: var(--ink); }
.archive-redownload-form {
  display: flex; gap: 8px; align-items: stretch;
}
.archive-redownload-form .input { width: 100%; height: 38px; }
.archive-redownload-form .btn { flex-shrink: 0; height: 38px; padding: 0 14px; display: inline-flex; align-items: center; gap: 6px; }
.archive-redownload-busy {
  display: flex; gap: 10px; align-items: center;
  font-size: 13px; color: var(--ink-2);
  padding: 10px 0;
}
.archive-redownload-done {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 12px;
  background: var(--success-soft);
  border: 1px solid var(--success);
  border-radius: 8px;
}
.archive-redownload-icon {
  width: 28px; height: 28px;
  background: var(--success);
  color: white;
  border-radius: 999px;
  display: grid; place-items: center;
  font-weight: 700;
  flex-shrink: 0;
}
.archive-redownload-note {
  display: flex; gap: 6px; align-items: flex-start;
  margin-top: 10px;
  font-size: 11.5px; color: var(--ink-3);
  line-height: 1.4;
}
.archive-redownload-note svg { flex-shrink: 0; margin-top: 2px; }


/* ========== Mobile overflow safety (Task 5) ==========
   Static audit (Docker not reachable from sandbox) found these residual
   horizontal-overflow risks after Tasks 1-4:
   - Form controls inside flex/grid containers default to
     min-width: auto, which is content-based and can push their parent
     wider than the viewport on narrow screens (despite .input { width:
     100% }).
   - Long unbroken strings (archive references, archive IDs, SHA-256
     hashes, URLs in code/pre) have no break opportunities and force
     their column wider than the viewport.
   - Bare <table> elements (none today, but defensive fallback) need a
     scroll container under 720px. The existing .ua-table already
     converts to block layout via per-cell rules at this breakpoint, so
     the blanket below is harmless overlap with that. */

.field input,
.field textarea,
.field select,
input[type="text"],
input[type="email"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="tel"],
input[type="password"],
textarea,
select {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.kv-grid dd,
.archive-ref,
.archive-row,
.ua-card code,
.ua-card pre,
.ua-ref,
.ua-file-name,
.ua-file-meta,
code, pre {
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media (max-width: 720px) {
  table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
  }
}

/* Date inputs default to ~13ch + picker chrome which overflows narrow
   columns. Force them to fill their container. */
input[type="date"],
input[type="time"],
input[type="datetime-local"] {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
