/* Scan web. Dark graphite by default in dark mode, warm paper in light; one signal accent. */
:root {
  color-scheme: light;
  --bg: #f3f2ec;
  --surface: #ffffff;
  --surface-2: #e9e8e0;
  --text: #15171a;
  --muted: #5f646b;
  --border: #d9d8ce;
  --border-strong: #b9b8ad;
  --accent: #4a6b0c;
  --accent-text: #ffffff;
  --accent-soft: #e6eed0;
  --ink: #15171a;
  --ink-text: #f6f6f1;
  --success: #17703d;
  --success-soft: #dff2e5;
  --warning: #80540a;
  --warning-soft: #f8eccf;
  --danger: #ad2a1e;
  --danger-soft: #fae3df;
  --info: #225c9c;
  --info-soft: #e0ebf7;
  --grid: rgb(21 23 26 / 7%);
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c0e11;
    --surface: #14171b;
    --surface-2: #1d2126;
    --text: #f0f2f3;
    --muted: #98a0aa;
    --border: #262b31;
    --border-strong: #3b424b;
    --accent: #c6f25c;
    --accent-text: #11150a;
    --accent-soft: #252e12;
    --ink: #f0f2f3;
    --ink-text: #0c0e11;
    --success: #5fd18e;
    --success-soft: #12291c;
    --warning: #eebb5c;
    --warning-soft: #2e2510;
    --danger: #ff8a7c;
    --danger-soft: #331715;
    --info: #86b8f5;
    --info-soft: #14243a;
    --grid: rgb(240 242 243 / 5%);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.75rem; line-height: 1.2; font-weight: 650; letter-spacing: -0.02em; margin: 0; overflow-wrap: anywhere; }
h2 { font-size: 1rem; margin: 0 0 12px; }
p { margin: 0 0 8px; }
p:last-child { margin-bottom: 0; }
code, .mono { font-family: var(--mono); font-size: 0.85em; }
svg.icon { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* Header */
.header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; color: var(--text); text-decoration: none; }
.brand-mark { width: 24px; height: 24px; border-radius: 6px; background: url("/assets/icon-64.png") center / cover; }
.nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.nav-link { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 6px; color: var(--muted); text-decoration: none; font-weight: 550; }
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link[aria-current="page"] { color: var(--text); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }
.lang { margin: 0 6px; padding: 5px 6px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: var(--text); font: inherit; font-size: 0.85rem; }

