:root {
  color-scheme: light;
  --ink: #10161c;
  --ink-2: #39454f;
  --paper: #f2f4f3;
  --paper-2: #ffffff;
  --line: #c9d0d2;
  --signal: #1f4fd8;
  --signal-dk: #17399b;
  --caution: #b24a00;
  --unknown: #4a4560;
  --focus: #ffb000;
  --danger: #8f2222;
  --r: 14px;
  --tap: 56px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Inter Tight", system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, .display { font-family: "Archivo", system-ui, sans-serif; letter-spacing: -.02em; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .8125rem; letter-spacing: .04em; }

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  padding-bottom: env(safe-area-inset-bottom);
}
.view { display: none; flex: 1; flex-direction: column; min-height: 100dvh; }
.view[data-active] { display: flex; }

.bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
  padding-top: calc(.875rem + env(safe-area-inset-top));
}
.bar--stacked { display: block; padding-bottom: .75rem; }
.bar__title-row { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: .5rem; margin-top: .75rem; }
.bar__title-row h1 { margin: 0; text-align: center; font-size: 1.125rem; }
.back-button, .icon-button {
  width: 48px; height: 48px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); font-size: 1.4rem;
}
.back-button:hover, .icon-button:hover { background: #e8eceb; }

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

.btn {
  min-height: var(--tap);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border-radius: var(--r);
  border: 2px solid transparent;
  font-family: "Archivo", sans-serif;
  font-weight: 600;
  font-size: 1.0625rem;
  padding: .75rem 1.25rem;
}
.btn--primary { background: var(--signal); color: #fff; }
.btn--primary:hover { background: var(--signal-dk); }
.btn--secondary { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn--secondary:hover { background: #e4e8e8; }
.btn--inspection { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.75); margin-top: .5rem; }
.btn--ghost {
  min-height: 44px;
  background: none;
  border: none;
  color: var(--signal-dk);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
}
.btn--ghost.on-dark { color: #9fd0ff; }
.danger-link { color: var(--danger); width: 100%; }
.actions { margin-top: auto; display: flex; flex-direction: column; gap: .625rem; }

.project {
  width: 100%; min-height: var(--tap); display: flex; align-items: center; gap: .75rem;
  padding: .625rem 1rem; background: none; border: 0; border-bottom: 1px solid rgba(255,255,255,.16); color: #fff; text-align: left;
}
.project__label { flex: 1; min-width: 0; }
.project__label .mono { display: block; color: #9aa6ae; font-size: .6875rem; }
.project__name {
  display: block; font-family: "Archivo", sans-serif; font-weight: 600; font-size: 1.0625rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.project__swap { flex: 0 0 auto; font-size: .875rem; color: #9fd0ff; text-decoration: underline; text-underline-offset: 3px; }
.project--empty .project__name { color: var(--focus); }
.project--light { border-bottom: 0; color: var(--ink); padding: 0; min-height: 0; }
.project--light .project__label .mono { color: var(--ink-2); }
.project--light .project__swap { color: var(--signal-dk); }
.project:disabled { cursor: default; opacity: 1; }

.camera { flex: 1; display: flex; flex-direction: column; background: var(--ink); color: #fff; }
.mode-switch {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: .75rem 1rem 0; background: var(--ink);
}
.mode-switch__button {
  min-height: 44px; border: 1px solid rgba(255,255,255,.28); background: transparent; color: #c3cbd1; border-radius: 10px; font-weight: 600;
}
.mode-switch__button.is-active { background: #fff; color: var(--ink); border-color: #fff; }
.camera__hint { padding: 1rem 1.25rem .75rem; text-align: center; }
.camera__hint h1 { margin: 0; font-size: 1.25rem; }
.camera__hint p { margin: .35rem auto 0; max-width: 430px; color: #c3cbd1; font-size: .9375rem; line-height: 1.35; }
.camera__stage { flex: 1; min-height: 300px; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.viewfinder { position: absolute; inset: 0; background: repeating-linear-gradient(115deg,#1b242c 0 22px,#1e282f 22px 44px); }
.reticle { position: relative; width: min(74%,300px); aspect-ratio: 1; border-radius: var(--r); }
.reticle span { position: absolute; width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.85); }
.reticle span:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: var(--r) 0 0 0; }
.reticle span:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 var(--r) 0 0; }
.reticle span:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 var(--r); }
.reticle span:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 var(--r) 0; }
.geo-chip, .inspection-chip {
  position: absolute; left: 1rem; right: 1rem; border-radius: 10px; backdrop-filter: blur(8px); background: rgba(8,12,16,.72); border: 1px solid rgba(255,255,255,.18);
}
.geo-chip { top: .75rem; padding: .5rem .75rem; font-size: .8125rem; color: #dfe5e8; width: max-content; right: auto; max-width: calc(100% - 2rem); }
.inspection-chip { bottom: .75rem; padding: .625rem .75rem; display: grid; grid-template-columns: 1fr auto; gap: .1rem .75rem; }
.inspection-chip .mono { grid-column: 1 / -1; color: #aeb9bf; font-size: .6875rem; }
.inspection-chip strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.camera__controls { padding: 1.25rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: .15rem; background: linear-gradient(to top,#0b0f13,rgba(11,15,19,0)); }
.shutter { width: 84px; height: 84px; border-radius: 50%; background: #fff; border: 5px solid rgba(255,255,255,.4); background-clip: padding-box; display: grid; place-items: center; }
.shutter:hover { background: #e6eaec; background-clip: padding-box; }
.shutter svg { width: 32px; height: 32px; color: var(--ink); }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.body { padding: 1.25rem 1rem 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; flex: 1; }
.shot { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: var(--r); border: 1px solid var(--line); background: #77848b; }
.disclosure { border: 1px solid var(--line); border-radius: var(--r); background: var(--paper-2); }
.disclosure__toggle { width: 100%; min-height: var(--tap); display: flex; align-items: center; gap: .625rem; padding: .875rem 1rem; background: none; border: 0; text-align: left; font-weight: 600; color: var(--ink); font-family: "Archivo",sans-serif; font-size: 1rem; border-radius: var(--r); }
.disclosure__toggle .plus { flex: 0 0 24px; height: 24px; display: grid; place-items: center; color: var(--signal-dk); font-size: 1.375rem; line-height: 1; }
.disclosure__toggle .opt { margin-left: auto; font-family: "Inter Tight",sans-serif; font-weight: 400; color: var(--ink-2); font-size: .875rem; }
.disclosure__toggle[aria-expanded="true"] .plus { transform: rotate(45deg); }
.disclosure__panel { padding: 1rem; border-top: 1px solid var(--line); }
.disclosure__panel[hidden] { display: none; }
label.field { display: block; font-weight: 600; font-size: .9375rem; margin-bottom: .375rem; }
.hint { color: var(--ink-2); font-size: .875rem; margin: 0 0 .625rem; }
.input-row { display: flex; gap: .5rem; align-items: flex-start; }
textarea, .text-input, .newform input { flex: 1; min-width: 0; font: inherit; color: var(--ink); padding: .75rem; border: 2px solid var(--line); border-radius: 10px; background: var(--paper-2); }
textarea { min-height: 104px; resize: none; }
textarea:focus, .text-input:focus, .newform input:focus { border-color: var(--signal); }
.mic { flex: 0 0 var(--tap); width: var(--tap); height: var(--tap); border: 2px solid var(--ink); border-radius: 10px; background: var(--paper-2); display: grid; place-items: center; color: var(--ink); }
.mic svg { width: 24px; height: 24px; }
.mic-status { margin: .5rem 0 0; font-size: .875rem; color: var(--ink-2); min-height: 1.25em; }

.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; flex: 1; padding: 2rem; text-align: center; }
.loading strong { font-family: "Archivo",sans-serif; font-size: 1.2rem; }
.loading p { margin: .4rem 0 0; color: var(--ink-2); }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--signal); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.verdict { border-radius: var(--r); padding: 1.125rem 1.25rem; color: #fff; display: flex; gap: .875rem; align-items: flex-start; }
.verdict--sure { background: var(--signal); }
.verdict--check { background: var(--caution); }
.verdict--unknown { background: var(--unknown); }
.verdict__icon { flex: 0 0 32px; height: 32px; }
.verdict__icon svg { width: 32px; height: 32px; }
.verdict h2 { margin: 0; font-size: 1.375rem; line-height: 1.25; }
.verdict p { margin: .25rem 0 0; font-size: .9375rem; color: rgba(255,255,255,.92); }
.verdict .mono { display: block; margin-bottom: .25rem; color: rgba(255,255,255,.85); }
dl.details { margin: 0; border-top: 1px solid var(--line); }
dl.details div { display: flex; gap: 1rem; justify-content: space-between; padding: .75rem 0; border-bottom: 1px solid var(--line); }
dl.details dt { color: var(--ink-2); font-size: .9375rem; flex: 0 0 auto; }
dl.details dd { margin: 0; text-align: right; font-weight: 500; overflow-wrap: anywhere; }
.note { background: var(--paper-2); border: 1px solid var(--line); border-left: 4px solid var(--ink-2); border-radius: 8px; padding: .875rem 1rem; }
.note--caution { border-left-color: var(--caution); }
.note h3 { margin: 0 0 .25rem; font-size: .875rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.note p { margin: 0; }
.saved { margin: 0; color: var(--ink-2); display: flex; align-items: center; gap: .5rem; }
.saved::before { content: ""; flex: 0 0 8px; height: 8px; border-radius: 50%; background: var(--signal); }
.saved span { color: var(--ink); font-weight: 500; }

.history-list { display: flex; flex-direction: column; gap: .75rem; }
.history-item { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .5rem; padding: .65rem; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r); }
.history-item__open { min-width: 0; display: grid; grid-template-columns: 92px minmax(0,1fr); gap: .875rem; align-items: center; padding: .1rem; border: 0; background: none; color: var(--ink); text-align: left; border-radius: 10px; }
.history-item__open:hover { background: #edf0f0; }
.history-item img { width: 92px; height: 76px; object-fit: cover; border-radius: 9px; background: #d8dddf; }
.history-item__text { min-width: 0; display: block; }
.history-item__title { display: block; font-family: "Archivo",sans-serif; font-weight: 600; font-size: 1rem; overflow-wrap: anywhere; }
.history-item__meta { display: block; margin-top: .25rem; color: var(--ink-2); font-size: .875rem; overflow-wrap: anywhere; }
.history-item__actions { display: flex; flex-direction: column; gap: .35rem; align-self: center; }
.history-action { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--paper-2); color: var(--ink); }
.history-action:hover { background: #e8eceb; }
.history-action svg { width: 21px; height: 21px; }
.history-action--danger { color: var(--danger); }
.history-action--danger:hover { background: #fff0ee; }
.empty-state, .error-box { padding: 1rem; border: 1px dashed var(--line); border-radius: var(--r); color: var(--ink-2); background: var(--paper-2); }
.error-box { border-style: solid; border-left: 4px solid var(--danger); color: var(--ink); }
.summary-card { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem; }
.summary-card h2 { margin: 0 0 .5rem; font-size: 1.15rem; }
.summary-card p { margin: 0; }
.summary-list { display: flex; flex-direction: column; gap: .75rem; }
.summary-item { padding: .875rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--paper-2); }
.summary-item strong { display: block; margin-bottom: .25rem; font-family: "Archivo",sans-serif; }

.sheet[hidden] { display: none; }
.sheet { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; justify-content: flex-end; }
.sheet__scrim { position: absolute; inset: 0; background: rgba(8,12,16,.6); border: 0; }
.sheet__panel { position: relative; width: 100%; max-width: 520px; margin: 0 auto; background: var(--paper-2); border-radius: 20px 20px 0 0; padding: .75rem 1rem calc(1rem + env(safe-area-inset-bottom)); max-height: 82dvh; overflow-y: auto; animation: rise .18s ease-out; }
@keyframes rise { from { transform: translateY(14px); } to { transform: none; } }
.sheet__grip { width: 44px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto .875rem; }
.sheet h2 { margin: 0 0 .75rem; font-size: 1.125rem; }
.sheet__list { list-style: none; margin: 0 0 .5rem; padding: 0; }
.sheet__list li { border-bottom: 1px solid var(--line); }
.sheet__item { width: 100%; min-height: var(--tap); display: flex; align-items: center; gap: .75rem; padding: .75rem .25rem; background: none; border: 0; text-align: left; font-size: 1.0625rem; color: var(--ink); }
.sheet__item:hover { background: #edf0f0; }
.sheet__item .tick { flex: 0 0 22px; height: 22px; color: var(--signal); }
.sheet__item .tick svg { width: 22px; height: 22px; }
.sheet__item[aria-current="true"] { font-weight: 600; }
.sheet__item .meta { margin-left: auto; font-size: .8125rem; color: var(--ink-2); }
.sheet__new { width: 100%; min-height: var(--tap); display: flex; align-items: center; gap: .625rem; padding: .75rem .25rem; background: none; border: 0; text-align: left; font-family: "Archivo",sans-serif; font-weight: 600; font-size: 1.0625rem; color: var(--signal-dk); }
.sheet__new .plus { font-size: 1.5rem; line-height: 1; }
.newform[hidden] { display: none; }
.newform { display: flex; flex-direction: column; gap: .625rem; padding-top: .5rem; }
.newform .row { display: flex; gap: .5rem; }
.newform .row .btn { width: auto; flex: 1; }
.sheet-actions { margin-top: 1rem; }

[hidden] { display: none !important; }
dialog { border: 0; border-radius: 18px; padding: 1.25rem; width: min(calc(100% - 2rem), 520px); max-height: calc(100dvh - 2rem); overflow-y: auto; color: var(--ink); background: var(--paper-2); }
dialog::backdrop { background: rgba(8,12,16,.65); }
dialog h2 { margin: 0 0 .5rem; }
.dialog-actions { margin-top: 1rem; }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.edit-grid .field { margin: 0; }
.edit-grid .field input, .edit-grid .field textarea { display: block; width: 100%; margin-top: .35rem; }
.edit-grid__wide { grid-column: 1 / -1; }
.edit-grid textarea { min-height: 86px; }
@media (max-width: 520px) {
  .edit-grid { grid-template-columns: 1fr; }
  .edit-grid__wide { grid-column: auto; }
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .spinner { animation: none; }
}
@media (prefers-contrast: more) { :root { --line: #5a666b; } }
