/*
   MyWeb's own styles, no Bifrost and no Bootstrap. One narrow column, white cards on a grey
   ground, one accent. «Covered» and «done» use the accent and nothing else: no colour here says
   good or bad (docs/05-compliance.md). System fonts, so nothing is fetched from a third party.
*/

:root {
    --bg: #F3F4F2;
    --surface: #FFFFFF;
    --surface-2: #F6F7F5;
    --ink: #16181A;
    --muted: #5D626A;
    --line: #E4E6E2;
    --line-strong: #C9CCC6;
    --off: #E4E6E2;
    --accent: #3346C8;
    --accent-hover: #24339A;
    --accent-ink: #FFFFFF;
    --accent-soft: #EEF0FB;
    --scrim: rgba(22, 24, 26, 0.4);
    --radius: 16px;
    --radius-sm: 12px;
    --column: 560px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111315;
        --surface: #1B1E21;
        --surface-2: #22262A;
        --ink: #EDEEEC;
        --muted: #A3A8AE;
        --line: #2C3035;
        --line-strong: #4A4F56;
        --off: #2F3338;
        --accent: #8C9BFF;
        --accent-hover: #AEB8FF;
        --accent-ink: #0E1330;
        --accent-soft: #232A55;
        --scrim: rgba(0, 0, 0, 0.6);
        color-scheme: dark;
    }
}

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

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