/* Layout */
.main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 32px 20px 56px; outline: none; }
.page { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.page.narrow { max-width: 640px; }
.page.wide { max-width: none; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.eyebrow { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.04em; color: var(--muted); }
.footer { padding: 18px 20px; text-align: center; font-size: 0.85rem; color: var(--muted); border-top: 1px solid var(--border); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card-title { font-family: var(--mono); font-size: 0.75rem; font-weight: 500; letter-spacing: 0.04em; color: var(--muted); }

.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; margin-top: 12px; flex-wrap: wrap; }
.columns { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
@media (max-width: 860px) { .columns { grid-template-columns: minmax(0, 1fr); } }

/* Sign-in */
.auth-shell {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  max-width: 1040px; margin: 2vh auto 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
.auth-hero {
  position: relative; display: flex; flex-direction: column; gap: 16px; justify-content: flex-end;
  min-height: 560px; padding: 32px;
  background-color: var(--surface-2);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
  border-inline-end: 1px solid var(--border);
  overflow: hidden;
}
.auth-hero h2 { font-size: 1.85rem; line-height: 1.15; font-weight: 650; letter-spacing: -0.025em; margin: 0; }
.auth-hero p { color: var(--muted); max-width: 40ch; }
.scan-figure { position: absolute; top: 28px; left: 50%; width: min(78%, 340px); transform: translateX(-50%); color: var(--text); }
.scan-figure svg { display: block; width: 100%; height: auto; fill: none; stroke: currentColor; stroke-width: 1; stroke-linejoin: round; }
.scan-figure .back { opacity: 0.3; }
.scan-figure .points { fill: var(--accent); stroke: none; }
.scan-figure .sweep { stroke: var(--accent); stroke-width: 1.5; animation: sweep 5s ease-in-out infinite alternate; }
@keyframes sweep { from { transform: translateY(-74px); } to { transform: translateY(74px); } }
@media (prefers-reduced-motion: reduce) { .scan-figure .sweep { animation: none; } }
.hero-tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; font-family: var(--mono); font-size: 0.75rem; }
.hero-tags li { padding: 2px 8px; border: 1px solid var(--border-strong); border-radius: 4px; color: var(--muted); }
.auth { display: flex; flex-direction: column; gap: 14px; justify-content: center; padding: 36px; min-width: 0; }
.auth .card { border: 0; padding: 0; background: transparent; }
@media (max-width: 800px) {
  .auth-shell { grid-template-columns: minmax(0, 1fr); margin-top: 0; }
  .auth-hero { min-height: 0; padding: 20px; border-inline-end: 0; border-bottom: 1px solid var(--border); }
  .auth-hero h2 { font-size: 1.35rem; }
  .auth-hero p, .scan-figure { display: none; }
  .auth { padding: 22px 20px; }
}

.loading { width: 120px; height: 2px; margin: 18vh auto; background: var(--border); position: relative; overflow: hidden; }
.loading::after { content: ""; position: absolute; inset: 0; width: 40%; background: var(--accent); animation: load 1.1s ease-in-out infinite alternate; }
@keyframes load { from { transform: translateX(0); } to { transform: translateX(150%); } }
@media (prefers-reduced-motion: reduce) { .loading::after { animation: none; } }
.main[aria-busy="true"] > :not(.loading) { opacity: 0.6; }

[dir="rtl"] .loading::after { animation-direction: alternate-reverse; }
/* The monospace stack has no real Arabic glyphs and breaks letter joining. */
[dir="rtl"] .hero-tags, [dir="rtl"] .table th, [dir="rtl"] .card-title, [dir="rtl"] .eyebrow, [dir="rtl"] .tile-kind { font-family: var(--font); }
/* Addresses and codes stay left-to-right inside Arabic text. */
[dir="rtl"] input[type="email"], [dir="rtl"] input[type="password"], [dir="rtl"] input[inputmode="numeric"] { direction: ltr; text-align: end; }

/* Text */
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; }
.link { color: var(--accent); text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; }
@media (prefers-color-scheme: light) { .link { text-underline-offset: 2px; } }

/* Forms */
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 0.85rem; font-weight: 600; }
.field-hint { font-size: 0.8rem; color: var(--muted); }
.input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border-strong); border-radius: 6px;
  background: var(--bg); color: var(--text); font: inherit;
}
.input:hover { border-color: var(--muted); }
.input:focus-visible, .btn:focus-visible, .tab:focus-visible, .lang:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.input[readonly] { background: var(--surface-2); }
.input-small { width: 90px; }
.select { width: auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px; border-radius: 6px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-warning { background: var(--warning-soft); color: var(--warning); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-block { width: 100%; }
.stack > .btn { align-self: flex-start; }
.auth .stack > .btn { align-self: stretch; }
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } }

.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--border); max-width: 100%; overflow-x: auto; }
.tab { padding: 8px 0; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.card > .tabs { margin-bottom: 18px; }

.msg { margin: 8px 0 0; font-size: 0.9rem; }
.msg:empty { display: none; }
.msg-error { color: var(--danger); }
.msg-success { color: var(--success); }
.msg-info { color: var(--muted); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar .input[type="search"] { flex: 1 1 240px; width: auto; }

/* Badges */
.badge { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; line-height: 1.6; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }

/* Library */
.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.tile { display: flex; flex-direction: column; height: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; overflow: hidden; transition: border-color 0.12s ease; }
.tile:hover { border-color: var(--accent); }
.tile-art {
  display: flex; align-items: center; justify-content: center; height: 112px; color: var(--muted);
  background-color: var(--surface-2);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 16px 16px;
  border-bottom: 1px solid var(--border);
}
.tile:hover .tile-art { color: var(--accent); }
.tile-art svg.icon { width: 44px; height: 44px; stroke-width: 1; }
.tile-art-photo { position: relative; height: 150px; overflow: hidden; }
.tile-photo { display: block; width: 100%; height: 100%; object-fit: cover; }
.tile-type { position: absolute; inset-block-end: 8px; inset-inline-end: 8px; display: flex; padding: 5px; border-radius: 6px; background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / 30%); }
.tile-art .tile-type svg.icon { width: 18px; height: 18px; stroke-width: 1.75; }
.detail-image { display: block; width: 100%; border-radius: var(--radius); }
.tile-body { display: flex; flex-direction: column; gap: 3px; flex: 1; padding: 12px 14px 14px; }
.tile-kind { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); }
.tile-title { font-weight: 600; overflow-wrap: anywhere; }
.tile-meta { font-size: 0.85rem; color: var(--muted); }
.tile-body .row { margin-top: auto; padding-top: 8px; flex-wrap: wrap; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 48px 20px; text-align: center; color: var(--muted); }
.empty svg.icon { width: 40px; height: 40px; stroke-width: 1; }

