:root {
  --bg: #0d1420;
  --panel: #131d2d;
  --panel-2: #1a2639;
  --border: #2a3a52;
  --text: #cfe6ff;
  --muted: #8ea3bb;
  --primary: #2f7df6;
  --primary-text: #fff;
  --green: #7bd88f;
  --yellow: #ffd24a;
  --red: #ff6b5e;
  --neutral: #9fb3c8;
  --radius: 8px;
  --header-h: 40px; /* slim site header on patient/doctor pages */
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
a { color: var(--primary); }
[hidden] { display: none !important; }

.lang-switch { position: fixed; top: 10px; right: 10px; display: flex; gap: 4px; z-index: 50; }
.lang-btn { background: var(--panel); color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 3px 9px; font: inherit; font-size: 12px; cursor: pointer; }
.lang-btn.active { color: var(--text); border-color: var(--primary); }

/* ---------- site header and footer ---------- */
.site-header { height: var(--header-h); display: flex; align-items: center; padding: 0 14px; border-bottom: 1px solid var(--border); background: var(--panel); }
.brand { color: var(--text); font-weight: 700; text-decoration: none; letter-spacing: .02em; }
.brand:hover, .brand:focus-visible { color: var(--primary); }
.site-footer { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; padding: 14px 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.site-footer a { color: var(--muted); }
.site-footer a:hover, .site-footer a:focus-visible { color: var(--text); }
@media print { .site-header, .site-footer { display: none; } }

/* ---------- imprint and privacy ---------- */
.legal { max-width: 720px; margin: 0 auto; padding: 40px 16px 32px; overflow-wrap: anywhere; }
.legal h1 { font-size: 1.9rem; margin-top: .6em; }
.legal h2 { font-size: 1.15rem; margin-top: 1.6em; }
.legal section + section { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border); }
.legal.one-lang section + section { margin-top: 0; padding-top: 0; border-top: 0; }
.legal dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; }
.legal dt { color: var(--muted); }
.legal dd { margin: 0; }
@media (max-width: 560px) {
  .legal dl { grid-template-columns: 1fr; }
  .legal dd { margin-bottom: 6px; }
}

/* ---------- landing ---------- */
.landing { max-width: 1120px; margin: 0 auto; padding: 56px 16px 40px; overflow-wrap: anywhere; }
.landing h1 { font-size: 2.4rem; }
.landing h2 { font-size: 1.5rem; }
.landing h3 { font-size: 1.05rem; margin-bottom: .3em; }
.landing p { color: var(--text); }
.landing img { display: block; max-width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--panel); }
.landing-hero { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 32px; align-items: center; }
.landing-tagline { font-size: 1.25rem; font-weight: 600; }
.landing-hero .btn { margin-top: 6px; }
.landing-shot { box-shadow: 0 8px 32px rgba(0, 0, 0, .45); }
.landing-section { margin-top: 56px; padding-top: 32px; border-top: 1px solid var(--border); }
.landing-how { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 32px; align-items: start; }
.landing-how h2 { grid-column: 1 / -1; }
.landing-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.landing-steps li { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.landing-steps p { margin: 0; }
.landing-photos { display: grid; grid-template-columns: 9fr 16fr; gap: 12px; align-items: start; }
.landing-ai p, .landing-hw > p { max-width: 720px; }
.landing-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 12px 0; }
.landing-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; }
.landing-card p { flex: 1; margin-top: 0; }
.landing-card .btn { align-self: flex-start; text-decoration: none; }
.landing-affiliate { font-size: 13px; }
.landing > .disclaimer { margin-top: 40px; }
@media (max-width: 860px) {
  .landing-hero, .landing-how { grid-template-columns: minmax(0, 1fr); }
  .landing-photos { margin-top: 16px; }
}
@media (max-width: 560px) {
  .landing { padding-top: 48px; }
  .landing h1 { font-size: 2rem; }
  .landing-cards { grid-template-columns: minmax(0, 1fr); }
  .landing-section { margin-top: 40px; padding-top: 24px; }
}
.disclaimer { color: var(--muted); font-size: 13px; border-left: 3px solid var(--border); padding-left: 10px; }
.error { color: var(--red); }

