/* ==========================================================================
   HabitsBot — full d'estil
   Base clara i freda · verd de creixement (fet/ratxa) · ambre per la flama.
   Navegació simple: Hàbits, Progrés i Configurar, amb detall per hàbit.
   ========================================================================== */

:root {
    --bg:          #F4F6F3;
    --surface:     #FFFFFF;
    --ink:         #16241C;
    --ink-soft:    #2E3A33;
    --muted:       #67736B;
    --line:        #E4E8E3;
    --line-soft:   #EDF0EC;

    --green:       #1B7750;
    --green-deep:  #14603E;
    --green-soft:  #E4F1EA;
    --amber:       #DDA032;
    --miss:        #B7443D;
    --miss-soft:   #F7E7E5;
    --info:        #4A83C4;

    --radius:      16px;
    --radius-sm:   11px;
    --shadow:      0 1px 2px rgba(22,36,28,.04), 0 8px 24px rgba(22,36,28,.055);
    --shadow-lg:   0 -8px 40px rgba(22,36,28,.14);

    --display: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
    --body:    Inter, "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;

    --header-h: 58px;
    --tabbar-h: 66px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--body);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select { font-family: inherit; font-size: 16px; }
svg { display: block; }
.hidden { display: none !important; }
.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;
}
:where(button, a, input, select, [role="button"]):focus-visible {
    outline: 3px solid rgba(27,119,80,.32);
    outline-offset: 2px;
}
button:disabled { cursor: not-allowed; opacity: .55; }

/* --------------------------------------------------------------- header -- */
.app-header {
    position: sticky;
    top: 0; z-index: 20;
    height: var(--header-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px;
    background: rgba(244,246,243,.86);
    backdrop-filter: saturate(1.4) blur(12px);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--line);
}
.brand {
    font-family: var(--display);
    font-weight: 700;
    font-size: 1.28rem;
    letter-spacing: -0.02em;
    display: flex; align-items: center;
}
.brand .dots { color: var(--green); margin-right: 12px; letter-spacing: -2px; }
.logout-form { margin: 0; }
.logout { font-size: .84rem; color: var(--muted); text-decoration: none; font-weight: 500; }
.logout:active { color: var(--ink); }

.network-banner {
    position: sticky; top: var(--header-h); z-index: 19;
    max-width: 560px; margin: 0 auto; padding: 8px 16px;
    background: #FFF3D8; border-bottom: 1px solid rgba(138,100,16,.2);
    color: #76530A; text-align: center; font-size: .78rem; font-weight: 600;
}