.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 18px; margin: 0; }
.facts dt { color: var(--muted); font-size: 0.9rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.list { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.list-row:first-child { border-top: 0; }

/* Admin */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; box-shadow: -1px -1px 0 var(--border); }
.stat-value { font-family: var(--mono); font-size: 1.7rem; font-weight: 500; line-height: 1.1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.82rem; color: var(--muted); }
.stat-success .stat-value { color: var(--success); }
.stat-warning .stat-value { color: var(--warning); }
.stat-danger .stat-value { color: var(--danger); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card .table-wrap { border: 0; border-radius: 0; margin: 0 -18px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th { text-align: start; font-family: var(--mono); font-size: 0.72rem; font-weight: 500; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 14px; border-top: 1px solid var(--border); vertical-align: top; }
.table tbody tr:first-child td { border-top: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.details { min-width: 180px; overflow-wrap: anywhere; }
.num { text-align: end; font-variant-numeric: tabular-nums; }
.table th.num { text-align: end; }

.feedback-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; }
.feedback-item .row.between { margin-top: 0; }
.feedback-message { margin: 10px 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Static pages (privacy policy) */
.prose { max-width: 720px; margin: 0 auto; }
.prose h1 { margin: 8px 0 14px; }
.prose h2 { margin-top: 28px; font-size: 1.1rem; }
.prose li { margin-bottom: 4px; }
.prose .todo { background: var(--warning-soft); color: var(--warning); padding: 0 4px; border-radius: 4px; }

/* Model editor */
.viewer-stage { position: relative; }
/* Scale bar over the bottom of the model view: real length under the current zoom. */
.scale-bar {
  position: absolute; inset-block-end: 10px; inset-inline-start: 50%; transform: translateX(-50%);
  display: grid; justify-items: center; gap: 2px; padding: 4px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--surface, #fff) 80%, transparent); color: var(--text, #111);
  font-size: 12px; font-weight: 600; pointer-events: none;
}
[dir="rtl"] .scale-bar { transform: translateX(50%); }
.scale-line { display: block; height: 3px; background: currentColor; position: relative; }
.scale-line::before, .scale-line::after { content: ""; position: absolute; top: -3px; width: 2px; height: 9px; background: currentColor; }
.scale-line::before { inset-inline-start: 0; }
.scale-line::after { inset-inline-end: 0; }
.editor-canvas { display: block; width: 100%; height: min(70vw, 480px); border-radius: var(--radius); touch-action: none; }
.editor-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.editor-group { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.editor-group legend { font-size: 0.85rem; font-weight: 600; padding: 0 4px; }
.editor-slider { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; }
.editor-range { grid-column: 1 / -1; grid-row: 2; width: 100%; min-height: 28px; accent-color: var(--accent); }
.editor-value { font-size: 0.8rem; color: var(--muted); }
.editor-check { display: flex; align-items: center; gap: 8px; min-height: 32px; }

/* Advice under a photogrammetry model's quality score. */
.hints { margin: 0; padding-inline-start: 1.2em; display: grid; gap: 4px; }

/* A tool that is on (brush, piece picking) looks pressed. */
.editor-group .btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: transparent; }

/* A short message over the page, such as asking to fetch an edited model on the phone. */
dialog.modal {
  max-width: min(420px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); padding: 20px;
}
dialog.modal::backdrop { background: rgb(0 0 0 / 0.45); }
dialog.modal h2 { margin: 0 0 8px; font-size: 1.15rem; }

/* A capture kept while the account has no Pro: shown, not opened. */
.tile-locked { opacity: 0.75; cursor: default; }
