:root {
    --bg: #0d0f12;
    --panel: #171a1f;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --accent: #8ab4f8;
    --error: #f28b82;
    --line: #262a31;
}

/* Rules below set display on elements that are also hidden with the hidden attribute. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, "Segoe UI", Arial, sans-serif;
}

body {
    display: flex;
    flex-direction: column;
}

header {
    display: flex;
    flex-wrap: wrap;            /* on a phone a long status moves to its own line */
    align-items: center;
    gap: 8px 16px;
    padding: 10px 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.15;
    white-space: nowrap;
}

h1 small {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: var(--muted);
}

.button {
    padding: 6px 14px;
    border-radius: 6px;
    background: var(--accent);
    color: #0d0f12;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

#status {
    color: var(--muted);
    font-size: 14px;
}

#status.busy::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-inline-end: 8px;
    border: 2px solid var(--accent);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: -1px;
}

#status.error { color: var(--error); }

@keyframes spin { to { transform: rotate(360deg); } }

#stage {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#view {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: grab;
    touch-action: none;
}

#view:active { cursor: grabbing; }

#empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.8;
    color: var(--muted);
    pointer-events: none;
}

#stage.dragover { outline: 3px dashed var(--accent); outline-offset: -12px; }

/* Over a photo of a person, once zoomed in: no detail is generated. */
#note {
    position: absolute;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    color: #fff;
    font-size: 13px;
    letter-spacing: 0.08em;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

/* ---- depth gauge: a logarithmic bar from the whole image down to quarks ---- */

#gauge {
    padding: 8px 16px;
    background: var(--panel);
    border-top: 1px solid var(--line);
}

#gaugeBar {
    position: relative;
    display: flex;
    height: 20px;
}

/* One segment per stage; its flex-grow is the number of decades the stage spans. */
#gaugeBar .seg {
    flex-basis: 0;
    min-width: 0;
    overflow: hidden;
    text-align: center;
    font-size: 11px;
    line-height: 20px;
    color: var(--muted);
    background: #22262d;
    box-shadow: inset -1px 0 0 var(--bg);
}

#gaugeBar .seg.current {
    background: #2f4468;
    color: var(--text);
}

#gaugeMark {
    position: absolute;
    top: -3px;
    bottom: -3px;
    width: 2px;
    margin-left: -1px;
    background: var(--accent);
}

#gaugeLabel {
    margin-top: 6px;
    font-size: 13px;
    color: var(--muted);
}

/* ---- material panel ---- */

#panel {
    background: var(--panel);
    border-top: 1px solid var(--line);
    font-size: 14px;
}

#panel summary {
    padding: 8px 16px;
    cursor: pointer;
}

#caption { font-weight: 600; }

#materialName { color: var(--muted); }

#materialName:not(:empty)::before { content: " \00b7  "; }   /* " · ": the first space after the escape only ends it */

#panelBody {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0 24px;
    max-height: 40vh;
    padding: 0 16px 8px;
    overflow-y: auto;
}

@media (max-width: 700px) {
    #panelBody { grid-template-columns: 1fr; }
}

#panel h2 {
    margin: 4px 0;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

#panel p {
    margin: 0 0 8px;
    line-height: 1.4;
}

.estimate {
    margin-inline-start: 6px;
    padding: 0 6px;
    border: 1px solid #3a3f47;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    color: var(--muted);
}

.comp {
    display: grid;
    grid-template-columns: minmax(90px, 40%) 1fr 60px;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.comp-bar {
    height: 8px;
    border-radius: 4px;
    background: var(--line);
    overflow: hidden;
}

.comp-bar i {
    display: block;
    height: 100%;
    background: var(--accent);
}

.comp-pct {
    text-align: end;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

footer {
    padding: 4px 16px;
    border-top: 1px solid var(--line);
    background: var(--panel);
    color: var(--muted);
    font-size: 11px;
    text-align: center;
}

/* ---- account: name and sign-out in the header ---- */

#account {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-inline-start: auto;
    color: var(--muted);
    font-size: 14px;
}

.link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    cursor: pointer;
}

.link:hover { text-decoration: underline; }

/* ---- sign-in page ---- */

#signin {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.card {
    width: min(420px, 100%);
    padding: 28px 24px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    text-align: center;
}

.card h2 {
    margin: 0 0 8px;
    font-size: 20px;
}

.card p {
    margin: 0 0 16px;
    line-height: 1.5;
    color: var(--muted);
}

.card p.error { color: var(--error); }

.card .note { margin: 16px 0 0; font-size: 12px; }

.google {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    border-radius: 6px;
    background: #fff;
    color: #1f1f1f;
    font-weight: 600;
    text-decoration: none;
}

.google:hover { background: #f1f3f4; }