/* ----------------------------------------------------------- app / views - */
.app {
    max-width: 560px;
    margin: 0 auto;
    padding: 22px 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom));
}
.home-hero { margin: 2px 2px 20px; }
.hero-greet {
    font-family: var(--display); font-weight: 700;
    font-size: 1.5rem; letter-spacing: -0.02em; line-height: 1.15;
    display: flex; align-items: center; gap: 9px;
}
.hero-emoji { font-size: 1.15rem; }
.hero-sub { color: var(--muted); font-size: .95rem; margin-top: 5px; }
.hero-sub b { color: var(--ink); font-weight: 600; }
.view-title {
    font-family: var(--display);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.home-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; margin: 0 2px;
}
#home-title {
    min-width: 0; flex: 1 1 auto;
    font-size: 1.2rem; line-height: 1.2; white-space: nowrap;
}
#view-home > .hero-sub { margin: 5px 2px 20px; }
#home-own > .hero-week { margin: -7px 2px 20px; }
.home-scope {
    display: inline-flex; flex: 0 0 auto; align-items: center; padding: 3px;
    border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.home-scope button {
    flex: 0 0 auto; min-height: 36px; padding: 6px 10px; border-radius: 9px;
    color: var(--muted); font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.home-scope button.active { color: var(--green-deep); background: var(--green-soft); }

/* Dashboard físic WHOOP, integrat a Inici i sense vista pròpia. */
.whoop-dashboard {
    display: grid; grid-template-columns: 56px minmax(0, 1fr); align-items: center; gap: 8px;
    margin: -5px 0 14px; padding: 8px 11px;
    border: 1px solid #DDE6E0; border-radius: 13px;
    background: linear-gradient(145deg, #FCFDFC 0%, #F2F6F3 100%);
    box-shadow: 0 3px 12px rgba(26,65,46,.055);
}
.whoop-dash-head {
    display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 5px;
    align-self: stretch; margin: 0; padding-right: 8px;
    border-right: 1px solid #D8E1DB;
}
.whoop-eyebrow {
    display: block; color: var(--green-deep); font-size: .6rem; line-height: 1;
    font-weight: 850; letter-spacing: .15em;
}
.whoop-sync { color: var(--muted); font-size: .57rem; line-height: 1; white-space: nowrap; }
.whoop-sync:not(:empty)::before { content: '↻'; margin-right: 3px; font-size: .64rem; }
.whoop-kpis {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0;
}
.whoop-kpi {
    --whoop-color: #829086;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    min-width: 0; min-height: 52px; padding: 0 3px;
}
.whoop-kpi-label {
    min-width: 0; color: var(--muted); font-size: .62rem; font-weight: 700;
    line-height: 1; text-align: center; white-space: nowrap;
}
.whoop-ring {
    position: relative; width: 38px; height: 38px; display: grid; place-items: center;
    flex: 0 0 38px; border-radius: 50%;
    background: conic-gradient(var(--whoop-color) var(--whoop-progress, 0%), #E2E8E4 0);
}
.whoop-ring::after {
    content: ''; position: absolute; inset: 3px; border-radius: 50%; background: #FAFCFA;
}
.whoop-kpi-value {
    position: relative; z-index: 1; display: block; font-family: var(--display); font-size: .72rem;
    font-weight: 780; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums;
}
.whoop-kpi-value small { margin-left: 1px; font-size: .44rem; font-weight: 700; color: inherit; }
.whoop-kpi.recovery.good { --whoop-color: #36A873; }
.whoop-kpi.recovery.warn { --whoop-color: #D9A42A; }
.whoop-kpi.recovery.bad { --whoop-color: #D95A54; }
.whoop-kpi.sleep { --whoop-color: #927CC3; }
.whoop-kpi.strain { --whoop-color: #5599CC; }
.whoop-kpi.skeleton { min-height: 52px; overflow: hidden; }
.whoop-kpi.skeleton .whoop-ring { background: #E3E9E5; }
.whoop-kpi.skeleton .whoop-ring::after { background: #F7F9F7; }
.whoop-kpi.skeleton i { width: 38px; height: 7px; border-radius: 99px; background: #E1E7E3; }
.whoop-dash-warning {
    grid-column: 1 / -1; margin-top: 2px; padding: 6px 1px 0; border-top: 1px solid #D8E1DB;
    color: #8A6410; font-size: .63rem;
}
.whoop-empty {
    grid-column: 1 / -1; padding: 8px 4px; text-align: center;
    color: var(--muted); font-size: .68rem;
}

/* ==========================================================================
   INICI — targetes de progrés (només lectura)
   ========================================================================== */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 15px 16px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}
.card, .rest {
    display: block; width: 100%; text-align: left; color: inherit; font: inherit;
}
.card:focus-visible, .rest:focus-visible { border-color: var(--green); }
.card-main {
    display: flex; align-items: center; gap: 16px;
}
.card-info { flex: 1; min-width: 0; }

.chip {
    display: inline-flex; align-items: center; gap: 5px;
    align-self: flex-start;
    font-size: .7rem; font-weight: 600;
    padding: 3px 9px; border-radius: 999px;
    white-space: nowrap;
}
/* nom de l'hàbit: primera línia, protagonista. Ajusta en diverses línies
   en comptes de tallar-se amb punts suspensius. */
.card-title {
    font-family: var(--display); font-weight: 600;
    font-size: 1.15rem; letter-spacing: -0.015em; line-height: 1.25;
    color: var(--ink);
    overflow-wrap: anywhere;
}
/* categoria + ratxa: informació secundària i subtil */
.card-meta2 {
    display: flex; align-items: center; gap: 7px;
    margin-top: 6px;
    font-size: .82rem; color: var(--muted);
}
.card-meta2 { flex-wrap: wrap; row-gap: 2px; }
.card-meta2 .cc-sep { color: #CBD2CB; }
.cc-freq2 { color: var(--ink-soft); font-weight: 500; }
.card-meta2 .cc-streak.zero { filter: grayscale(1) opacity(.55); color: #B7BEB7; }
.rec-badge {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: .68rem; font-weight: 600; letter-spacing: .01em;
    color: #8A6410; background: rgba(221,160,50,.16);
    padding: 2px 8px; border-radius: 999px;
}

/* estat operatiu: línia fina */
.card-status {
    display: flex; align-items: center; gap: 7px;
    margin-top: 7px;
    font-size: .78rem; font-weight: 500; color: var(--muted);
}
.st-dot { width: 8px; height: 8px; border-radius: 50%; background: #C2CAC2; flex-shrink: 0; }
.tone-good .st-dot    { background: var(--green); }
.tone-good            { color: var(--green-deep); }
.tone-warn .st-dot    { background: var(--amber); }
.tone-miss .st-dot    { background: var(--miss); }
.tone-info .st-dot    { background: var(--info); }
.tone-neutral .st-dot { background: #C2CAC2; }

/* anell de progrés: gran, ocupa l'alçada de la card */
.ring-wrap { position: relative; width: 68px; height: 68px; flex-shrink: 0; }
.ring { width: 68px; height: 68px; }
.ring-track { fill: none; stroke: var(--line-soft); stroke-width: 6.5; }
.ring-arc {
    fill: none; stroke-width: 6.5; stroke-linecap: round;
    transition: stroke-dashoffset .6s cubic-bezier(.3,.9,.3,1);
}
.ring-num {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    line-height: 1;
}
.rn-done {
    font-family: var(--display); font-weight: 700;
    font-size: 1.4rem; letter-spacing: -0.02em; color: var(--ink);
}
.rn-target {
    font-size: .54rem; color: var(--muted);
    text-transform: uppercase; letter-spacing: .06em; margin-top: 3px;
}
.ring-num.complete .rn-done { color: var(--green); }

/* ==========================================================================
   CONFIGURAR — targetes de detall (gestió)
   ========================================================================== */
.config-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 18px;
}
.btn-add {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--green); color: #fff;
    font-weight: 600; font-size: .88rem;
    padding: 9px 15px; border-radius: 999px;
    box-shadow: 0 4px 12px rgba(31,138,91,.28);
}
.btn-add:active { transform: scale(.97); }

/* acordió per categoria */
.cat-group { margin-bottom: 20px; }
.cat-head {
    width: 100%;
    display: flex; align-items: center; justify-content: space-between;
    padding: 2px 4px 10px;
    background: none;
}
.cat-head-left {
    display: flex; align-items: center; gap: 8px;
    font-family: var(--display); font-weight: 600; font-size: .92rem;
    color: var(--ink);
}
.cat-ico { font-size: 1rem; }
.cat-count {
    font-size: .7rem; font-weight: 600; color: var(--muted);
    background: var(--line-soft); padding: 1px 8px; border-radius: 999px;
}
.cat-chevron { color: var(--muted); transition: transform .2s; flex-shrink: 0; }
.cat-group.collapsed .cat-chevron { transform: rotate(-90deg); }
.cat-group.collapsed .cat-body { display: none; }

.ccard {
    display: flex; align-items: center; gap: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 10px 13px 16px;
    margin-bottom: 9px;
    box-shadow: var(--shadow);
}
.ccard.inactive { opacity: .55; }
.ccard-open {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column;
    text-align: left; background: none;
}
.cc-name {
    font-family: var(--display); font-weight: 600;
    font-size: 1.08rem; letter-spacing: -0.015em; line-height: 1.2;
    color: var(--ink);
}
.cc-freq {
    font-size: .85rem; color: var(--muted); margin-top: 5px; line-height: 1.4;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cc-type { color: var(--ink-soft); font-weight: 600; }
.cc-foot {
    display: flex; align-items: center; gap: 16px;
    margin-top: 10px; padding-top: 10px;
    border-top: 1px solid var(--line-soft);
    font-size: .82rem; color: var(--ink-soft); font-weight: 500;
}
.cc-foot-item.muted { color: #A9B2AA; font-weight: 400; }

.crow-tag {
    display: inline-block; margin-left: 8px; vertical-align: middle;
    font-size: .62rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .04em; color: var(--muted);
    background: var(--line-soft); padding: 2px 7px; border-radius: 5px;
}
.crow-del {
    flex-shrink: 0; color: #B9C0B9; padding: 8px;
    border-radius: 8px; transition: color .15s, background .15s;
}
.crow-del:active { color: var(--miss); background: var(--miss-soft); }

/* ----------------------------------------------------------------- empty -- */
.empty {
    text-align: center; padding: 52px 20px; color: var(--muted);
}
.empty .big { font-size: 2.1rem; margin-bottom: 12px; }
.empty .sub { font-size: .92rem; margin-top: 4px; }

/* ==========================================================================
   TAB BAR
   ========================================================================== */
.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    background: rgba(255,255,255,.92);
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-top: 1px solid var(--line);
}
.tab {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px;
    color: var(--muted);
    font-size: .72rem; font-weight: 600; letter-spacing: .01em;
    transition: color .15s;
}
.tab svg { width: 23px; height: 23px; }
.tab.active { color: var(--green); }
.tabbar.detail-open { display: none; }

/* ==========================================================================
   DETALL DE L'HÀBIT — calendari editable i context en un sol lloc
   ========================================================================== */
.habit-detail { padding-bottom: 8px; }
.detail-topbar {
    display: flex; align-items: center; justify-content: space-between;
    margin: -6px 0 20px;
}
.detail-back, .detail-edit {
    min-height: 44px; display: inline-flex; align-items: center; gap: 4px;
    color: var(--green-deep); font-size: .88rem; font-weight: 600;
}
.detail-back { margin-left: -8px; padding: 0 8px 0 2px; }
.detail-edit { padding: 0 10px; }
.detail-head { margin: 0 2px 22px; }
.detail-category {
    display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
    color: var(--muted); font-size: .78rem; font-weight: 600;
}
.detail-category span {
    width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 9px; background: var(--surface); border-bottom: 3px solid var(--detail-cat);
    box-shadow: var(--shadow);
}
.detail-head h1 {
    font-family: var(--display); font-size: 1.75rem; line-height: 1.15;
    letter-spacing: -.025em; overflow-wrap: anywhere;
}
.detail-head p { margin-top: 6px; color: var(--muted); font-size: .9rem; }
.detail-period, .detail-calendar, .detail-evolution {
    background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
    padding: 17px; margin-bottom: 13px; box-shadow: var(--shadow);
}
.detail-section-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin-bottom: 14px;
}
.detail-section-head h2 {
    font-family: var(--display); font-size: 1rem; line-height: 1.25;
}
.detail-status {
    display: inline-flex; align-items: center; gap: 6px; text-align: right;
    max-width: 68%; justify-content: flex-end; color: var(--muted);
    font-size: .72rem; font-weight: 600; line-height: 1.25;
}
.detail-status .st-dot { flex-shrink: 0; }
.detail-progress-copy { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.detail-progress-copy strong {
    font-family: var(--display); font-size: 1.45rem; line-height: 1;
    font-variant-numeric: tabular-nums;
}
.detail-progress-copy span { color: var(--muted); font-size: .78rem; }
.detail-progress-bar {
    height: 8px; margin-top: 11px; overflow: hidden;
    border-radius: 99px; background: var(--line-soft);
}
.detail-progress-bar span {
    display: block; height: 100%; border-radius: inherit; background: var(--green);
    transition: width .45s cubic-bezier(.3,.9,.3,1);
}
.detail-actions-btn {
    min-height: 44px; width: 100%; margin-top: 16px; border-top: 1px solid var(--line-soft);
    color: var(--green-deep); font-size: .84rem; font-weight: 600;
}
.calendar-heading { margin-bottom: 4px; }
.calendar-heading p { color: var(--muted); font-size: .76rem; margin-top: 3px; }
.evolution-heading { margin-bottom: 3px; }
.evolution-heading p { color: var(--muted); font-size: .76rem; margin-top: 3px; }
.evolution-chart { min-height: 140px; margin: 2px -3px 0; }
.evo-svg { display: block; width: 100%; height: 140px; overflow: visible; }
.evo-goal {
    stroke: #D8D0E7; stroke-width: 1; stroke-dasharray: 4 5;
    vector-effect: non-scaling-stroke;
}
.evo-base { stroke: var(--line-soft); stroke-width: 1; vector-effect: non-scaling-stroke; }
.evo-axis {
    fill: #988AAE; font-size: 8px; font-weight: 650; letter-spacing: .02em;
}
.evo-area { fill: url(#evo-fill); }
.evo-line, .evo-line-current {
    fill: none; stroke: #765BAA; stroke-width: 2.5; stroke-linecap: round;
    stroke-linejoin: round; vector-effect: non-scaling-stroke;
}
.evo-line-current { stroke-dasharray: 5 5; opacity: .72; }
.evo-hit { fill: transparent; cursor: pointer; }
.evo-dot {
    fill: var(--surface); stroke: #765BAA; stroke-width: 3;
    vector-effect: non-scaling-stroke; transition: stroke-width .14s, fill .14s;
}
.evo-point.current .evo-dot { stroke-dasharray: 2 2; }
.evo-point.skipped .evo-dot { stroke: #9BA39C; }
.evo-point.selected .evo-dot { fill: #765BAA; stroke-width: 4; }
.evo-point:focus { outline: none; }
.evo-point:focus .evo-hit { stroke: rgba(118,91,170,.25); stroke-width: 4; }
.evo-week-label {
    fill: var(--muted); font-size: 9px; font-weight: 600; text-anchor: middle;
}
.evo-week-label.current { fill: #6D55A4; font-weight: 750; }
.evolution-selected {
    min-height: 32px; display: flex; align-items: center; justify-content: center;
    margin-top: -2px; padding: 7px 10px; border-radius: 10px;
    background: #F4F0FA; color: #5F4B84; font-size: .76rem; font-weight: 600;
    text-align: center; font-variant-numeric: tabular-nums;
}
.evolution-empty { padding: 46px 8px; text-align: center; color: var(--muted); font-size: .8rem; }
.detail-calendar .hist-nav { margin: 8px 0 14px; }
.detail-loading { padding: 26px 8px; text-align: center; color: var(--muted); font-size: .8rem; }
.detail-load-error {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    padding: 24px 8px; text-align: center; color: var(--muted); font-size: .8rem;
}
.retry-detail { min-height: 40px; padding: 0 12px; color: var(--green-deep); font-weight: 600; }

/* ==========================================================================
   MODAL (bottom sheet)
   ========================================================================== */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(22,36,28,.42);
    display: flex; align-items: flex-end; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity .22s;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
    background: var(--surface);
    width: 100%; max-width: 560px;
    border-radius: 22px 22px 0 0;
    padding: 10px 18px calc(20px + env(safe-area-inset-bottom));
    max-height: 92vh; overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(100%);
    transition: transform .28s cubic-bezier(.2,.85,.25,1);
}
.modal-backdrop.open .modal { transform: translateY(0); }
.modal-grip {
    width: 38px; height: 4px; border-radius: 3px;
    background: var(--line); margin: 0 auto 16px;
}
.modal h3 { font-family: var(--display); font-size: 1.28rem; margin-bottom: 20px; }

.field { margin-bottom: 18px; }
.field label {
    display: block; font-size: .74rem; font-weight: 600;
    color: var(--muted); margin-bottom: 8px;
    text-transform: uppercase; letter-spacing: .05em;
}
.field input[type=text],
.field input[type=time],
.field select {
    width: 100%; padding: 12px 13px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--ink);
}
.field input:focus, .field select:focus {
    outline: none; border-color: var(--green);
    box-shadow: 0 0 0 3px var(--green-soft);
}

.seg { display: flex; gap: 7px; }
.seg button {
    flex: 1; padding: 11px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--muted);
    font-weight: 500; font-size: .92rem;
    transition: all .15s;
}
.seg button.active {
    background: var(--green-soft); border-color: var(--green); color: var(--green-deep);
    font-weight: 600;
}

.picker { display: flex; flex-wrap: wrap; gap: 7px; }
.picker.days button {
    flex: 0 0 auto;
    padding: 9px 15px;
    border: 1px solid var(--line); border-radius: 999px;
    background: var(--surface); color: var(--ink-soft);
    font-size: .88rem; font-weight: 500;
    transition: all .15s; min-height: 44px;
}
.picker button.active {
    background: var(--green); border-color: var(--green); color: #fff; font-weight: 600;
}

.quota-row { display: flex; align-items: center; gap: 10px; }
.quota-row .step {
    width: 44px; height: 44px; flex-shrink: 0;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    font-size: 1.3rem; color: var(--green-deep); font-weight: 600;
    display: flex; align-items: center; justify-content: center;
}
.quota-row .step:active { background: var(--green-soft); }
.quota-row input {
    width: 62px; text-align: center; font-weight: 600;
    padding: 11px 0; border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.quota-row .suffix { color: var(--muted); font-size: .9rem; }

.form-error {
    background: var(--miss-soft); color: var(--miss);
    border-radius: var(--radius-sm); padding: 11px 13px;
    font-size: .86rem; margin-bottom: 16px;
}

.modal-secondary {
    display: flex; gap: 10px;
    margin-top: 22px; padding-top: 18px;
    border-top: 1px solid var(--line-soft);
    margin-bottom: 16px;
}
.link-btn {
    flex: 1;
    font-size: .88rem; font-weight: 600; color: var(--muted);
    padding: 11px 14px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface);
    transition: background .15s, border-color .15s, color .15s;
}
.link-btn:active { background: var(--bg); }
.link-btn.danger { color: var(--miss); border-color: rgba(200,86,79,.3); }
.link-btn.danger:active { background: var(--miss-soft); }

.modal-actions { display: flex; gap: 11px; }
.btn {
    padding: 13px 16px; border-radius: var(--radius-sm); min-height: 44px;
    font-weight: 600; font-size: .96rem; flex: 1;
    transition: transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--green); color: #fff; }
.btn-ghost { background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.btn-danger-solid { background: var(--miss); color: #fff; }

/* ------------------------------------------------------ diàleg confirmació */
.confirm-backdrop {
    position: fixed; inset: 0; z-index: 70;
    background: rgba(22,36,28,.5);
    display: flex; align-items: center; justify-content: center;
    padding: 28px;
    opacity: 0; pointer-events: none; transition: opacity .2s;
}
.confirm-backdrop.open { opacity: 1; pointer-events: auto; }
.confirm-card {
    background: var(--surface);
    border-radius: 20px;
    padding: 26px 22px 20px;
    width: 100%; max-width: 340px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    transform: scale(.94);
    transition: transform .22s cubic-bezier(.2,.85,.25,1);
}
.confirm-backdrop.open .confirm-card { transform: scale(1); }
.confirm-icon { font-size: 2rem; margin-bottom: 10px; }
.confirm-title { font-family: var(--display); font-size: 1.18rem; margin-bottom: 8px; }
.confirm-msg { color: var(--muted); font-size: .9rem; line-height: 1.5; margin-bottom: 22px; }
.confirm-actions { display: flex; gap: 11px; }

/* ------------------------------------------------ accions card config --- */
.cc-actions { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.cc-hist {
    color: #9AA69E; padding: 8px; border-radius: 8px;
    transition: color .15s, background .15s;
}
.cc-hist:active { color: var(--green); background: var(--green-soft); }

/* Calendari mensual del detall d'un hàbit. */
.hist-nav { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 16px; }
.hist-arrow {
    width: 44px; height: 44px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--ink); border: 1px solid var(--line);
}
.hist-arrow:disabled { opacity: .3; }
.hist-month {
    font-family: var(--display); font-weight: 600; font-size: 1.05rem;
    min-width: 150px; text-align: center; color: var(--ink);
}

.hw, .hist-week { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.hw-number {
    width: 25px; flex-shrink: 0; color: var(--muted); text-align: center;
    font-size: .64rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.hw.header .hw-number { color: #A3ADA5; font-size: .58rem; }
.hw-days { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.hw-badge { width: 18px; flex-shrink: 0; text-align: center; font-weight: 700; font-size: .9rem; color: transparent; }
.hd {
    aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
    font-size: .82rem; border-radius: 9px; color: var(--ink);
}
.hd.dow {
    color: var(--muted); font-size: .68rem; text-transform: uppercase;
    letter-spacing: .03em; font-weight: 600; aspect-ratio: auto; padding: 4px 0;
}
.hd.out { color: #CBD2CB; }
.hd.done { background: var(--green); color: #fff; font-weight: 600; }
.hd.today { box-shadow: inset 0 0 0 2px var(--amber); }

.hist-week.complete { background: rgba(31,138,91,.09); border-radius: 12px; }
.hist-week.complete .hw-badge { color: var(--green); }
.hist-week.failed { background: var(--miss-soft); border-radius: 12px; }
.hist-week.current { background: rgba(74,131,196,.09); border-radius: 12px; }
.hist-week.upcoming { opacity: .52; }
.hist-week.skipped {
    background: repeating-linear-gradient(-45deg, #F0F2EF, #F0F2EF 5px, #E7EAE6 5px, #E7EAE6 10px);
    border-radius: 12px;
}
.hist-week.skipped .hw-badge { color: var(--muted); }

.hist-banner {
    text-align: center; font-weight: 600; font-size: .9rem;
    padding: 10px; border-radius: 10px; margin-top: 12px;
}
.hist-banner.complete { background: var(--green-soft); color: var(--green-deep); }
.hist-banner.skipped { background: var(--line-soft); color: var(--muted); }

.hist-legend { display: flex; gap: 14px; justify-content: center; margin: 10px 0 2px; font-size: .74rem; color: var(--muted); }
.lg { display: flex; align-items: center; gap: 6px; }
.lg-dot { width: 12px; height: 12px; border-radius: 4px; background: var(--green); }
.lg-box { width: 14px; height: 12px; border-radius: 4px; background: rgba(31,138,91,.15); border: 1px solid rgba(31,138,91,.4); }
.lg-fail { width: 14px; height: 12px; border-radius: 4px; background: var(--miss-soft); border: 1px solid rgba(200,86,79,.4); }

/* card d'Inici tocable */
.card.tappable { cursor: pointer; transition: transform .08s; }
.card.tappable:active { transform: scale(.99); }

/* calendari editable */
.hd.edit { cursor: pointer; }
.hd.edit:active { box-shadow: inset 0 0 0 2px var(--green); }
.hw-badge { width: 26px; }
.wk-skip {
    width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
    color: #C7CEC7; border-radius: 7px; background: none;
}
.wk-skip:active { background: var(--miss-soft); }
.wk-skip.on { color: var(--miss); }
.hist-banner.clickable { cursor: pointer; }
.hist-banner.action { background: var(--line-soft); color: var(--muted); }
.hist-banner.clickable:active { filter: brightness(.97); }

/* ------------------------------------------------ finestra d'accions ---- */
.sheet-backdrop {
    position: fixed; inset: 0; z-index: 58;
    background: rgba(22,36,28,.42);
    display: flex; align-items: flex-end; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity .2s;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet-modal {
    background: var(--surface); width: 100%; max-width: 560px;
    border-radius: 22px 22px 0 0;
    padding: 12px 18px calc(20px + env(safe-area-inset-bottom));
    box-shadow: var(--shadow-lg);
    transform: translateY(100%);
    transition: transform .26s cubic-bezier(.2,.85,.25,1);
}
.sheet-backdrop.open .sheet-modal { transform: translateY(0); }
.sheet-modal h3 { font-family: var(--display); font-size: 1.2rem; margin-top: 4px; }
.sheet-sub { color: var(--muted); font-size: .85rem; margin: 3px 0 16px; }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.sheet-btn {
    display: flex; align-items: center; gap: 12px;
    width: 100%; text-align: left;
    padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px;
    background: var(--surface); font-size: .95rem; font-weight: 500; color: var(--ink);
    transition: background .15s, border-color .15s;
}
.sheet-btn:active { background: var(--bg); }
/* icona de l'acció: quadrat arrodonit amb el color de l'acció, com les
   icones de la resta de l'app (abans eren emoji i desentonaven) */
.sheet-btn .sheet-ic {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
}
.sheet-ic svg { width: 19px; height: 19px; }
.sheet-ic.tone-good { background: rgba(31,138,91,.12);  color: var(--green); }
.sheet-ic.tone-warn { background: rgba(221,160,50,.17); color: #A87C1C; }
.sheet-ic.tone-info { background: rgba(74,131,196,.13); color: var(--info); }
.sheet-ic.tone-miss { background: var(--miss-soft);     color: var(--miss); }
.sheet-btn.good { border-color: rgba(31,138,91,.4); }
.sheet-btn.danger { color: var(--miss); border-color: rgba(200,86,79,.35); }
.sheet-btn.active { background: var(--line-soft); border-color: #C4CBC4; font-weight: 600; }
.sheet-modal .btn-ghost { width: 100%; }

/* ----------------------------------------------------------------- toast -- */
.toast {
    position: fixed; left: 50%;
    bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom));
    transform: translateX(-50%) translateY(16px);
    background: var(--ink); color: #fff;
    padding: 11px 19px; border-radius: 999px;
    font-size: .88rem; font-weight: 500;
    opacity: 0; pointer-events: none; transition: all .25s; z-index: 90;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--miss); }

/* ----------------------------------------------------------------- login -- */
.login-body {
    min-height: 100vh; min-height: 100dvh;
    display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 36px 28px; width: 100%; max-width: 360px; text-align: center;
}
.login-mark { font-size: 1.9rem; color: var(--green); letter-spacing: -5px; }
.login-title { font-family: var(--display); font-size: 1.7rem; margin-top: 10px; }
.login-sub { color: var(--muted); font-size: .9rem; margin: 5px 0 24px; }
.login-form { text-align: left; }
.login-form label {
    display: block; font-size: .74rem; font-weight: 600; color: var(--muted);
    margin: 0 0 7px; text-transform: uppercase; letter-spacing: .05em;
}
.login-form input {
    width: 100%; padding: 12px 13px; margin-bottom: 15px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.login-form input:focus {
    outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft);
}
.login-form .btn { width: 100%; }
.login-error {
    background: var(--miss-soft); color: var(--miss);
    padding: 10px; border-radius: var(--radius-sm);
    font-size: .86rem; margin-bottom: 16px;
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

/* ==========================================================================
   MULTIUSUARI — interruptors, preferències i hàbits compartits
   ========================================================================== */

/* interruptor (switch) */
.switch-row {
    display: flex; align-items: center; gap: 14px;
    cursor: pointer; position: relative;
    /* reset: no ha d'heretar l'estil de les etiquetes del formulari */
    text-transform: none; letter-spacing: normal; font-size: 1rem;
    color: var(--ink); font-weight: 400; margin: 0;
}
.switch-row.boxed {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius-sm); padding: 14px 15px;
    margin-bottom: 18px;
}
.switch-row.card-like {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow);
}
.switch-txt { flex: 1; min-width: 0; }
.switch-txt b {
    display: block; font-weight: 600; font-size: .95rem; color: var(--ink);
    text-transform: none; letter-spacing: normal;
}
.switch-txt small {
    display: block; color: var(--muted); font-size: .8rem; margin-top: 3px;
    line-height: 1.35; text-transform: none; letter-spacing: normal; font-weight: 400;
}
input.switch { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-ui {
    flex-shrink: 0; width: 46px; height: 27px; border-radius: 999px;
    background: #D6DCD7; position: relative; transition: background .2s;
}
.switch-ui::after {
    content: ''; position: absolute; top: 3px; left: 3px;
    width: 21px; height: 21px; border-radius: 50%; background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s;
}
input.switch:checked ~ .switch-ui { background: var(--green); }
input.switch:checked ~ .switch-ui::after { transform: translateX(19px); }
input.switch:focus-visible ~ .switch-ui {
    outline: 3px solid rgba(27,119,80,.32); outline-offset: 3px;
}

.share-users-wrap {
    margin: -7px 0 18px; padding: 13px 14px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface);
}
.share-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.share-option {
    display: inline-flex; align-items: center; gap: 7px; min-height: 42px;
    padding: 6px 10px 6px 7px; border: 1px solid var(--line);
    border-radius: 999px; background: var(--bg); color: var(--ink);
    font-size: .82rem; font-weight: 600; cursor: pointer;
    text-transform: none; letter-spacing: normal; margin: 0;
}
.share-option input { position: absolute; opacity: 0; pointer-events: none; }
.share-avatar {
    width: 28px; height: 28px; display: inline-flex; align-items: center;
    justify-content: center; border-radius: 50%; background: var(--line-soft);
    color: var(--muted); font-family: var(--display); font-weight: 700;
}
.share-option i { display: none; color: var(--green-deep); font-style: normal; }
.share-option:has(input:checked) {
    border-color: rgba(31,138,91,.45); background: var(--green-soft);
    color: var(--green-deep);
}
.share-option:has(input:checked) .share-avatar { background: var(--green); color: #fff; }
.share-option:has(input:checked) i { display: inline; }
.share-option:has(input:focus-visible) { outline: 3px solid rgba(27,119,80,.25); outline-offset: 2px; }
.field-help {
    display: block; margin-top: 9px; color: var(--muted); font-size: .76rem;
    line-height: 1.35; text-transform: none; letter-spacing: normal; font-weight: 400;
}

.telegram-panel {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); margin-top: 10px; overflow: hidden; box-shadow: var(--shadow);
}
.telegram-main {
    display: grid; grid-template-columns: 36px minmax(0, 1fr) auto;
    align-items: center; gap: 12px; padding: 14px 16px;
}
.telegram-icon {
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    border-radius: 11px; color: var(--muted); background: var(--line-soft); flex-shrink: 0;
}
.telegram-icon svg { width: 20px; height: 20px; }
.telegram-panel.connected .telegram-icon { color: var(--green-deep); background: var(--green-soft); }
.btn-test {
    min-width: 64px; min-height: 44px; padding: 8px 12px;
    border: 1px solid var(--line); border-radius: 10px;
    color: var(--green-deep); background: var(--surface); font-weight: 600;
}
.telegram-warning {
    margin: 0 16px 12px 64px; padding: 10px 12px; border-radius: 10px;
    background: var(--miss-soft); color: #8E302B; font-size: .8rem;
}
.telegram-disconnect-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 11px 16px; border-top: 1px solid var(--line-soft);
    color: var(--muted); font-size: .76rem;
}
.telegram-disconnect-row .btn-integration { min-height: 40px; }

.app-update-row {
    display: flex; align-items: center; gap: 12px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 14px 16px; margin-top: 10px;
    box-shadow: var(--shadow);
}
.app-update-icon {
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    border-radius: 11px; color: var(--green-deep); background: var(--green-soft); flex-shrink: 0;
}
.app-update-icon svg { width: 20px; height: 20px; }
.app-update-row.checking .app-update-icon svg { animation: update-spin .8s linear infinite; }
@keyframes update-spin { to { transform: rotate(360deg); } }

.whoop-panel {
    margin-top: 10px; overflow: hidden;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.whoop-settings-main {
    display: grid; grid-template-columns: 36px minmax(0, 1fr) auto;
    align-items: center; gap: 12px; padding: 14px 16px;
}
.whoop-settings-icon {
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    border-radius: 11px; color: #675A7D; background: #F0ECF7; flex-shrink: 0;
}
.whoop-settings-icon svg { width: 21px; height: 21px; }
.whoop-panel.connected .whoop-settings-icon { color: var(--green-deep); background: var(--green-soft); }
.btn-integration {
    min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
    color: var(--green-deep); background: var(--surface); font-size: .8rem;
    font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn-integration.subtle { color: var(--muted); }
.whoop-toggle-row {
    display: flex; align-items: center; gap: 14px; position: relative;
    padding: 13px 16px 14px; border-top: 1px solid var(--line-soft);
    cursor: pointer; color: var(--ink);
}
.whoop-toggle-row.is-disabled { cursor: default; }
.whoop-toggle-row.is-disabled .switch-txt b,
.whoop-toggle-row.is-disabled .switch-txt small { color: var(--muted); }
.whoop-toggle-row input.switch:disabled ~ .switch-ui { opacity: .55; }
.whoop-config-warning {
    margin: 0 16px 12px 64px; padding: 10px 12px; border-radius: 10px;
    background: #FFF3D8; color: #76530A; font-size: .8rem;
}

@media (max-width: 719px) {
    #view-home > .hero-sub { margin-top: 13px; }
}

@media (max-width: 380px) {
    #home-title { font-size: 1.05rem; }
    .home-scope button { padding-inline: 8px; font-size: .72rem; }
    .telegram-main, .whoop-settings-main, .app-update-row { gap: 9px; padding-inline: 12px; }
    .telegram-icon, .whoop-settings-icon, .app-update-icon { width: 32px; height: 32px; }
    .telegram-main,
    .whoop-settings-main { grid-template-columns: 32px minmax(0, 1fr) auto; }
    .telegram-main .btn-test,
    .whoop-settings-main .btn-integration,
    .app-update-row .btn-test { min-height: 40px; padding: 6px 9px; font-size: .74rem; }
    .telegram-warning { margin-left: 53px; margin-right: 12px; }
    .telegram-disconnect-row { padding-inline: 12px; }
    .whoop-config-warning { margin-left: 53px; margin-right: 12px; }
}

/* bloc de preferències (final de Configurar) */
.settings-block { margin-top: 26px; }
.settings-title {
    font-family: var(--display); font-size: .8rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
    margin: 0 2px 10px;
}

/* separador de la secció pública */
.public-head { display: flex; align-items: center; gap: 12px; margin: 26px 2px 14px; }
.public-line { flex: 1; height: 1px; background: var(--line); }
.public-label {
    font-size: .7rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .06em; color: var(--muted); white-space: nowrap;
}

/* card d'hàbit compartit aliè — mateixa estructura que les pròpies */

/* fila d'etiquetes: propietari + estat del període */
.card-owner {
    display: flex; align-items: center; gap: 8px;
    flex-wrap: wrap; margin-top: 7px;
}
/* darrera compleció: sempre a la seva pròpia línia (pot ser llarga) */
.card-lastrow { display: flex; margin-top: 6px; }

/* hàbits compartits: franja d'informació a tota l'amplada de la card */
.pub-strip {
    margin-top: 13px; padding-top: 12px;
    border-top: 1px solid var(--line-soft);
    display: flex; flex-wrap: wrap; gap: 8px 20px;
}
.ps-row {
    display: flex; align-items: center; gap: 9px;
    font-size: .82rem; color: var(--ink-soft); line-height: 1.3;
}
.ps-ico {
    width: 24px; height: 24px; flex-shrink: 0; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
}
.ps-ico svg { width: 14px; height: 14px; }
.ps-ico.cal { background: rgba(74,131,196,.13); color: #4A83C4; }
.ps-ico.clk { background: rgba(31,138,91,.12); color: #2F9E6B; }
.ps-k { color: var(--muted); font-weight: 600; }
.ps-txt { min-width: 0; }
.owner-tag {
    font-size: .66rem; font-weight: 600; letter-spacing: .02em;
    color: #6D4AA8; background: #F0EAFA;
    border: 1px solid rgba(139,92,246,.24);
    padding: 1px 8px; border-radius: 999px;
    white-space: nowrap;
}
.pub-tag {
    font-size: .66rem; font-weight: 600; letter-spacing: .02em;
    color: #3D6E9E; background: #E7F0F8;
    border: 1px solid rgba(74,131,196,.24);
    padding: 1px 8px; border-radius: 999px;
    white-space: nowrap;
}

.flag-tag {
    font-size: .66rem; font-weight: 600; letter-spacing: .02em;
    padding: 1px 8px; border-radius: 999px; white-space: nowrap;
    border: 1px solid transparent;
}
.flag-tag.tone-good    { color: var(--green-deep); background: var(--green-soft); border-color: rgba(31,138,91,.22); }
.flag-tag.tone-warn    { color: #8A6410; background: rgba(221,160,50,.18); border-color: rgba(221,160,50,.4); }
.flag-tag.tone-neutral { color: #4E5A52; background: #E3E8E3; border-color: rgba(103,115,107,.38); }
.flag-tag.tone-muted   { color: #8A938B; background: transparent; border-color: var(--line); }
.flag-tag.tone-miss    { color: #A8322B; background: var(--miss-soft); border-color: rgba(200,86,79,.45); }
.flag-tag.tone-info    { color: #3D6E9E; background: #E7F0F8; border-color: rgba(74,131,196,.24); }

/* modal de detall d'hàbit compartit */
.info-backdrop {
    position: fixed; inset: 0; z-index: 62;
    background: rgba(22,36,28,.45);
    display: flex; align-items: flex-end; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity .2s;
}
.info-backdrop.open { opacity: 1; pointer-events: auto; }
.info-card {
    background: var(--surface); width: 100%; max-width: 560px;
    border-radius: 22px 22px 0 0;
    padding: 12px 18px calc(20px + env(safe-area-inset-bottom));
    box-shadow: var(--shadow-lg);
    transform: translateY(100%);
    transition: transform .26s cubic-bezier(.2,.85,.25,1);
}
.info-backdrop.open .info-card { transform: translateY(0); }
.info-card h3 { font-family: var(--display); font-size: 1.2rem; margin-top: 4px; }
.info-owner { display: flex; gap: 7px; margin: 8px 0 16px; }
.info-rows { margin-bottom: 16px; }
.info-row {
    display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
    padding: 10px 2px; border-bottom: 1px solid var(--line-soft);
}
.info-row:last-child { border-bottom: none; }
.ir-k { font-size: .82rem; color: var(--muted); }
.ir-v { font-size: .92rem; font-weight: 600; color: var(--ink); text-align: right; }
.info-card .btn-ghost { width: 100%; }

/* card apagada quan avui no li toca (però mai si va endarrerit) */
.card.shared.dim { opacity: .62; }

/* ==========================================================================
   INICI — seccions, cards compactes i tira del període
   ========================================================================== */

/* segona línia de l'hero: com va la setmana en conjunt */
.hero-week {
    margin-top: 9px; font-size: .85rem; color: var(--muted);
    display: flex; align-items: center; gap: 9px;
}
.hero-week b { color: var(--ink-soft); font-weight: 600; }
.wk-bar {
    flex: 1; max-width: 130px; height: 5px; border-radius: 99px;
    background: var(--line-soft); overflow: hidden;
}
.wk-fill { display: block; height: 100%; background: var(--green); border-radius: 99px; }

/* capçaleres de secció (Avui / La resta) */
.sec { display: flex; align-items: center; gap: 10px; margin: 26px 0 12px; }
.sec:first-child { margin-top: 6px; }
.sec-label {
    font-family: var(--display); font-weight: 600; font-size: .73rem;
    letter-spacing: .11em; text-transform: uppercase; color: var(--muted); white-space: nowrap;
}
.sec-line { flex: 1; height: 1px; background: var(--line); }
.sec-count { font-size: .73rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* card compacta: hàbits propis que avui no toquen */
.rest {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px;
    box-shadow: 0 1px 2px rgba(22,36,28,.03);
    transition: transform .12s, border-color .18s;
}
.rest:active { transform: scale(.99); }
.rest.dim { opacity: .88; }
.rest.attention {
    background: #FFFCF7;
    border-color: rgba(221,160,50,.34);
}
.rest.attention-miss {
    background: #FFF9F8;
    border-color: rgba(183,68,61,.32);
}
.rest-top { display: flex; align-items: center; gap: 12px; }
.rest-txt { flex: 1; min-width: 0; }
.rest-title {
    font-family: var(--display); font-weight: 600; font-size: 1rem;
    letter-spacing: -.01em; color: var(--ink);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rest-when {
    font-size: .78rem; color: var(--muted); margin-top: 2px;
    display: flex; align-items: center; gap: 6px;
}
.rest-runtime {
    font-size: .76rem; color: var(--muted); margin-top: 4px;
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.rest-runtime.tone-good { color: var(--green-deep); }
.rest-runtime .st-dot { flex-shrink: 0; }
.rest-runtime .rec-badge { flex-shrink: 0; }

/* anell petit */
.mini-ring { position: relative; width: 38px; height: 38px; flex-shrink: 0; }
.mini-ring svg { width: 38px; height: 38px; }
.mr-track { fill: none; stroke: var(--line-soft); stroke-width: 4.5; }
.mr-arc {
    fill: none; stroke-width: 4.5; stroke-linecap: round;
    transition: stroke-dashoffset .6s cubic-bezier(.3,.9,.3,1);
}
.mr-num {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-family: var(--display); font-weight: 700; font-size: .72rem;
    font-variant-numeric: tabular-nums; color: var(--ink);
}

/* tira de la setmana */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-top: 11px; }
.wd {
    display: flex; flex-direction: column; align-items: center; gap: 5px;
    padding: 5px 0 4px; border-radius: 8px;
}
.wd.now { background: var(--green-soft); }
.wd-l { font-size: .62rem; font-weight: 500; color: var(--muted); letter-spacing: .02em; }
.wd.now .wd-l { color: var(--green-deep); font-weight: 600; }
.mark { display: block; width: 13px; height: 13px; }
.m-done { border-radius: 50%; background: var(--green); }
.m-due  { border-radius: 50%; border: 2px solid var(--ink-soft); opacity: .45; }
.m-miss { border-radius: 50%; border: 2px solid var(--miss); background: var(--miss-soft); }
.m-free { width: 5px; height: 5px; margin: 4px; border-radius: 50%; background: var(--line); }

/* llegenda */
.legend {
    display: flex; flex-wrap: wrap; gap: 14px; justify-content: center;
    margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line);
    font-size: .74rem; color: var(--muted);
}
.lg { display: flex; align-items: center; gap: 6px; }

/* ==========================================================================
   GRUP — hàbits compartits per altres usuaris
   ========================================================================== */
.grup-sub { font-size: .88rem; color: var(--muted); margin: 5px 0 4px; }

.avatar {
    width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
    background: #F0EAFA; border: 1px solid rgba(139,92,246,.24); color: #6D4AA8;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--display); font-weight: 700; font-size: .92rem;
}

.card.shared .card-status { margin-top: 7px; }

/* capçalera de persona: el mateix acordió que els grups de categoria */
.person-group .cat-head { padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.person-group .cat-head-left { font-size: 1rem; gap: 10px; }
.person-sum {
    margin-left: auto; margin-right: 10px;
    font-size: .76rem; color: var(--muted); font-variant-numeric: tabular-nums;
}
.person-sum b { color: var(--ink-soft); font-weight: 600; }
.pub-rule { margin-top: 7px; font-size: .79rem; color: var(--muted); }
.pub-last {
    margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line-soft);
    font-size: .75rem; color: var(--muted);
}
.pub-last b { color: var(--ink-soft); font-weight: 600; }

/* Configurar: grup d'hàbits en pausa */
.paused-group .cat-head { color: var(--muted); }
.sheet-modal { position: relative; }

/* sheet: segona línia amb la regla i l'hora */
.sheet-sub b { color: var(--ink-soft); font-weight: 600; }
.sheet-rule { display: block; margin-top: 3px; font-size: .8rem; color: var(--muted); }

/* Configurar: botó de pausa/reactivar a la card */
.cc-pause {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 10px; color: var(--muted);
}
.cc-pause:hover { background: var(--line-soft); color: var(--ink-soft); }

/* ==========================================================================
   Configurar — card reorganitzada: accions a l'alçada del títol i metadades
   en una sola línia discreta (sense filet separador).
   ========================================================================== */
.cc-actions {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    flex-shrink: 0;
}
/* Mateix llenguatge que les icones del sheet: quadrat arrodonit amb el
   color de l'acció. Aquí una mica més petit, perquè la card és més densa. */
.cc-pause, .crow-del {
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; padding: 0; border-radius: 10px;
    transition: filter .15s;
}
.cc-pause, .crow-del { filter: none; }
.cc-pause:hover, .cc-pause:focus-visible,
.crow-del:hover, .crow-del:focus-visible { filter: brightness(.94); }
.cc-pause svg, .crow-del svg { width: 18px; height: 18px; }

.cc-foot {
    display: flex; align-items: center; gap: 0;
    margin-top: 8px; padding-top: 0; border-top: none;
    font-size: .79rem; font-weight: 400; color: var(--muted);
}
.cc-foot-item + .cc-foot-item::before {
    content: '·'; margin: 0 8px; color: var(--line);
}
.cc-foot-item.muted { color: #A9B2AA; }

/* Configurar — accions: separador i color contingut */
/* separa la informació de l'hàbit de la columna d'accions */
.cc-div {
    width: 1px; align-self: stretch; margin: 2px 0;
    background: var(--line); flex-shrink: 0;
}
.cc-pause         { background: rgba(221,160,50,.17); color: #A87C1C; }   /* pausar */
.cc-pause.resume  { background: rgba(31,138,91,.12);  color: var(--green); } /* reactivar */
.crow-del         { background: var(--miss-soft);     color: var(--miss); }  /* eliminar */

/* ==========================================================================
   PROGRÉS — resum mensual, ratxes i lectura setmanal
   ========================================================================== */
.overview-head { margin: 2px 2px 16px; }
.overview-head p { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.overview-summary-card {
    overflow: hidden; margin-bottom: 18px; padding: 0 17px 16px;
    color: var(--ink); border: 1px solid #E5DFF1; border-radius: var(--radius);
    background: linear-gradient(145deg, #FBF9FF 0%, #F3EFFB 100%);
    box-shadow: 0 1px 2px rgba(52,39,76,.035), 0 8px 24px rgba(70,50,105,.055);
}
.overview-summary-card.is-current { border-color: #DCD2EE; }
.overview-nav {
    display: flex; align-items: center; justify-content: space-between;
    margin: 0 -5px 15px; padding: 8px 0;
    border-bottom: 1px solid var(--line);
}
.overview-arrow {
    width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
    border-radius: 12px; color: #69558D; background: #ECE6F7;
}
.overview-arrow:hover, .overview-arrow:focus-visible { background: #E2D9F2; }
.overview-arrow:disabled { opacity: .25; cursor: default; }
.overview-month {
    font-family: var(--display); font-size: 1rem; font-weight: 600;
    color: var(--ink); padding: 7px 12px;
}
.overview-score { display: flex; align-items: center; gap: 14px; }
.overview-score-number {
    font-family: var(--display); font-weight: 750; font-size: 2rem;
    line-height: 1; min-width: 78px; color: #665184; font-variant-numeric: tabular-nums;
}
.overview-score-copy { display: flex; flex-direction: column; min-width: 0; }
.overview-score-copy span {
    color: var(--muted); font-size: .66rem; font-weight: 700;
    letter-spacing: .07em; text-transform: uppercase;
}
.overview-score-copy b { margin-top: 3px; font-size: .82rem; line-height: 1.35; }
.overview-live {
    display: flex; align-items: center; gap: 6px; width: fit-content;
    margin-top: 7px; color: var(--muted); font-size: .66rem; font-weight: 500;
}
.overview-live i { width: 7px; height: 7px; border-radius: 50%; background: #8B75B0; }
.overview-metrics {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 16px;
    padding-top: 13px; border-top: 1px solid var(--line);
}
.ov-metric {
    min-width: 0; display: flex; flex-direction: column; align-items: center;
    border-radius: 11px; padding: 8px 4px; background: var(--line-soft);
}
.ov-metric b { color: var(--ink); font-family: var(--display); font-size: 1rem; line-height: 1; }
.ov-metric small { margin-top: 4px; color: var(--muted); font-size: .62rem; }
.ov-metric.good { background: var(--green-soft); }
.ov-metric.good b { color: var(--green-deep); }
.ov-metric.bad { background: var(--miss-soft); }
.ov-metric.bad b { color: var(--miss); }
.ov-metric.current { background: rgba(74,131,196,.11); }
.ov-metric.current b { color: var(--info); }
.overview-legend {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 9px 13px;
    margin-top: 13px; color: var(--muted); font-size: .64rem;
}
.overview-legend span { display: flex; align-items: center; gap: 5px; }
.overview-legend i { width: 9px; height: 9px; border-radius: 3px; }
.overview-legend i.complete { background: var(--green); }
.overview-legend i.failed { background: #D97871; }
.overview-legend i.current { background: var(--info); }
.overview-legend i.upcoming { background: #BCC5BE; }

.overview-habit {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.overview-habit-head { display: flex; align-items: center; gap: 11px; }
.overview-cat {
    width: 38px; height: 38px; flex-shrink: 0; display: flex; align-items: center;
    justify-content: center; border-radius: 12px; font-size: 1.05rem;
    background: var(--line-soft); border-bottom: 3px solid var(--cat);
}
.overview-habit-title { flex: 1; min-width: 0; }
.overview-habit-title > div { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.overview-habit-title h2 {
    font-family: var(--display); font-size: 1rem; line-height: 1.2;
    overflow-wrap: anywhere;
}
.overview-habit-title p { color: var(--muted); font-size: .72rem; margin-top: 3px; }
.overview-paused {
    font-size: .58rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); background: var(--line-soft); border-radius: 999px;
    padding: 2px 6px; font-weight: 600;
}
.overview-streaks {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px;
    margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-soft);
}
.overview-streaks > span {
    min-width: 0; display: grid; grid-template-columns: auto 1fr auto;
    align-items: center; gap: 6px; padding: 8px 9px;
    border-radius: 10px; background: var(--bg); color: var(--muted);
}
.overview-streaks i { font-style: normal; font-size: .82rem; filter: grayscale(.7); opacity: .7; }
.overview-streaks span span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .66rem; }
.overview-streaks b { color: var(--ink-soft); font-family: var(--display); font-size: .88rem; }
.overview-streaks .streak-current.active { background: #FFF5E2; color: #825B0C; }
.overview-streaks .streak-current.active i { filter: none; opacity: 1; }
.overview-streaks .streak-current.active b { color: #825B0C; }
.overview-weeks-title {
    margin-top: 14px; color: var(--muted); font-size: .65rem; font-weight: 700;
    letter-spacing: .07em; text-transform: uppercase;
}
.overview-weeks {
    display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 7px; margin-top: 7px;
}
.overview-week {
    grid-column: span 3;
    min-width: 0; border: 1px solid var(--line); border-radius: 11px;
    padding: 9px 10px; display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "label label" "state score";
    align-items: center; column-gap: 8px; row-gap: 5px;
    text-align: left; background: var(--bg);
}
.overview-weeks.weeks-5 .overview-week:nth-child(n+3) { grid-column: span 2; }
.overview-week-label {
    grid-area: label; display: flex; align-items: center;
    justify-content: space-between; gap: 6px;
}
.overview-week-label b { color: var(--muted); font-size: .72rem; letter-spacing: .03em; text-transform: uppercase; }
.overview-week-label small { color: var(--muted); font-size: .68rem; white-space: nowrap; }
.overview-week > strong {
    grid-area: score; justify-self: end; font-family: var(--display); font-size: 1rem;
    line-height: 1; color: var(--ink-soft); font-variant-numeric: tabular-nums;
}
.overview-week > strong small { color: inherit; font-size: .68rem; font-weight: 600; opacity: .66; }
.overview-week-state {
    grid-area: state; display: flex; align-items: center; gap: 4px;
    min-width: 0; font-size: .7rem; font-weight: 650; white-space: nowrap;
}
.overview-week-state i { font-style: normal; font-size: .68rem; }
.overview-week.complete { background: var(--green-soft); border-color: rgba(31,138,91,.28); }
.overview-week.complete > strong, .overview-week.complete .overview-week-state { color: var(--green-deep); }
.overview-week.failed { background: var(--miss-soft); border-color: rgba(200,86,79,.28); }
.overview-week.failed > strong, .overview-week.failed .overview-week-state { color: var(--miss); }
.overview-week.current { background: rgba(74,131,196,.1); border-color: rgba(74,131,196,.3); }
.overview-week.current > strong, .overview-week.current .overview-week-state { color: var(--info); }
.overview-week.upcoming { background: #F7F8F6; opacity: .65; }
.overview-loading { text-align: center; color: var(--muted); font-size: .88rem; padding: 42px 0; }

/* Càrrega inicial i recuperació d'errors */
.skeleton-list { display: grid; gap: 10px; }
.skeleton-card {
    position: relative; height: 112px; padding: 20px 86px 20px 16px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    overflow: hidden;
}
.skeleton-card::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(100deg, transparent 25%, rgba(255,255,255,.72) 48%, transparent 72%);
    transform: translateX(-100%); animation: skeleton 1.25s infinite;
}
.skeleton-card span {
    display: block; height: 12px; margin-bottom: 12px;
    border-radius: 99px; background: var(--line-soft);
}
.skeleton-card span:nth-child(2) { width: 68%; height: 9px; }
.skeleton-card i {
    position: absolute; right: 18px; top: 22px;
    width: 64px; height: 64px; border-radius: 50%; background: var(--line-soft);
}
@keyframes skeleton { to { transform: translateX(100%); } }
.empty-cta, .retry-load, .retry-overview {
    display: inline-flex; align-items: center; margin-top: 18px; width: auto;
}

/* En escriptori, capçalera, contingut i navegació comparteixen la mateixa amplada. */
@media (min-width: 720px) {
    body { background: #EEF2EE; }
    .app-header {
        max-width: 560px; margin: 0 auto;
        border-left: 1px solid var(--line); border-right: 1px solid var(--line);
    }
    .app { min-height: calc(100vh - var(--header-h)); background: var(--bg); }
    .tabbar {
        left: 50%; right: auto; width: 100%; max-width: 560px;
        transform: translateX(-50%);
        border-left: 1px solid var(--line); border-right: 1px solid var(--line);
        box-shadow: 0 -8px 24px rgba(22,36,28,.06);
    }
}
