/* Listan – mobilförst designsystem.
   Byggt för 360–430 px porträtt. Desktop får samma app, centrerad. */

:root {
    color-scheme: light dark;

    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #f0f1f4;
    --surface-sunken: #e9eaee;
    --text: #14161a;
    --text-soft: #6b7280;
    --text-faint: #9aa1ac;
    --line: rgba(20, 22, 26, 0.09);
    --accent: #2f6df6;
    --accent-soft: rgba(47, 109, 246, 0.12);
    --success: #1f9d55;
    --danger: #d92c3c;
    --warn: #c2610a;

    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 20px;
    --radius-xl: 26px;

    --tap: 48px;
    --shadow-1: 0 1px 2px rgba(16, 18, 24, 0.06);
    --shadow-2: 0 8px 30px rgba(16, 18, 24, 0.14);

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --nav-height: 58px;

    --speed: 180ms;
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0e0f12;
        --surface: #17191e;
        --surface-2: #1e2127;
        --surface-sunken: #101216;
        --text: #f2f3f5;
        --text-soft: #a3aab6;
        --text-faint: #767d89;
        --line: rgba(255, 255, 255, 0.09);
        --accent: #6f9dff;
        --accent-soft: rgba(111, 157, 255, 0.16);
        --success: #4ac37e;
        --danger: #ff6a72;
        --warn: #e59a4a;
        --shadow-1: none;
        --shadow-2: 0 8px 30px rgba(0, 0, 0, 0.5);
    }
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
}

.page-progress {
    position: fixed;
    inset: 0 0 auto;
    z-index: 100;
    height: 3px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 100ms linear;
}

.page-progress span {
    display: block;
    width: 45%;
    height: 100%;
    background: var(--accent);
    transform: translateX(-110%);
}

.is-navigating .page-progress {
    opacity: 1;
}

.is-navigating .page-progress span {
    animation: page-progress 900ms ease-in-out infinite;
}

@keyframes page-progress {
    50% { width: 65%; }
    100% { transform: translateX(230%); }
}

/* Layout ------------------------------------------------------------- */

.shell {
    max-width: 560px;
    margin: 0 auto;
    min-height: 100dvh;
    background: var(--bg);
    position: relative;
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
}

.shell--plain {
    padding-bottom: calc(var(--safe-bottom) + 24px);
}

@media (min-width: 620px) {
    body {
        background: var(--surface-sunken);
    }

    .shell {
        box-shadow: 0 0 0 1px var(--line);
    }
}

main {
    padding: 0 16px 24px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Topbar -------------------------------------------------------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 52px;
    padding: calc(var(--safe-top) + 6px) 8px 6px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
}

.topbar h1 {
    flex: 1;
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar__sub {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-soft);
    letter-spacing: 0;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--tap);
    min-height: var(--tap);
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.icon-btn:active {
    background: var(--surface-2);
}

.icon-btn svg {
    width: 22px;
    height: 22px;
}

/* Typografi ----------------------------------------------------------- */

.section-title {
    margin: 22px 4px 8px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-faint);
}

.group-head {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    margin: 14px 0 4px;
    padding: 4px;
    border: 0;
    background: transparent;
    color: var(--text-faint);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.group-head__name {
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.group-head svg {
    width: 18px;
    height: 18px;
    flex: none;
    transition: transform var(--speed) var(--ease);
}

.group-head[aria-expanded="false"] svg {
    transform: rotate(-90deg);
}

.group-body[hidden] {
    display: none;
}

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

.empty {
    padding: 48px 24px;
    text-align: center;
    color: var(--text-soft);
}

.empty strong {
    display: block;
    margin-bottom: 6px;
    color: var(--text);
    font-size: 17px;
}

/* Knappar ------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--tap);
    padding: 0 18px;
    border: 0;
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.btn--primary {
    background: var(--accent);
    color: #fff;
}

.btn--danger {
    background: transparent;
    color: var(--danger);
    box-shadow: inset 0 0 0 1px currentColor;
}

.btn--ghost {
    background: transparent;
    box-shadow: inset 0 0 0 1px var(--line);
}

.btn--block {
    width: 100%;
}

.btn:active {
    transform: scale(0.985);
}

.btn[disabled] {
    opacity: 0.5;
    pointer-events: none;
}

/* Formulär ------------------------------------------------------------ */

.field {
    margin-bottom: 14px;
}

.field label {
    display: block;
    margin: 0 0 6px 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-soft);
}

.field .checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: var(--tap);
    margin-left: 0;
}

