/* Färger och typografi enligt skisserna i docs/design/ */
:root {
    --bg: #F3EFE6;
    --surface: #FFFDF8;
    --border: #DDD6C8;
    --divider: #ECE6D9;
    --text: #1E2528;
    --muted: #5B6468;
    --accent: #3F5E45;
    --accent-dark: #2C4331;
    --red: #9E3B26;
    --font-body: 'Source Sans 3', 'Segoe UI', system-ui, sans-serif;
    --font-display: Fraunces, Georgia, serif;
}

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

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 17px;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

h1 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 40px;
    line-height: 1.1;
}

h1:focus { outline: none; }

.page {
    max-width: 640px;
    margin: 0 auto;
    padding: calc(28px + env(safe-area-inset-top)) 20px calc(16px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.eyebrow {
    font-size: 14px;
    color: var(--muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.muted { color: var(--muted); }

.stack { display: flex; flex-direction: column; gap: 10px; }

label { font-weight: 600; font-size: 15px; }

input[type=text], input[type=password], input[type=date], input[type=number], select, textarea {
    font: inherit;
    min-height: 46px;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
}

button.primary {
    font: inherit;
    font-weight: 700;
    min-height: 46px;
    border: 0;
    border-radius: 12px;
    background: var(--accent);
    color: var(--surface);
    cursor: pointer;
}

button.primary:hover { background: var(--accent-dark); }

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

.error { margin: 0; color: var(--red); }

.notice {
    margin: 0;
    padding: 10px 14px;
    background: #E3EBE2;
    border-radius: 12px;
}

/* --- Sidhuvud --- */

.page-header { display: flex; flex-direction: column; gap: 2px; position: relative; }

.back-link {
    align-self: flex-start;
    margin-bottom: 8px;
    font-weight: 600;
    text-decoration: none;
}

/* --- Sektioner och kort --- */

.section { display: flex; flex-direction: column; gap: 12px; }

.section-title {
    margin: 0;
    font-size: 13px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 700;
}

details > summary.section-title { cursor: pointer; }

.card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.card-title { font-family: var(--font-display); font-size: 20px; font-weight: 500; }
.card-measure { font-weight: 600; color: var(--accent-dark); margin-top: -6px; }

.card-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }

.card.saved { border: 2px solid var(--accent); background: #F4F8F3; }

.saved-badge {
    flex: none;
    font-size: 13px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--surface);
}

/* Aspektsidan visar hela grenen: ett avsnitt per aspekt, indraget efter djup. */
.aspect-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-left: calc(min(var(--depth), 3) * 12px);
}

.aspect-section + .aspect-section { padding-top: 18px; border-top: 1px solid var(--border); }

.aspect-heading {
    margin: 0;
    font-size: 13px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 700;
}

.aspect-heading a { color: var(--accent-dark); text-decoration: none; }
.aspect-heading a:hover { text-decoration: underline; }

.history-summary { cursor: pointer; font-size: 14px; color: var(--muted); font-weight: 600; }

/* --- Status: färg + ikon + text, aldrig bara färg. Färgerna skiljer sig även i ljushet. --- */

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

.status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
}

/* I fas: mörkgrön cirkel med bock. */
.status-green .status-icon { border-radius: 50%; background: #3F5E45; color: #FFFDF8; }
.status-green .status-label { color: #2C4331; }

/* Snart dags: ljus gul triangel-känsla – rundad kvadrat med utropstecken, mörk text. */
.status-yellow .status-icon { border-radius: 5px; background: #F2C75C; color: #3A2E0B; border: 1px solid #C69A2B; }
.status-yellow .status-label { color: #6E5412; }

/* Behöver omsorg: mörk rödbrun kvadrat med kryss. */
.status-red .status-icon { border-radius: 3px; background: #9E3B26; color: #FFFDF8; }
.status-red .status-label { color: #7E2E1D; }

.status.compact .status-icon { width: 20px; height: 20px; font-size: 12px; }

.status-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.status-facts { font-size: 15px; color: var(--muted); }

/* --- Nu --- */

.all-good { flex-direction: row; align-items: center; gap: 12px; }

.care { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.care-main { display: flex; align-items: flex-start; gap: 12px; }
.care-main .status { margin-top: 2px; }
.care-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.care-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-left: 32px; }
.quick-done { font-size: 15px; font-weight: 600; color: var(--accent-dark); padding: 10px 0; }

.habit { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.habit-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.habit-head .row-title { color: inherit; text-decoration: none; flex: none; }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.day form { width: 100%; display: flex; justify-content: center; }
.day-name { font-size: 12px; font-weight: 700; color: var(--muted); }
.day.today .day-name { color: var(--accent-dark); text-decoration: underline; text-underline-offset: 3px; }

.day-box {
    width: 100%;
    max-width: 44px;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 2px solid #9A9386;
    background: transparent;
    font: inherit;
    font-size: 18px;
    font-weight: 800;
    color: var(--surface);
    cursor: pointer;
    padding: 0;
}

.day.today .day-box:not(.done) { border-color: var(--accent); border-width: 3px; }
.day-box.done { background: var(--accent); border-color: var(--accent); }
.day-box.future { border-style: dashed; border-color: var(--border); cursor: default; }

.missed-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}

.upcoming { display: flex; align-items: flex-start; gap: 14px; padding: 12px 16px; color: inherit; text-decoration: none; }
.upcoming-date { flex: none; width: 5.5em; font-weight: 700; font-size: 15px; color: var(--accent-dark); }
.upcoming-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.logout { align-self: center; margin-top: 8px; }

/* --- Pausad (accepterad) ambition: egen grå markering, ingen statusfärg. --- */

.status-paused .status-icon { border-radius: 50%; background: #E7E1D3; color: #3A4246; border: 1px dashed #9A9386; }
.status-paused .status-label { color: var(--muted); }

/* --- Reflektion --- */

.reflect-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px;
    background: var(--accent);
    border-radius: 16px;
    color: var(--surface);
}

.reflect-text { display: flex; flex-direction: column; gap: 4px; }
.reflect-eyebrow { font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: #DCE6DC; }
.reflect-title { font-family: var(--font-display); font-size: 24px; font-weight: 500; }
.reflect-meta { font-size: 15px; color: #E6EDE6; }

.reflect-start {
    width: 100%;
    min-height: 46px;
    border: 0;
    border-radius: 12px;
    background: var(--surface);
    color: var(--accent-dark);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.reflect-later {
    background: none;
    border: 0;
    padding: 4px 0;
    font: inherit;
    font-size: 15px;
    color: #E6EDE6;
    text-decoration: underline;
    cursor: pointer;
}

.intent-block { display: flex; flex-direction: column; gap: 8px; }
.intent-block .intent { font-size: 18px; }

.facts { display: flex; flex-direction: column; gap: 4px; }
.facts-title { font-weight: 700; font-size: 15px; }
.facts ul { margin: 0; padding-left: 18px; }

.reflection-form { display: flex; flex-direction: column; gap: 18px; }

.ratings { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.rating input, .decision input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.rating-box {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    border-radius: 12px;
    border: 1px solid #CFC7B6;
    background: var(--surface);
    font-weight: 700;
    font-size: 18px;
    cursor: pointer;
}

.rating input:checked + .rating-box { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.rating input:focus-visible + .rating-box, .decision input:focus-visible + .decision-box { outline: 3px solid #F2C75C; outline-offset: 2px; }
.rating-scale { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }

.decisions { gap: 8px; }

.decision-box {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #CFC7B6;
    background: var(--surface);
    cursor: pointer;
}

.decision-label { font-weight: 700; }
.decision-hint { font-size: 14px; color: var(--muted); }

/* Selected: thicker border plus a check mark – not colour alone. */
.decision input:checked + .decision-box { border: 2px solid var(--accent); background: #E3EBE2; }
.decision input:checked + .decision-box .decision-label::after { content: "  ✓"; color: var(--accent-dark); }

/* The revisit date is only relevant for Acceptera. */
.revisit { display: none; flex-direction: column; gap: 6px; padding: 4px 0 0 4px; }
.decisions:has(input[value="Accept"]:checked) .revisit { display: flex; }

.schedule { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.schedule.offered { box-shadow: inset 3px 0 0 var(--accent); }
.schedule-head { display: flex; flex-direction: column; gap: 2px; }
.schedule-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.row-meta.due { color: var(--accent-dark); font-weight: 700; }

.cadence { display: flex; align-items: center; gap: 8px; }
.cadence label { display: flex; align-items: center; gap: 6px; font-weight: 400; }
.cadence input[type=number] { width: 4.5em; }

.history-items { margin: 4px 0 0; padding-left: 18px; }

/* --- Insatser --- */

.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 15px;
    text-decoration: none;
    white-space: nowrap;
}

.button-link.primary { background: var(--accent); color: var(--surface); font-weight: 700; min-height: 46px; padding: 0 18px; }
.button-link.primary:hover { background: var(--accent-dark); color: var(--surface); }
.button-link.secondary { background: var(--surface); color: var(--text); border: 1px solid #CFC7B6; }
.button-link.secondary:hover { border-color: var(--accent); color: var(--text); }

.item { display: flex; align-items: center; gap: 8px; padding-right: 12px; }

.item-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 12px 16px;
    color: inherit;
    text-decoration: none;
}

.item-main.padded { width: 100%; }
.item-main:hover .row-title { color: var(--accent); }
.item-actions { flex: none; display: flex; align-items: center; gap: 8px; }
.list-item.saved { background: #F4F8F3; box-shadow: inset 3px 0 0 var(--accent); }
.row-meta.missed { color: var(--red); }
.done-mark { color: var(--accent); font-weight: 700; font-size: 20px; }
.chip.ended { opacity: 0.6; text-decoration: line-through; }

@media (max-width: 480px) {
    .item { flex-direction: column; align-items: stretch; padding: 0 16px 12px 0; }
    .item-actions { padding-left: 16px; }
}

.initiative-form { display: flex; flex-direction: column; gap: 16px; }

fieldset.plain { margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 8px; }
fieldset.plain > legend { font-weight: 600; font-size: 15px; padding: 0; margin-bottom: 6px; }

.segmented.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.segmented button:disabled { opacity: 0.45; cursor: not-allowed; }

.radio-row { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.check input[type=radio] { width: 20px; height: 20px; accent-color: var(--accent); }

.choice-group { display: flex; flex-direction: column; }
.choice-group + .choice-group { margin-top: 8px; }
.choice-group-title { font-size: 13px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; font-weight: 700; }
.card-meta { font-size: 14px; color: var(--muted); }

.intent {
    margin: 0;
    padding-left: 12px;
    border-left: 3px solid var(--border);
    font-style: italic;
    white-space: pre-line;
}

.small { font-size: 14px; margin: 0; }

.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.history-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 600; }

/* --- Ambitionsformulär --- */

.ambition-form { display: flex; flex-direction: column; gap: 14px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.segmented button {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-height: 56px;
    padding: 8px 14px;
    font: inherit;
    font-weight: 600;
    text-align: left;
    color: var(--text);
    background: var(--surface);
    border: 1px solid #CFC7B6;
    border-radius: 12px;
    cursor: pointer;
}

.segmented button small { font-weight: 400; font-size: 13px; color: var(--muted); }
.segmented button[aria-pressed="true"] { background: #E3EBE2; border: 2px solid var(--accent); }

.sentence { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 17px; }
.sentence input[type=number] { width: 5.5em; }

textarea { resize: vertical; line-height: 1.4; }

/* --- Knappar --- */

button.secondary, button.danger {
    font: inherit;
    font-weight: 600;
    font-size: 15px;
    min-height: 44px;
    padding: 0 14px;
    border-radius: 12px;
    cursor: pointer;
    white-space: nowrap;
}

button.secondary { background: var(--surface); color: var(--text); border: 1px solid #CFC7B6; }
button.secondary:hover { border-color: var(--accent); }
button.danger { background: var(--red); color: var(--surface); border: 0; }
button.primary { padding: 0 18px; white-space: nowrap; }

/* --- Formulär på en rad --- */

.inline-form { display: flex; flex-direction: column; gap: 6px; }
.input-row { display: flex; gap: 8px; }
.input-row > input, .input-row > select { flex: 1; min-width: 0; }

.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.button-row .spacer { flex: 1; }
.confirm-text { font-weight: 600; }

/* --- Listor --- */

.list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}

.list-item + .list-item { border-top: 1px solid var(--divider); }
.list-item.selected { background: #FAF7F0; }

.row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 52px;
    padding: 12px 16px;
    background: none;
    border: 0;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

a.row { text-decoration: none; }
a.row:hover .row-title { color: var(--accent); }

.row-wrap { display: flex; align-items: stretch; }
.row-wrap > .row { flex: 1; min-width: 0; }

.row-edit {
    flex: none;
    width: 52px;
    background: none;
    border: 0;
    border-left: 1px solid var(--divider);
    font: inherit;
    font-size: 20px;
    color: var(--muted);
    cursor: pointer;
}

.row-edit:hover, .row-edit[aria-expanded="true"] { color: var(--accent); }

.list-item.archived .row-title { color: var(--muted); font-style: italic; }

.row-stacked { flex-direction: column; align-items: flex-start; gap: 6px; }
.row-title { flex: 1; font-size: 17px; }
.row-title.area, .check .area { font-weight: 600; }
.row-meta { font-size: 14px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
    font-size: 13px;
    padding: 3px 9px;
    border-radius: 999px;
    background: #E7E1D3;
    color: #3A4246;
}

.panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 4px 16px 16px;
}

.checklist {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    border: 0;
}

.checklist legend { font-weight: 600; font-size: 15px; margin-bottom: 4px; }

.check {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    font-weight: 400;
    font-size: 16px;
}

.check input { width: 20px; height: 20px; accent-color: var(--accent); }

/* --- Flikrad --- */

.shell { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 48px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
}

.tab.active, .tab[data-active] { color: var(--accent); font-weight: 700; }
.tab[aria-disabled] { opacity: 0.4; cursor: default; }

.login { max-width: 400px; padding-top: calc(15vh + env(safe-area-inset-top)); }

.valid.modified:not([type=checkbox]) { outline: 1px solid var(--accent); }
.invalid { outline: 1px solid var(--red); }
.validation-message { color: var(--red); }

.blazor-error-boundary {
    padding: 1rem;
    background: var(--red);
    color: white;
}

.blazor-error-boundary::after { content: "Ett fel inträffade."; }