.btn { display: inline-block; padding: 8px 16px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font: inherit; cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--primary); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn:focus-visible, .lang-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.thumb { border-radius: 6px; overflow: hidden; border: 1px solid var(--border); background: var(--panel); cursor: pointer; }
.thumb.selected { outline: 2px solid var(--primary); }
.thumb img { display: block; width: 100%; height: 90px; object-fit: cover; background: #000; }
.thumb .meta { padding: 5px 7px; font-size: 12px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.pill { display: inline-block; padding: 1px 7px; border-radius: 9px; font-weight: 700; font-size: 11px; color: #000; background: var(--neutral); }

.dialog-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .65); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.dialog { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; max-width: 560px; width: 100%; max-height: 90vh; overflow: auto; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 14px; z-index: 200; box-shadow: 0 4px 16px rgba(0, 0, 0, .4); }
.toast.error { border-color: var(--red); color: var(--red); }

.body-view { position: relative; background: var(--bg); overflow: hidden; min-height: 240px; }
.body-view-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.body-view-canvas:active { cursor: grabbing; }
.body-view-canvas.picking { cursor: crosshair; }
.body-view-canvas.over-marker { cursor: pointer; }
.body-view-reset { position: absolute; top: 8px; right: 8px; background: rgba(19, 29, 45, .85); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.body-view-reset:hover { border-color: var(--primary); }
.body-view-reset:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- patient page ---------- */
.muted { color: var(--muted); }
.btn.small { padding: 2px 8px; font-size: 12px; }
.btn.big { padding: 18px 28px; font-size: 18px; min-width: 150px; }
.thumb-open { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; }
.thumb-open:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.thumb-missing { height: 90px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 6px; font-size: 12px; color: var(--muted); background: var(--panel-2); }
.thumb .meta-2 { padding-top: 0; }
.thumb-n { font-weight: 700; }
.thumb-analysing { color: var(--muted); font-style: italic; }
.thumb.flash { animation: tile-flash 1.2s ease-out; }
@keyframes tile-flash { 0% { box-shadow: 0 0 0 4px var(--yellow); } 100% { box-shadow: 0 0 0 0 transparent; } }
.verdict { font-size: 11px; font-weight: 600; }
.verdict-ok { color: var(--green); }
.verdict-inspect { color: var(--red); }
.verdict-none { color: var(--muted); }

.patient { display: flex; height: calc(100vh - var(--header-h)); }
.patient-body { flex: 0 0 45%; position: relative; height: calc(100vh - var(--header-h)); }
.patient-side { flex: 1; min-width: 0; overflow-y: auto; padding: 14px 18px 40px; }
.patient-header { padding-right: 90px; }
.patient-header h1 { font-size: 1.5rem; margin-bottom: .2em; }
.patient-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 14px; }
.banner { display: flex; gap: 10px; align-items: center; justify-content: space-between; background: var(--panel-2); border: 1px solid var(--yellow); border-radius: var(--radius); padding: 8px 12px; margin: 8px 0; font-size: 14px; }
.body-hint { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-size: 12px; color: var(--muted); pointer-events: none; z-index: 2; }
.place-prompt { position: absolute; top: 44px; left: 12px; right: 12px; text-align: center; background: rgba(19, 29, 45, .9); border: 1px solid var(--primary); border-radius: var(--radius); padding: 8px 12px; z-index: 3; pointer-events: none; }
.corner-preview { position: absolute; left: 10px; bottom: 34px; width: 34%; max-width: 220px; border: 2px solid var(--text); border-radius: 6px; z-index: 3; pointer-events: none; background: #000; }

.capture-panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; }
.capture-panel h2 { font-size: 1.1rem; }
.cam-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.cam-row select { flex: 1; min-width: 0; }
select, input[type="text"] { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font: inherit; }
.cam-video { display: block; width: 100%; max-height: 50vh; background: #000; border-radius: 6px; object-fit: contain; }
.panel-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.panel-msg { margin: 8px 0 0; }
.panel-btns .btn:last-child { margin-left: auto; }
.ai-lines .disclaimer { margin: 0 0 6px; }
.moles-title { font-size: 1.1rem; margin-top: 14px; }

.dialog-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.sex-consent { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; font-size: 13px; color: var(--muted); }
.sex-consent input { margin-top: 3px; }
.scan-danger { margin-top: 32px; padding-top: 14px; border-top: 1px solid var(--border); }
.page-error a { margin-left: 8px; }
.sex-choice { display: flex; gap: 14px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.field input { width: 100%; }
.share-link { display: flex; gap: 8px; align-items: flex-end; }
.share-link .field { flex: 1; min-width: 0; }
.page-error { padding: 40px; }
/* only an error message left: shrink to content so the footer is in view */
.error-only { min-height: 0; }
.error-only .patient, .error-only .doctor { height: auto; }

@media (max-width: 760px) {
  /* stacked: the body is at the top, keep Reset view clear of the fixed language switch */
  .patient-body .body-view-reset, .doctor-body .body-view-reset { right: auto; left: 8px; }
  .patient { flex-direction: column; height: auto; }
  .patient-body { flex: none; height: 60vh; }
  .patient-side { overflow: visible; }
}

/* ---------- doctor page ---------- */
.doctor { display: flex; height: calc(100vh - var(--header-h)); }
.doctor-body { flex: 0 0 33.333%; min-width: 260px; position: relative; height: calc(100vh - var(--header-h)); }
.doctor-side { flex: 1; min-width: 0; overflow-y: auto; padding: 14px 18px 40px; }
.doctor-header { padding-right: 90px; margin-bottom: 8px; }
.doctor-title { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.doctor-title h1 { font-size: 1.5rem; margin: 0; }
.doctor-title .btn { text-decoration: none; }
.doctor-label { margin: 6px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.doctor-meta { margin: 2px 0 0; font-size: 14px; }
.doctor-counter { color: var(--text); }
.doctor .disclaimer { margin: 6px 0 12px; }
@media (max-width: 760px) {
  .doctor { flex-direction: column; height: auto; }
  .doctor-body { flex: none; height: 55vh; min-width: 0; }
  .doctor-side { overflow: visible; }
}

/* ---------- lightbox ---------- */
html.lb-open, html.lb-open body { overflow: hidden; }
.lightbox { position: fixed; inset: 0; z-index: 90; display: flex; background: rgba(5, 9, 15, .96); }
.lightbox:focus { outline: none; }
.lb-stage { position: relative; flex: 1; min-width: 0; overflow: hidden; touch-action: none; cursor: zoom-in; user-select: none; }
.lb-stage.zoomed { cursor: grab; }
.lb-stage.dragging { cursor: grabbing; }
.lb-img { position: absolute; transform-origin: 0 0; max-width: none; image-rendering: auto; }
.lb-missing { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.lb-zoom { position: absolute; left: 10px; top: 10px; z-index: 1; font-size: 12px; color: var(--muted); pointer-events: none; }
.lb-panel { flex: 0 0 320px; background: var(--panel); border-left: 1px solid var(--border); padding: 14px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.lb-top { display: flex; align-items: center; gap: 10px; }
.lb-title { margin: 0; font-size: 1.3rem; }
.lb-pos { font-size: 13px; }
.lb-close { margin-left: auto; padding: 2px 11px; font-size: 20px; line-height: 1.2; }
.lb-ai { flex: 0 0 auto; height: 10.5em; display: flex; flex-direction: column; gap: 4px; }
.lb-ai p { margin: 0; }
.lb-reason { flex: 1; min-height: 0; overflow-y: auto; overflow-wrap: anywhere; white-space: pre-wrap; }
.lb-verdicts { display: flex; flex-direction: column; gap: 8px; }
.lb-verdicts .btn { text-align: left; }
.lb-ok.active { background: var(--green); border-color: var(--green); color: #000; }
.lb-inspect.active { background: var(--red); border-color: var(--red); color: #000; }
.lb-verdict { margin: 0; font-weight: 600; }
.lb-note { margin-top: 0; }
.lb-note textarea { width: 100%; resize: vertical; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font: inherit; }
.lb-status { margin: 0; min-height: 1.5em; font-size: 13px; }
.lb-nav { display: flex; gap: 8px; }
.lb-hint { font-size: 12px; margin: 0; }
@media (max-width: 760px) {
  .lightbox { flex-direction: column; }
  .lb-panel { flex: 0 0 auto; max-height: 45vh; border-left: 0; border-top: 1px solid var(--border); }
}