.checkbox-label input {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    accent-color: var(--accent);
}

.input,
select.input,
textarea.input {
    width: 100%;
    min-height: var(--tap);
    padding: 12px 14px;
    border: 0;
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    box-shadow: inset 0 0 0 1px var(--line);
    appearance: none;
}

.input:focus-visible,
.btn:focus-visible,
.icon-btn:focus-visible,
.row__surface:focus-visible,
.chip:focus-visible,
.nav-item:focus-visible,
.quantity-stepper button:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.form-error {
    margin: 0 0 14px;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    color: var(--danger);
    font-size: 14px;
}

/* Kort och listor ----------------------------------------------------- */

.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-1);
    overflow: hidden;
}

.card + .card {
    margin-top: 12px;
}

.card__pad {
    padding: 16px;
}

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

.list-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.list-card {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 68px;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-1);
    color: inherit;
    text-decoration: none;
}

.list-card:active {
    background: var(--surface-2);
}

.list-card__icon {
    position: relative;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--accent-soft);
    color: var(--accent);
    flex: none;
    overflow: visible;
}

.list-card__icon svg {
    width: 20px;
    height: 20px;
}

.list-card__shared {
    position: absolute;
    right: -5px;
    bottom: -5px;
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border: 2px solid var(--surface);
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
}

.list-card__shared svg {
    width: 10px;
    height: 10px;
    stroke-width: 2.4;
}

.list-card__body {
    flex: 1;
    min-width: 0;
}