h1, h2, h3, p { margin: 0; }
h1:focus { outline: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon { flex: none; display: block; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.visually-hidden {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ── Shell: column and tab bar ── */

/* Installed on a home screen the page draws under the status bar and the home indicator
   (viewport-fit=cover), so the column, the tab bar and the public pages add the safe-area
   insets to their own padding. The insets are 0 in an ordinary browser tab. */

.shell { min-height: 100dvh; }

.shell-main {
    width: 100%; max-width: var(--column); margin: 0 auto;
    padding: calc(28px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) calc(104px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    display: flex; flex-direction: column; gap: 28px;
}

.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px max(8px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
.tabbar-inner { max-width: var(--column); margin: 0 auto; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tab {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    min-height: 44px; padding: 8px 0; border-radius: var(--radius-sm);
    color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 500;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); font-weight: 600; }

/* ── Page header ── */

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.page-head-text { display: flex; flex-direction: column; gap: 4px; }
.eyebrow { font-size: 14px; font-weight: 500; color: var(--muted); }
.page-title { font-size: 30px; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; }
.page-lead { font-size: 14px; color: var(--muted); }

/* The initial in the corner of «I dag»: a way to Innstillinger. */
.avatar {
    width: 44px; height: 44px; flex: none; border-radius: 22px;
    border: 1px solid var(--line); background: var(--surface); color: var(--ink);
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 600; text-decoration: none;
}
.avatar:hover { color: var(--ink); border-color: var(--line-strong); }

.back-link {
    align-self: flex-start; display: inline-flex; align-items: center; gap: 4px;
    min-height: 44px; margin: -12px 0 -16px -4px;
    color: var(--muted); text-decoration: none; font-size: 15px; font-weight: 500;
}
.back-link:hover { color: var(--ink); }

/* ── Sections and cards ── */

.section { display: flex; flex-direction: column; gap: 12px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head-stack { display: flex; flex-direction: column; gap: 2px; }
.section-title { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.section-meta { font-size: 14px; font-weight: 500; color: var(--muted); }

.card { background: var(--surface); border-radius: var(--radius); }
.stack { display: flex; flex-direction: column; gap: 8px; }

.context-link {
    display: flex; align-items: center; gap: 12px; padding: 14px 16px;
    border-radius: var(--radius); background: var(--surface); color: var(--ink); text-decoration: none;
}
.context-link:hover { color: var(--ink); background: var(--surface-2); }
.context-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.context-plan { font-size: 13px; font-weight: 500; color: var(--muted); }
.context-phase { font-size: 15px; font-weight: 600; }
.context-link .icon { color: var(--muted); }

.empty { padding: 20px 16px; border-radius: var(--radius); background: var(--surface); color: var(--muted); }

.notice { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; background: var(--surface); border: 1px solid var(--line-strong); }
.notice-error { border-color: var(--ink); }
.notice-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.notice-row button { border: 0; background: transparent; padding: 0 4px; font-weight: 600; color: var(--accent); }

/* ── Texts from the plans: a card each, crossed out with the button ── */

.text-card { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--accent-soft); }
.text-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.text-card-context { font-size: 13px; font-weight: 500; color: var(--muted); }
.text-card-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.text-card-text { font-size: 15px; line-height: 1.45; white-space: pre-wrap; }

/* ── Habits ── */

.progress { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; }
.progress span { height: 4px; border-radius: 2px; background: var(--off); }
.progress span.on { background: var(--accent); }

.habit {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 14px 14px 16px; border-radius: var(--radius); background: var(--surface);
}
.habit-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.habit-name { font-size: 16px; font-weight: 600; }
.habit-status { font-size: 13px; color: var(--muted); }

.dots { display: flex; gap: 4px; margin-top: 6px; }
.dot { width: 12px; height: 12px; border-radius: 4px; background: var(--off); }
.dot.on { background: var(--accent); }

.check {
    width: 52px; height: 52px; flex: none; border-radius: 26px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--line-strong); background: var(--surface); color: var(--muted);
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.check:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.check.done { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.check:disabled:not(.done) { opacity: 0.6; }

/* ── Things to record ── */

ul.rows { margin: 0; padding: 0; list-style: none; }
.rows { display: flex; flex-direction: column; border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.row {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px;
    padding: 12px 16px; border: 0; border-top: 1px solid var(--line);
    background: transparent; color: var(--ink); text-align: left;
}
.row:first-child { border-top: 0; }
button.row:hover { background: var(--surface-2); }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { font-size: 16px; font-weight: 600; }
.row-sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.row .icon { color: var(--muted); }
.row .icon.saved { color: var(--accent); }
.row-value { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; max-width: 45%; overflow-wrap: anywhere; }

/* ── Bottom sheet ── */

.sheet-layer { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.sheet-backdrop { position: absolute; inset: 0; border: 0; background: var(--scrim); cursor: default; }
.sheet {
    position: relative; width: 100%; max-width: var(--column); max-height: 92dvh; overflow-y: auto;
    display: flex; flex-direction: column; gap: 20px;
    padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
    border-radius: 24px 24px 0 0; background: var(--surface);
    animation: sheet-in 180ms ease-out;
}
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.sheet-grabber { align-self: center; width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sheet-title { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.sheet-form { display: flex; flex-direction: column; gap: 20px; }

.icon-button {
    width: 44px; height: 44px; flex: none; border-radius: 22px; border: 0;
    background: var(--surface-2); color: var(--ink);
    display: flex; align-items: center; justify-content: center;
}

.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 14px; font-weight: 600; }
.input, .textarea {
    width: 100%; padding: 0 16px; border-radius: 14px;
    border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: 16px;
}
.input { height: 52px; }
.input:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-big { height: 72px; font-size: 36px; font-weight: 600; font-variant-numeric: tabular-nums; }
.textarea { padding: 14px 16px; line-height: 1.45; resize: vertical; min-height: 120px; }
.field-help { font-size: 13px; line-height: 1.45; color: var(--muted); }

.choices { margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 8px; }
.choices legend { padding: 0; margin-bottom: 8px; font-size: 14px; font-weight: 600; }
.choice {
    display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 16px;
    border-radius: 14px; border: 1.5px solid var(--line-strong); background: var(--surface);
    font-size: 16px; font-weight: 500; text-align: left;
}
.choice-ring { width: 20px; height: 20px; flex: none; border-radius: 10px; border: 2px solid var(--line-strong); }
.choice[aria-pressed="true"] { border: 2px solid var(--accent); background: var(--accent-soft); }
.choice[aria-pressed="true"] .choice-ring { border: 6px solid var(--accent); }

.time-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.time-row strong { color: var(--ink); font-weight: 600; }
.link-button { min-height: 44px; padding: 0 4px; border: 0; background: transparent; color: var(--accent); font-size: 14px; font-weight: 600; }

/* ── Buttons ── */

.button {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px; padding: 0 18px; border-radius: 14px;
    border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink);
    font-size: 15px; font-weight: 600; text-decoration: none;
}
.button:hover { color: var(--ink); border-color: var(--ink); }
.button-primary { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.button-primary:hover { color: var(--accent-ink); border-color: var(--accent-hover); background: var(--accent-hover); }
.button-primary:disabled { border-color: var(--off); background: var(--off); color: var(--muted); }
.button-block { width: 100%; min-height: 56px; border-radius: var(--radius); font-size: 17px; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }
.button-row .button { flex: 1; }

/* ── Toast ── */

.toast {
    position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 30;
    transform: translateX(-50%); max-width: calc(100% - 40px);
    padding: 10px 16px; border-radius: 999px; background: var(--ink); color: var(--bg);
    font-size: 14px; font-weight: 500; text-align: center;
}

/* ── History grid ── */

.grid-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.grid-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.grid-head h3 { font-size: 16px; font-weight: 600; }
.days { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 4px; }
.day { height: 20px; border-radius: 4px; background: var(--off); }
.day.on { background: var(--accent); }
.day.now:not(.on) { box-shadow: inset 0 0 0 2px var(--line-strong); background: transparent; }
.grid-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.grid-foot strong { color: var(--ink); font-weight: 600; }
.coverage-line { padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

/* The latest registrations under the form in the record sheet. */
.recent { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.recent-title { font-size: 14px; font-weight: 600; }
.recent ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.recent li { display: flex; justify-content: space-between; gap: 12px; }
.recent li span:last-child { text-align: right; font-weight: 600; overflow-wrap: anywhere; }

/* ── Plans ── */

.plan { display: flex; flex-direction: column; gap: 18px; padding: 18px 16px; }
.plan-title { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.phases { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.phase { display: flex; gap: 14px; }
.phase-rail { display: flex; flex-direction: column; align-items: center; width: 24px; flex: none; }
.phase-mark {
    width: 24px; height: 24px; border-radius: 12px; flex: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; border: 2px solid var(--line-strong); color: var(--muted);
}
.phase.past .phase-mark { border: 0; background: var(--off); }
.phase.current .phase-mark { border: 0; background: var(--accent); color: var(--accent-ink); }
.phase-line { width: 2px; flex: 1; min-height: 16px; background: var(--line); }
.phase:last-child .phase-line { display: none; }
.phase-body { flex: 1; min-width: 0; padding: 2px 0 18px; display: flex; flex-direction: column; gap: 12px; }
.phase:last-child .phase-body { padding-bottom: 0; }
.phase-name { font-size: 15px; font-weight: 600; }
.phase.past .phase-name { color: var(--muted); }
.phase.current .phase-name { font-weight: 700; }
.phase-meta { font-size: 13px; color: var(--muted); }
.phase.current .phase-meta { color: var(--accent); font-weight: 600; }
.applies { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.applies-group { display: flex; flex-direction: column; gap: 4px; }
.applies-label { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.applies-items { font-size: 14px; line-height: 1.45; }

/* ── Public pages: login and registration ── */

.public {
    min-height: 100dvh; max-width: 440px; margin: 0 auto; display: flex; flex-direction: column;
    padding: calc(48px + env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.public-main { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 28px; padding: 40px 0; }
.public-intro { display: flex; flex-direction: column; gap: 8px; }
.public-intro h1 { font-size: 32px; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; }
.public-intro p { font-size: 16px; line-height: 1.45; color: var(--muted); }
.account-form { display: flex; flex-direction: column; gap: 16px; }
.account-form .button-block { margin-top: 8px; }
.account-alt { font-size: 15px; color: var(--muted); text-align: center; }
.account-alt a { font-weight: 600; text-decoration: none; }
.public-foot { font-size: 13px; color: var(--muted); text-align: center; }

/* ── Framework ── */

.blazor-error-boundary { padding: 1rem; border-radius: var(--radius-sm); background: var(--ink); color: var(--bg); }
.blazor-error-boundary::after { content: "Noe gikk galt."; }

/* ── Next of kin: read-only values, expandable ── */

.row-details { border-top: 1px solid var(--line); }
.row-details:first-child { border-top: 0; }
.row-details > summary { list-style: none; border-top: 0; cursor: pointer; }
.row-details > summary::-webkit-details-marker { display: none; }
.row-details > summary:hover { background: var(--surface-2); }
.entry-list { margin: 0; padding: 0 16px 12px; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.entry-list li { display: flex; justify-content: space-between; gap: 12px; }
.entry-list li span:last-child { text-align: right; overflow-wrap: anywhere; }
.entry-more { padding: 0 16px 12px; font-size: 13px; color: var(--muted); }
a.row { text-decoration: none; }
a.row:hover { color: var(--ink); background: var(--surface-2); }
.plan-share { align-self: flex-start; font-size: 14px; font-weight: 600; text-decoration: none; }
.public-text { font-size: 16px; line-height: 1.45; }

/* ── Settings ── */

.settings-card { display: flex; flex-direction: column; gap: 16px; padding: 18px 16px; }
.settings-card .button { align-self: flex-start; }
.people { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.person { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.person:first-child { border-top: 0; padding-top: 0; }
.person .button-row { flex-wrap: nowrap; }
.link-box { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.link-box-row { display: flex; gap: 8px; }
.link-box-row .input { flex: 1; min-width: 0; font-size: 14px; }
.link-button.muted { color: var(--muted); }

/* ── Rhythm on every requirement ── */

/* The squares under a row with a rhythm (I dag, the next of kin's view): the same dots as a habit, as spans inside the button. */
.row-text .dots { margin-top: 4px; }

/* A number against the one before it: an arrow in the text colour, never a colour that judges. */
.trend { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; color: var(--ink); }

/* What a plan asks for once, with its value, inside the plan card. */
.once { display: flex; flex-direction: column; gap: 8px; }
.once .rows { border: 1px solid var(--line); }
