/* PsiTools: a dark, quiet theme. */

:root {
    --bg: #05070d;
    --surface: #0e1220;
    --surface-2: #161b2e;
    --border: #262d47;
    --text: #e7e9f2;
    --muted: #9298b0;
    --accent: #8fa8ff;
    --accent-strong: #5b7cfa;
    --accent-text: #0b1023;
    --danger: #ff6b7a;
    --success: #5fd39a;
    --warn: #f4c06a;
    --radius: 12px;
    --topbar-height: 56px;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; font-weight: 600; }
h1:focus { outline: none; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; font-weight: 600; }

.icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.25em; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Loading */

.loading-screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.loading-psi { font-family: "Times New Roman", serif; font-size: 3.5rem; color: #fff; animation: pulse 2.5s ease-in-out infinite; user-select: none; }
@keyframes pulse { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }

/* ---- Top bar and banners */

.topbar {
    position: sticky; top: 0; z-index: 20;
    height: var(--topbar-height);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px; padding-top: env(safe-area-inset-top);
    background: rgba(5, 7, 13, .9); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .5rem; color: var(--text); font-weight: 600; }
.brand:hover { text-decoration: none; }
.psi { font-family: "Times New Roman", serif; font-size: 1.8rem; line-height: 1; color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.status-chip, .user-chip {
    display: inline-flex; align-items: center; gap: .35rem;
    height: 36px; padding: 0 .7rem; border-radius: 18px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font: inherit; font-size: .9rem; cursor: pointer;
}
.user-chip:hover { text-decoration: none; border-color: var(--accent); }
.user-name { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-chip.online { color: var(--success); }
.status-chip.offline { color: var(--muted); }
.status-chip.error { color: var(--warn); }

.banner { padding: .55rem 16px; background: var(--surface-2); color: var(--muted); font-size: .9rem; border-bottom: 1px solid var(--border); }
.banner.warn { color: var(--warn); }

main { padding-bottom: 48px; }
main.bare { padding: 0; }

/* ---- Pages and panels */

.page { max-width: 980px; margin: 0 auto; padding: 20px 16px; }
.page.narrow { max-width: 560px; }
.page-header { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-header h1 { flex: 1; min-width: 0; }
.page-header-actions { display: flex; gap: .5rem; align-items: center; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.section-title { margin-top: 1.5rem; color: var(--muted); font-size: .95rem; text-transform: uppercase; letter-spacing: .06em; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.error { color: var(--danger); margin: .5rem 0; }
.success { color: var(--success); margin: .5rem 0; }
.warn-text { color: var(--warn); }
.hint { display: block; color: var(--muted); font-size: .85rem; margin-top: .25rem; }

/* ---- Forms */

label { display: block; margin-bottom: .9rem; font-size: .92rem; color: var(--muted); }
label > input:not([type=checkbox]), label > textarea, label > select { margin-top: .3rem; }
input:not([type=checkbox]), textarea, select {
    display: block; width: 100%;
    padding: .6rem .75rem; border-radius: 8px;
    border: 1px solid var(--border); background: var(--bg); color: var(--text);
    font: inherit; font-size: 1rem;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-strong); outline-offset: 0; border-color: transparent; }
input:disabled { opacity: .6; }
textarea { resize: vertical; }
label.check { display: flex; gap: .55rem; align-items: flex-start; color: var(--text); cursor: pointer; }
label.check input { width: 1.1rem; height: 1.1rem; margin: .2rem 0 0; accent-color: var(--accent-strong); flex: none; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.field { margin-bottom: 1.1rem; }
.field-label { display: block; font-size: .92rem; color: var(--muted); margin-bottom: .4rem; }

.button {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    min-height: 40px; padding: .5rem 1rem; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
    font: inherit; font-weight: 500; cursor: pointer; text-decoration: none;
}
.button:hover { border-color: var(--accent); text-decoration: none; }
.button:disabled { opacity: .45; cursor: default; border-color: var(--border); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.button.primary:hover:not(:disabled) { background: #a9bcff; }
.button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.button.big { min-height: 52px; padding: .7rem 2rem; font-size: 1.1rem; }
.button-row { display: flex; gap: .6rem; justify-content: flex-end; align-items: center; flex-wrap: wrap; margin-top: 1rem; }
.button-row > .muted { margin-right: auto; }
.icon-button {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 8px; border: 1px solid transparent;
    background: transparent; color: var(--text); cursor: pointer;
}
.icon-button:hover:not(:disabled) { border-color: var(--border); background: var(--surface-2); }
.icon-button:disabled { opacity: .35; cursor: default; }
.icon-button.danger { color: var(--danger); }
.link-button { background: none; border: none; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.link-button:hover { text-decoration: underline; }
.small-link { display: block; text-align: center; margin-top: 1rem; font-size: .9rem; }

/* ---- Sign-in pages */

.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px 24px; }
.auth-card h1 { text-align: center; margin-bottom: 1.2rem; }
.auth-card .button.primary { width: 100%; margin-top: .4rem; }
.auth-logo { text-align: center; font-family: "Times New Roman", serif; font-size: 3rem; line-height: 1; color: var(--accent); margin-bottom: .5rem; }

/* ---- Home */

.home { max-width: 760px; margin: 0 auto; padding: 24px 16px; display: flex; flex-direction: column; align-items: center; }
.home-disk { position: relative; width: min(56vw, 300px); aspect-ratio: 1; animation: disk-in 4.8s ease-out both; }
.home-disk img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.home-disk .disk2 { opacity: 0; animation: disk2 4.8s linear forwards; }
.home-disk .disk1 { animation: disk1 4.8s linear forwards; }
.home-disk .vignette { position: absolute; inset: 0; background: radial-gradient(circle, transparent 33%, rgba(5,7,13,.75) 66%, var(--bg) 100%); }
@keyframes disk-in { from { transform: rotate(-90deg); opacity: 0; } to { transform: rotate(0); opacity: 1; } }
@keyframes disk1 { 0%, 35% { opacity: 1; } 100% { opacity: 0; } }
@keyframes disk2 { 0%, 35% { opacity: 0; } 100% { opacity: 1; } }
.home-greeting { color: var(--muted); margin: .5rem 0 1.5rem; }
.tiles { width: 100%; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.tile {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .7rem;
    aspect-ratio: 1.15; border-radius: 16px; border: 1px solid var(--border); background: var(--surface);
    color: var(--text); font-weight: 600; transition: transform .15s, border-color .15s;
}
.tile:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.tile .icon { width: 44px; height: 44px; color: var(--accent); }

/* ---- Tables and lists */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.list { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.list th, table.list td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.list th { color: var(--muted); font-weight: 500; background: var(--surface); }
table.list tr:last-child td { border-bottom: none; }
table.list tr.dimmed td { opacity: .5; }
table.list td.actions { text-align: right; }

.session-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.session-list li { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.session-main { flex: 1; min-width: 0; color: var(--text); display: flex; flex-direction: column; }
.session-main:hover { text-decoration: none; }
.session-main:hover .session-title { color: var(--accent); }
.session-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-meta { color: var(--muted); font-size: .85rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: .25rem; color: var(--warn); font-size: .8rem; }
.badge.subtle { color: var(--muted); }
label.keep { display: flex; align-items: center; gap: .35rem; margin: 0; font-size: .85rem; white-space: nowrap; cursor: pointer; }
label.keep input { width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--accent-strong); }

/* ---- Modal */

.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.65); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 0 18px; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 14px 18px 18px; }
.modal.card-modal { max-width: 640px; }

/* ---- New reading */

.steps { display: flex; list-style: none; padding: 0; margin: 0 0 16px; gap: 6px; counter-reset: step; }
.steps li { flex: 1; text-align: center; padding: .4rem; font-size: .85rem; color: var(--muted); border-bottom: 2px solid var(--border); counter-increment: step; }
.steps li::before { content: counter(step) ". "; }
.steps li.current { color: var(--text); border-color: var(--accent); }
.steps li.done { color: var(--accent); border-color: var(--accent-strong); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: .5rem; }
.chip {
    display: inline-flex; align-items: center; gap: .3rem; min-height: 34px; padding: .25rem .75rem;
    border-radius: 17px; border: 1px solid var(--border); background: var(--bg); color: var(--text);
    font: inherit; font-size: .88rem; cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip.selected { background: var(--surface-2); border-color: var(--accent-strong); padding: .25rem .35rem; cursor: default; }
.chip-star, .chip-x { display: inline-flex; border: none; background: none; color: var(--muted); padding: 2px; cursor: pointer; }
.chip.primary .chip-star { color: var(--warn); }
.chip.primary .chip-star .icon { fill: currentColor; }
.chip-x:hover, .chip-star:hover { color: var(--text); }

.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented button { padding: .5rem .9rem; border: none; background: var(--bg); color: var(--text); font: inherit; font-size: .92rem; cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button.on { background: var(--accent); color: var(--accent-text); }
.segmented button:disabled { opacity: .4; cursor: default; }

details.more { margin: .5rem 0 1rem; }
details.more summary { cursor: pointer; color: var(--accent); margin-bottom: .75rem; }

.question-recap { font-style: italic; margin: 0 0 1rem; }
.question-recap.big { font-size: 1.25rem; }

.spread-choices { display: flex; flex-direction: column; gap: 8px; }
.spread-option {
    display: flex; flex-direction: column; gap: .15rem; text-align: left; width: 100%;
    padding: .7rem .9rem; border-radius: 10px; border: 1px solid var(--border); background: var(--bg);
    color: var(--text); font: inherit; cursor: pointer;
}
.spread-option:hover { border-color: var(--accent); }
.spread-option.recommended { border-width: 2px; border-color: var(--accent-strong); }
.spread-option.selected { background: var(--surface-2); box-shadow: inset 4px 0 0 var(--accent); }
.spread-option.other { opacity: .85; }
.spread-name { font-weight: 600; }
.recommended-label { display: inline-flex; align-items: center; gap: .2rem; color: var(--warn); font-size: .8rem; margin-right: .4rem; }
.recommended-label .icon { fill: currentColor; width: 1em; height: 1em; }
.spread-why { color: var(--muted); font-size: .88rem; }
.option-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.option-letter { width: 1.5rem; font-weight: 700; color: var(--accent); }
.deck-line { margin: 0; }
.deck-override { margin-top: .5rem; display: flex; flex-direction: column; gap: .5rem; }

/* ---- Draw */

.draw-actions { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .5rem; margin: 1rem 0; }
.draw-actions p { margin: 0; }
.hold-button { min-width: 220px; min-height: 56px; font-size: 1.05rem; touch-action: none; user-select: none; -webkit-user-select: none; }
.hold-button.holding { background: var(--accent-strong); border-color: var(--accent-strong); transform: scale(.97); }

.fan { display: flex; flex-wrap: wrap; justify-content: center; padding: 8px 24px 8px 8px; margin: 0 auto; max-width: 900px; }
.fan-card { width: 52px; margin-right: -22px; margin-bottom: 8px; padding: 0; border: none; background: none; cursor: pointer; transition: transform .12s; }
.fan-card img { display: block; width: 100%; border-radius: 4px; box-shadow: 0 2px 6px rgba(0,0,0,.6); }
.fan-card:hover:not(:disabled) { transform: translateY(-8px); }
.fan-card.taken { visibility: hidden; }
.fan.disabled .fan-card { cursor: default; }
.fan.shuffling .fan-card:nth-child(odd) { animation: jiggle .2s linear infinite alternate; }
.fan.shuffling .fan-card:nth-child(even) { animation: jiggle .2s linear infinite alternate-reverse; }
@keyframes jiggle { from { transform: translate(-2px, 1px) rotate(-2deg); } to { transform: translate(2px, -1px) rotate(2deg); } }
@media (min-width: 720px) { .fan-card { width: 64px; margin-right: -28px; } }

/* ---- Spread layout */

.spread-wrap { display: flex; justify-content: center; margin: 8px 0; }
.spread { position: relative; width: 100%; }
.slot { position: absolute; display: flex; flex-direction: column; align-items: center; padding: 0 4%; }
.slot .card-face, .slot-empty { width: 100%; aspect-ratio: 400 / 691; }
.slot-empty { border: 1px dashed var(--border); border-radius: 6px; }
.slot.next .slot-empty { border: 2px solid var(--accent); box-shadow: 0 0 12px rgba(143,168,255,.4); }
.slot-label { font-size: clamp(.6rem, 1.6vw, .8rem); color: var(--muted); text-align: center; line-height: 1.15; margin-top: 3px; overflow: hidden; max-height: 2.4em; }
.slot.next .slot-label { color: var(--accent); }

.card-face { display: block; padding: 0; border: none; background: none; border-radius: 6px; cursor: pointer; }
.card-face:disabled { cursor: default; }
.card-face img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 6px; box-shadow: 0 2px 10px rgba(0,0,0,.6); }
.card-face.up { animation: flip-in .35s ease-out; }
@keyframes flip-in { from { transform: rotateY(90deg); } to { transform: rotateY(0); } }

.card-details { display: grid; grid-template-columns: minmax(0, 200px) 1fr; gap: 18px; align-items: start; }
.card-details img { width: 100%; border-radius: 8px; }
.card-details dl { margin: 0; }
.card-details dt { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; margin-top: .6rem; }
.card-details dt:first-child { margin-top: 0; }
.card-details dd { margin: 0; }
.tag { display: inline-block; font-size: .72rem; padding: 0 .35rem; border: 1px solid var(--border); border-radius: 4px; color: var(--muted); }
@media (max-width: 560px) { .card-details { grid-template-columns: 1fr; } .card-details img { max-width: 180px; justify-self: center; } }

/* ---- Reading page */

.facts { display: flex; flex-wrap: wrap; gap: 6px; }
.facts span { font-size: .85rem; padding: .2rem .6rem; border-radius: 12px; background: var(--surface-2); color: var(--muted); }
.options-recap { margin: .75rem 0 0; padding-left: 1.2rem; }
dl.log { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; font-size: .9rem; }
dl.log dt { color: var(--muted); }
dl.log dd { margin: 0; overflow-wrap: anywhere; }

/* ---- Mindsight */

.exercise-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 1rem; }
.exercise-tile {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .8rem;
    padding: 1.6rem .8rem; border-radius: 20px; border: 1px solid var(--border); background: var(--surface);
    font: inherit; font-weight: 700; cursor: pointer; transition: transform .15s;
}
.exercise-tile:hover { transform: translateY(-2px); }
.exercise-tile:active { transform: scale(.96); }
.exercise-tile svg { width: 48px; height: 48px; }
.ex-colors { color: #fda4af; }
.ex-shapes, .ex-colorfulshapes { color: #7dd3fc; }
.ex-letters, .ex-colorfulletters { color: #6ee7b7; }
.ex-numbers, .ex-colorfulnumbers { color: #c4b5fd; }
.ex-words, .ex-colorfulwords { color: #fcd34d; }
.ex-pictures { color: #a5b4fc; }

.offline-photos { margin-top: 24px; }
.offline-photos progress { width: 100%; height: 10px; accent-color: var(--accent); }

.ms-overlay {
    position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center;
    overflow: hidden; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.ms-prep { background: #000; padding: 2rem; }
.ms-prep p { color: #fff; opacity: .8; font-size: clamp(1.8rem, 6vw, 3rem); font-weight: 700; text-align: center; animation: pulse 2.5s ease-in-out infinite; }
.ms-content { flex: 1; width: 100%; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.ms-shape { width: 100%; max-width: 80vw; max-height: 60vh; filter: drop-shadow(0 10px 15px rgba(0,0,0,.25)); }
.ms-text { font-weight: 900; text-align: center; line-height: 1; overflow-wrap: anywhere; font-size: clamp(6rem, 25vw, 15rem); }
.ms-text.long { font-size: clamp(3rem, 15vw, 8rem); }
.ms-text.outlined { text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000; }
.ms-image { max-width: 100%; max-height: 85vh; object-fit: contain; border-radius: 8px; pointer-events: none; box-shadow: 0 25px 50px rgba(0,0,0,.5); }
.ms-exit {
    margin-bottom: 2rem; padding: .75rem 2rem; border-radius: 999px; cursor: pointer;
    background: rgba(0,0,0,.2); color: #fff; border: 1px solid rgba(255,255,255,.2);
    font: inherit; font-size: .75rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; backdrop-filter: blur(4px);
}
.ms-exit:hover { background: rgba(0,0,0,.4); }

/* ---- Small screens */

@media (max-width: 560px) {
    .brand-name, .user-name { display: none; }
    .row-2 { grid-template-columns: 1fr; }
    .session-list li { flex-wrap: wrap; }
    label.keep span { display: none; }
    .segmented { display: flex; }
    .segmented button { flex: 1; }
}

/* ---- Blazor error UI */

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow; color: #222;
    bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none; left: 0; padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "An error has occurred."; }

/* Card work: AI classification and interpretation */
.restate { border: 1px solid var(--accent-strong); border-radius: var(--radius); padding: .75rem 1rem; margin: 0 0 1rem; }
.restate p { margin: 0 0 .25rem; }
.restate .button-row { margin-top: .5rem; }
.chip.suggested { border-style: dashed; border-color: var(--accent); }
.verdict { border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem; background: var(--surface-2); border-left: 4px solid var(--muted); }
.verdict.positive { border-left-color: var(--success); }
.verdict.negative { border-left-color: var(--danger); }
.verdict-value { font-size: 1.3rem; font-weight: 600; margin-right: .75rem; }
.verdict-confidence { color: var(--muted); font-size: .9rem; }
.verdict-condition { margin: .35rem 0 0; }
.timing .hint { margin-top: .1rem; }
.synthesis { line-height: 1.6; }
.panel h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; font-weight: 600; }
.position-readings, .predictions { list-style: none; padding: 0; margin: 0; }
.position-readings li, .predictions li { padding: .5rem 0; border-top: 1px solid var(--border); }
.position-head { display: block; margin-bottom: .15rem; }
.tag.warn { color: var(--warn); border-color: var(--warn); margin-left: .35rem; }
.option-reading { margin-bottom: .75rem; }
.prediction-deadline { display: inline-block; min-width: 7.5rem; color: var(--accent); font-variant-numeric: tabular-nums; }
pre.raw { white-space: pre-wrap; word-break: break-word; font-size: .8rem; background: var(--surface-2); padding: .75rem; border-radius: 8px; max-height: 24rem; overflow: auto; }