.list-card__title {
    display: block;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-card__meta {
    display: block;
    font-size: 13px;
    color: var(--text-soft);
}

.count-pill {
    min-width: 26px;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}

.count-pill--unread,
.nav-badge {
    background: var(--accent);
    color: #fff;
}

.friend-invite {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.friend-invite .input { flex: 1; min-width: 0; }
.friend-request { display: flex; align-items: center; gap: 6px; }
.friend-request__body { flex: 1; min-width: 0; }
.friend-request__body small { display: block; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; }
.friend-action--accept { color: var(--success); }
.friend-avatar {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: none;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
}
.avatar--image {
    object-fit: cover;
}
.pending-friend { display: flex; justify-content: space-between; gap: 12px; margin: 0; padding: 10px 4px; }
.pending-friend span { color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; }

.chat { padding-bottom: 76px; }
.chat-messages { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px 0; }
.chat-empty { align-self: center; color: var(--text-soft); padding: 40px 16px; }
.chat-message { max-width: 82%; padding: 9px 12px 6px; border-radius: var(--radius) var(--radius) var(--radius) 4px; background: var(--surface); box-shadow: var(--shadow-1); overflow-wrap: anywhere; }
.chat-message--mine { align-self: flex-end; border-radius: var(--radius) var(--radius) 4px var(--radius); background: var(--accent); color: #fff; }
.chat-message p { margin: 0; white-space: pre-wrap; }
.chat-message time { display: block; margin-top: 2px; color: var(--text-soft); font-size: 11px; text-align: right; }
.chat-message--mine time { color: rgba(255, 255, 255, 0.72); }
.chat-compose { position: fixed; z-index: 25; bottom: calc(var(--nav-height) + var(--safe-bottom)); display: flex; gap: 8px; width: min(560px, 100%); margin-left: -16px; padding: 8px 16px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(14px); }
.chat-compose .input { flex: 1; min-width: 0; border-radius: var(--radius-xl); }
.chat-compose .icon-btn { flex: none; background: var(--accent); color: #fff; }

/* Snabbinmatning ------------------------------------------------------ */

.quick-add {
    position: sticky;
    top: calc(var(--safe-top) + 52px);
    z-index: 20;
    display: flex;
    gap: 8px;
    padding: 8px 0 12px;
    background: linear-gradient(var(--bg) 72%, transparent);
}

.quick-add input {
    flex: 1;
    min-height: var(--tap);
    padding: 12px 16px;
    border: 0;
    border-radius: var(--radius-xl);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line);
}

.quick-add button {
    flex: none;
    width: var(--tap);
    height: var(--tap);
    border: 0;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
}

.quick-add button svg {
    width: 22px;
    height: 22px;
}

.proxy-notice {
    margin: 0 4px 14px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.list-intro {
    margin: 0 4px 16px;
    color: var(--text-soft);
    font-size: 15px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

/* Rader med svep ------------------------------------------------------ */

.rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.row {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface-sunken);
    touch-action: pan-y;
}

/* Bakgrunden följer sveprikningen: grönt = positiv åtgärd, rött = ta bort. */
.row[data-dir="right"] {
    background: var(--success);
}

.row[data-dir="left"] {
    background: var(--danger);
}

.row__behind {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    pointer-events: none;
}

.row__behind span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transition: opacity var(--speed) var(--ease);
}

.row[data-dir="left"] .row__behind .behind-delete,
.row[data-dir="right"] .row__behind .behind-done {
    opacity: 1;
}

.row__surface {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    min-height: 56px;
    padding: 13px 14px;
    border: 0;
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-align: left;
    box-shadow: var(--shadow-1);
    cursor: pointer;
    will-change: transform;
    -webkit-tap-highlight-color: transparent;
}

.row[data-color="red"] .row__surface,
.calendar-item[data-color="red"] { --item-color: #e05252; }
.row[data-color="orange"] .row__surface,
.calendar-item[data-color="orange"] { --item-color: #e88932; }
.row[data-color="yellow"] .row__surface,
.calendar-item[data-color="yellow"] { --item-color: #d2a91e; }
.row[data-color="green"] .row__surface,
.calendar-item[data-color="green"] { --item-color: #36a269; }
.row[data-color="blue"] .row__surface,
.calendar-item[data-color="blue"] { --item-color: #3f7edb; }
.row[data-color="pink"] .row__surface,
.calendar-item[data-color="pink"] { --item-color: #d85b91; }

.row[data-color] .row__surface {
    background: color-mix(in srgb, var(--item-color) 18%, var(--surface));
    box-shadow: inset 4px 0 0 var(--item-color), var(--shadow-1);
}

.row__surface.is-animating {
    transition: transform var(--speed) var(--ease);
}

.row__check {
    flex: none;
    width: 22px;
    height: 22px;
    margin-top: 1px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 2px var(--text-faint);
    display: grid;
    place-items: center;
    color: transparent;
}

.row.is-done .row__check {
    background: var(--success);
    box-shadow: none;
    color: #fff;
}

.row__check svg {
    width: 14px;
    height: 14px;
}

button.row__check {
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
}

.row__body {
    flex: 1;
    min-width: 0;
    display: block;
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.row__text {
    min-width: 0;
    overflow-wrap: anywhere;
}

.row__title-line {
    display: flex;
    align-items: center;
    gap: 6px;
}

.row__indicators {
    display: inline-flex;
    flex: none;
    align-self: center;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-left: auto;
    padding-left: 8px;
}

.row__priority {
    display: inline-grid;
    flex: none;
    width: 28px;
    height: 28px;
    place-items: center;
    border: 1px solid color-mix(in srgb, currentColor 24%, transparent);
    border-radius: 50%;
    background: var(--surface-2);
    font-size: 14px;
    font-weight: 800;
    line-height: 1;
}

.row__priority--prioritized {
    color: var(--warn);
}

.row__priority--deprioritized {
    color: var(--accent);
}

.row__quantity {
    display: inline-grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

.row__creator {
    display: block;
    margin-top: 3px;
    color: var(--text-faint);
    font-size: 12px;
}

.row.is-done .row__text {
    color: var(--text-faint);
    text-decoration: line-through;
}

.row.is-deleted {
    border-color: color-mix(in srgb, var(--warn) 42%, var(--border));
    background: color-mix(in srgb, var(--warn) 7%, var(--surface));
}

.row__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}

.row__date {
    display: block;
    margin-top: 3px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-soft);
    white-space: nowrap;
}

.row__date.is-overdue {
    color: var(--warn);
}

.row__link {
    position: relative;
    flex: none;
    width: 28px;
    min-width: 28px;
    height: 28px;
    min-height: 28px;
    color: var(--accent);
}

.row__link::before {
    position: absolute;
    inset: -10px;
    content: '';
}

.row__link svg {
    width: 28px;
    height: 28px;
    padding: 6px;
    border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
    border-radius: 50%;
    background: var(--accent-soft);
}

/* Kalender ------------------------------------------------------------ */

.view-switcher {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 0 0 14px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.view-switcher button {
    min-height: 40px;
    border: 0;
    border-right: 1px solid var(--line);
    background: transparent;
    color: var(--text-soft);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.view-switcher button:last-child {
    border-right: 0;
}

.view-switcher button[aria-pressed="true"] {
    background: var(--accent);
    color: #fff;
}

.calendar-view {
    margin-bottom: 18px;
}

.calendar-head {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto 40px;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}

.calendar-head strong {
    overflow: hidden;
    font-size: 15px;
    text-align: center;
    text-overflow: ellipsis;
    text-transform: capitalize;
    white-space: nowrap;
}

.calendar-nav,
.calendar-today {
    min-height: 40px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

.calendar-nav {
    font-size: 25px;
}

.calendar-today {
    padding: 0 10px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
}

.calendar-week {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 8px;
}

.calendar-day {
    min-height: 72px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.calendar-day.is-today {
    border-color: var(--accent);
}

.calendar-day h3,
.calendar-agenda h3 {
    margin: 0 0 9px;
    font-size: 13px;
    text-transform: capitalize;
}

.calendar-day__empty {
    margin: 0;
    color: var(--text-soft);
    font-size: 13px;
}

.calendar-item {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 8px;
    overflow: hidden;
    border: 0;
    border-left: 3px solid var(--line);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 12px;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.calendar-item[data-color] {
    border-left-color: var(--item-color);
    background: color-mix(in srgb, var(--item-color) 22%, var(--surface-2));
}

.calendar-item--prioritized {
    border-left-color: var(--warn);
}

.calendar-item--deprioritized {
    border-left-color: var(--accent);
}

.calendar-weekdays,
.calendar-month {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays span {
    padding: 5px 0;
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}

.calendar-month {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--line);
    gap: 1px;
}

.calendar-cell {
    position: relative;
    display: grid;
    min-width: 0;
    min-height: 48px;
    place-items: center;
    border: 0;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.calendar-cell.is-outside {
    color: var(--text-faint);
    background: var(--surface-2);
}

.calendar-cell.is-selected {
    box-shadow: inset 0 0 0 2px var(--accent);
}

.calendar-cell.is-today span {
    display: grid;
    width: 24px;
    height: 24px;
    place-items: center;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}

.calendar-cell b {
    position: absolute;
    right: 3px;
    bottom: 3px;
    min-width: 15px;
    padding: 1px 3px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 9px;
}

.calendar-agenda {
    margin-top: 14px;
}

.row__more {
    flex: none;
    width: 34px;
    min-height: 34px;
    margin: -4px -6px 0 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-faint);
    display: grid;
    place-items: center;
    cursor: pointer;
}

.row__more svg {
    width: 18px;
    height: 18px;
}

.row.is-removing {
    transition: opacity var(--speed) var(--ease), transform var(--speed) var(--ease);
    opacity: 0;
    transform: translateX(-16px);
}

.row.is-dragging {
    opacity: 0.75;
    transform: scale(1.02);
    box-shadow: var(--shadow-2);
    z-index: 5;
}

/* Chips --------------------------------------------------------------- */

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border: 0;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
}

.chip--state {
    background: var(--accent-soft);
    color: var(--accent);
}

.chip--purchased {
    background: color-mix(in srgb, var(--success) 16%, transparent);
    color: var(--success);
}

.chip--surprise {
    background: color-mix(in srgb, var(--warn) 16%, transparent);
    color: var(--warn);
}

.chip--warning {
    background: color-mix(in srgb, var(--warn) 18%, transparent);
    color: var(--warn);
}

.chip-toggle {
    min-height: 44px;
    padding: 8px 16px;
    font-size: 15px;
    background: var(--surface-2);
    cursor: pointer;
}

.chip-toggle[aria-pressed="true"] {
    background: var(--accent);
    color: #fff;
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-bar {
    display: flex;
    gap: 8px;
    padding: 2px 0 10px;
    overflow-x: auto;
    scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar {
    display: none;
}

/* Bottennavigering ---------------------------------------------------- */

.bottom-nav {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 100%;
    max-width: 560px;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    padding-bottom: var(--safe-bottom);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--line);
    z-index: 40;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    min-height: var(--nav-height);
    color: var(--text-faint);
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.nav-item > span:not(.nav-badge) {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-item svg {
    width: 23px;
    height: 23px;
}

.nav-item.is-active {
    color: var(--accent);
}

.is-offline .nav-item[data-offline-unavailable],
.nav-item.is-disabled {
    color: var(--text-faint);
    opacity: 0.38;
    pointer-events: none;
}

.nav-badge {
    position: absolute;
    top: 6px;
    left: 50%;
    margin-left: 4px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    line-height: 17px;
    text-align: center;
}

/* Bottenark ----------------------------------------------------------- */

.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(6, 8, 12, 0.42);
    opacity: 0;
    transition: opacity var(--speed) var(--ease);
}

.sheet-backdrop.is-open {
    opacity: 1;
}

.sheet {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translate(-50%, 100%);
    width: 100%;
    max-width: 560px;
    max-height: 86dvh;
    overflow-y: auto;
    z-index: 61;
    padding: 8px 16px calc(20px + var(--safe-bottom));
    background: var(--surface);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: var(--shadow-2);
    transition: transform var(--speed) var(--ease);
}

.sheet.is-open {
    transform: translate(-50%, 0);
}

.sheet__grip {
    width: 38px;
    height: 4px;
    margin: 6px auto 12px;
    border-radius: 999px;
    background: var(--line);
}

.sheet h2 {
    margin: 0 0 4px;
    font-size: 18px;
}

.sheet__lead {
    margin: 0 0 16px;
    color: var(--text-soft);
    font-size: 14px;
    overflow-wrap: anywhere;
}

.sheet-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.sheet-action {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 52px;
    padding: 12px 14px;
    border: 0;
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.sheet-action svg {
    width: 20px;
    height: 20px;
    color: var(--text-soft);
    flex: none;
}

.sheet-action--danger {
    color: var(--danger);
}

.sheet-action--danger svg {
    color: var(--danger);
}

.sheet-action[aria-pressed="true"] {
    box-shadow: inset 0 0 0 2px var(--accent);
}

.sheet-priority {
    padding: 10px 12px 12px;
    border-radius: var(--radius);
    background: var(--surface-2);
}

.priority-segments {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.priority-segments button {
    min-width: 0;
    min-height: 40px;
    padding: 6px;
    border: 0;
    border-right: 1px solid var(--line);
    background: var(--surface);
    color: var(--text-soft);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.priority-segments button:last-child {
    border-right: 0;
}

.priority-segments button[aria-pressed="true"] {
    background: var(--accent);
    color: #fff;
}

.color-swatches {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 14px;
}

.color-swatch {
    position: relative;
    width: 32px;
    height: 32px;
    flex: none;
    border: 2px solid var(--surface-2);
    border-radius: 50%;
    background: var(--swatch-color);
    box-shadow: 0 0 0 1px var(--line);
    cursor: pointer;
}

.color-swatch[aria-pressed="true"] {
    box-shadow: 0 0 0 3px var(--text);
}

.color-swatch--red { --swatch-color: #e05252; }
.color-swatch--orange { --swatch-color: #e88932; }
.color-swatch--yellow { --swatch-color: #d2a91e; }
.color-swatch--green { --swatch-color: #36a269; }
.color-swatch--blue { --swatch-color: #3f7edb; }
.color-swatch--pink { --swatch-color: #d85b91; }

.color-swatch--none {
    background: var(--surface);
}

.color-swatch--none::after {
    position: absolute;
    top: 13px;
    left: 3px;
    width: 22px;
    height: 3px;
    border-radius: 2px;
    background: var(--danger);
    content: '';
    transform: rotate(-45deg);
}

.calendar-feed-url {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.calendar-feed-url .input {
    min-width: 0;
}

.calendar-feed-url .btn {
    flex: none;
}

.sheet-cancel,
#calendar-feed-revoke {
    margin-top: 8px;
}

.sheet-quantity {
    display: flex;
    min-height: 56px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 12px 8px 20px;
    border-radius: var(--radius);
    background: var(--surface-2);
    font-weight: 600;
}

.quantity-stepper {
    display: grid;
    grid-template-columns: 44px 38px 44px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.quantity-stepper button,
.quantity-stepper__value {
    display: grid;
    min-height: 40px;
    place-items: center;
}

.quantity-stepper button {
    border: 0;
    background: transparent;
    color: var(--accent);
    font: inherit;
    font-size: 22px;
    font-weight: 600;
    cursor: pointer;
}

.quantity-stepper button:disabled {
    color: var(--text-faint);
    cursor: default;
}

.quantity-stepper__value {
    border-right: 1px solid var(--line);
    border-left: 1px solid var(--line);
    font-size: 14px;
}

/* Snackbar ------------------------------------------------------------ */

.snackbar-root {
    position: fixed;
    left: 50%;
    bottom: calc(var(--nav-height) + var(--safe-bottom) + 10px);
    transform: translateX(-50%);
    width: min(520px, calc(100% - 24px));
    z-index: 70;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.snackbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 12px 12px 16px;
    border-radius: var(--radius);
    background: #22252c;
    color: #fff;
    box-shadow: var(--shadow-2);
    pointer-events: auto;
    animation: snackbar-in var(--speed) var(--ease);
}

.snackbar span {
    flex: 1;
    font-size: 14px;
}

.snackbar button {
    border: 0;
    background: transparent;
    color: #8ab4ff;
    font: inherit;
    font-weight: 700;
    min-height: 40px;
    padding: 0 8px;
    cursor: pointer;
}

.snackbar.is-leaving {
    animation: snackbar-out 140ms var(--ease) forwards;
}

@keyframes snackbar-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
}

@keyframes snackbar-out {
    to {
        opacity: 0;
        transform: translateY(12px);
    }
}

/* Flash --------------------------------------------------------------- */

.flash {
    margin: 8px 0 0;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-1);
}

.flash--success {
    background: color-mix(in srgb, var(--success) 14%, var(--surface));
}

.flash--error {
    background: color-mix(in srgb, var(--danger) 14%, var(--surface));
}

/* Historik och notiser ------------------------------------------------ */

.timeline {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.timeline li {
    padding: 10px 2px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
}

.timeline li:last-child {
    border-bottom: 0;
}

.timeline time {
    display: block;
    color: var(--text-faint);
    font-size: 12px;
}

.notice-row {
    display: block;
    padding: 14px 16px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    color: inherit;
    text-decoration: none;
}

.notice-row.is-unread {
    box-shadow: var(--shadow-1), inset 3px 0 0 var(--accent);
}

.notice-row strong {
    display: block;
    font-size: 15px;
}

.notice-row p {
    margin: 2px 0 0;
    font-size: 14px;
    color: var(--text-soft);
}

.notice-row time {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-faint);
}

/* Admin --------------------------------------------------------------- */

.user-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    color: inherit;
    text-decoration: none;
}

.avatar {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
    font-size: 14px;
    flex: none;
}

.tag-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-faint);
}

.tag-dot--on {
    background: var(--success);
}

.tag-dot--off {
    background: var(--danger);
}

/* Auth ---------------------------------------------------------------- */

.auth {
    max-width: 420px;
    margin: 0 auto;
    padding: calc(var(--safe-top) + 40px) 20px calc(var(--safe-bottom) + 40px);
}

.auth__logo {
    display: block;
    width: 112px;
    height: 112px;
    margin: 0 auto 18px;
}

.auth__brand {
    margin: 0 0 6px;
    font-size: 30px;
    font-weight: 800;
    letter-spacing: 0;
    text-align: center;
}

.auth__lead {
    margin: 0 0 24px;
    color: var(--text-soft);
    text-align: center;
}

.auth__links {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
    font-size: 14px;
}

.account-version {
    margin: 28px 0 0;
    color: var(--text-faint);
    font-size: 12px;
    text-align: center;
}

.offline-banner {
    position: sticky;
    top: 0;
    z-index: 60;
    margin: 0;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    background: #9a3412;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
}

.offline-conflicts {
    margin-bottom: 12px;
}

.offline-conflicts__heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.offline-conflicts > .muted {
    margin: 8px 0 12px;
    font-size: 13px;
}

.offline-conflicts ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.offline-conflicts li {
    padding: 10px 0;
    border-top: 1px solid var(--border);
}

.offline-conflicts li span,
.offline-conflicts li small {
    display: block;
}

.offline-conflicts li small {
    margin-top: 4px;
    color: var(--text-faint);
    overflow-wrap: anywhere;
}

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

/* Hjälpklasser -------------------------------------------------------- */

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.hidden {
    display: none !important;
}

.spacer {
    height: 12px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }

    .is-navigating .page-progress span {
        width: 100%;
        transform: none;
    }
}
