/* gooogle fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* root */
:root {
    /* FLUID type scale: every token is clamp(min, vw-curve, max) so text and chrome grow
       proportionally from small phones (~320px) to wide screens (~1600px) — no step jumps. */
    --font-size-default: clamp(10px, 0.23vw + 9.25px, 13px);
    --font-size-small: clamp(9px, 0.16vw + 8.5px, 11px);
    --font-size-medium: clamp(12px, 0.23vw + 11.25px, 15px);
    --font-size-large: clamp(19px, 0.55vw + 17.25px, 26px);
    --font-size-icon: clamp(16px, 0.31vw + 15px, 20px); /* header/action icons — NOT the large display size */
    --font-family: "Inter", sans-serif;
    --bg-grey: rgba(0, 0, 0, 0.06); /* hairlines/soft borders: felt more than seen */
    --bg-white: rgba(255, 255, 255, 1);
    --bg-white-opacity: rgba(255, 255, 255, 0.25);
    --bg-black: rgba(0, 0, 0, 1);
    --bg-red: rgba( 255, 0, 0, 1);
    --padding-default: clamp(6px, 0.16vw + 5.5px, 8px);
    --padding-small: clamp(11px, 0.55vw + 9.25px, 18px);
    --padding-medium: 2rem;
    --padding-large: 3rem;
    --letter-spacing: 0.3px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --button-click-scale: 0.85;
    --transition-fast: 120ms ease;
    --transition-base: 200ms ease;
    --gradiant-white-black-soft: linear-gradient(139deg, rgba(255,255,255,1) 46%, rgba(238,238,238,1) 70%, rgba(255,255,255,1) 100%);
    /* Monochrome design tokens (Notes design, 2026-07): black is the accent.
       Card/track/grey ramp — flipped by #app.dark exactly like the bg vars. */
    --bg-card: rgba(255, 255, 255, 1);
    --bg-sheet: rgba(255, 255, 255, 1);
    --bg-track: rgba(0, 0, 0, 0.03);
    --text-grey: rgba(0, 0, 0, 0.62);
    --text-grey-soft: rgba(0, 0, 0, 0.42);
    --on-ink-soft: rgba(255, 255, 255, 0.25);
    /* Chip scale (forecast strips + similar dense rows) and layout gaps — fluid like the type
       scale above; dense-chip UIs consume these tokens. */
    --font-size-chip: clamp(8.5px, 0.16vw + 8px, 10.5px);
    --font-size-chip-strong: clamp(9.5px, 0.16vw + 9px, 11.5px);
    --font-size-chip-icon: clamp(12px, 0.23vw + 11.25px, 15px);
    --gap-chip: clamp(7px, 0.39vw + 5.75px, 12px);
    --gap-card: clamp(7px, 0.39vw + 5.75px, 12px);
    /* Subtle edge shadow that appears when a row can scroll — the swipe affordance. */
    --scroll-shadow: rgba(0, 0, 0, 0.07);
    /* Header and footer share ONE height. */
    --bar-height: 54px;
}

/* Responsive type scale: the font tokens shrink on narrow viewports so text fits the
   device instead of wrapping/clipping. Everything using the vars follows automatically. */
/* (The old ≤400px/≤350px step overrides are gone — the clamp() curves above scale every token
   continuously with the viewport instead.) */

/* focus */
*:focus {
    outline: none;
}

/* keyframes */
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes pillPop {
    0%   { transform: scale(0.88); opacity: 0; }
    60%  { transform: scale(1.04); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes offlineDrop {
    from { opacity: 0; transform: translate(-50%, -10px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

/* body */
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: fixed;
    left: 0;
    top: 0;
    letter-spacing: var(--letter-spacing);
    font-weight: 400;
    font-family: var(--font-family);
    background: var(--bg-white);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* offline */
#offline {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    animation: offlineDrop var(--transition-base) forwards;
}

#offline span {
    background: var(--bg-red);
    color: var(--bg-white);
    font-size: var(--font-size-default);
    padding: var(--padding-default) var(--padding-small);
    border-radius: 1rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

/* app */
#app {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--gradiant-white-black-soft);
    background-size: 300% 300%;
    color: var(--bg-black);
    font-size: var(--font-size-medium);
    letter-spacing: 0.3px;
}

/* app dark mode */
#app.dark {
    --bg-white: rgba(0, 0, 0, 1);
    --bg-black: rgba(255, 255, 255, 1);
    --bg-grey: rgba(255, 255, 255, 0.09); /* hairlines/soft borders: felt more than seen */
    --bg-white-opacity: rgba(0, 0, 0, 0.25);
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-sheet: rgba(22, 22, 22, 1);
    --bg-track: rgba(255, 255, 255, 0.09);
    --text-grey: rgba(255, 255, 255, 0.65);
    --text-grey-soft: rgba(255, 255, 255, 0.42);
    --on-ink-soft: rgba(0, 0, 0, 0.15);
    --scroll-shadow: rgba(255, 255, 255, 0.09);
    animation: none;
    background: var(--bg-white);
}

#app.dark header .logo img {
    filter: invert(1);
}


/* app form */
#app form .formGroup {
    display: flex;
    background: var(--bg-black);
    padding: var(--padding-small);
    color: var(--bg-white);
    border-radius: 2rem;
    margin-bottom: 1rem;
    gap: 1rem;
    transition: box-shadow var(--transition-base);
}

#app form .formGroup i {
    margin-left: 0.5rem;
    opacity: 0.5;
    transition: opacity var(--transition-base);
}

#app form .formGroup:focus-within i {
    opacity: 1;
}

#app form .formGroup input {
    font-family: var(--font-family);
    background: transparent;
    border: 0;
    width: 100%;
    letter-spacing: var(--letter-spacing);
    font-size: var(--font-size-medium);
    font-optical-sizing: auto;
    font-style: normal;
    font-weight: 400;
    color: var(--bg-white);
}

#app form .formGroup input::placeholder {
    color: var(--bg-white-opacity);
}

#app form .formSubmit {
    text-align: center;  
    margin-top: var(--padding-default);
}

#app form .formSubmit button {
    width: auto;
    padding: var(--padding-default) var(--padding-small);
    border-radius: 1rem;
    font-family: var(--font-family);
    font-size: var(--font-size-medium);
    font-weight: 700;
    letter-spacing: var(--letter-spacing);
    border: 1px solid var(--bg-grey);
    background: var(--bg-white);
    color: var(--bg-black);
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-base);
}

#app form .formSubmit button:hover {
    box-shadow: var(--box-shadow);
}

#app form .formSubmit button:active {
    transform: scale(var(--button-click-scale));
}

#app form .formMessage {
    font-size: var(--font-size-default);
    color: var(--bg-red);
    text-align: center;
    margin-top: 1rem;
    animation: fadeSlideUp var(--transition-base) forwards;
}

/* auth screens (login / signup / forgot / reset / join) */
#app form .authTitle {
    text-align: center;
    font-weight: 700;
    margin-bottom: var(--padding-default);
}
#app form .authSubtitle {
    text-align: center;
    color: var(--text-grey);
    font-size: var(--font-size-default);
    margin: -6px 0 var(--padding-default);
}
#app form .authLinks {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin-top: 1rem;
}
#app form .authLinks a {
    color: var(--text-grey);
    font-size: var(--font-size-default);
    text-decoration: underline;
}
#app form .formMessage a {
    color: inherit;
    text-decoration: underline;
}

/* app main */
#app main {
    flex: auto;
    height: 100%;
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border-top: 1px solid var(--bg-grey);
    border-bottom: 1px solid var(--bg-grey);
}

#app main #login {
    display: flex;
    min-width: 300px;
    flex-direction: column;
}

#app.login main {
    border: 0;
}

/* app header */
#app header {
    background: transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    height: calc(var(--bar-height) + var(--safe-top));
    padding: var(--safe-top) var(--padding-small) 0;
    position: relative;
}

#app header .module {
    font-size: inherit;
    font-weight: 700;
}

#app header .logo img {
    max-height: 24px;
}

#app header #darkmode-toggle, 
#app header #filter-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: var(--font-size-icon);
    color: inherit;
    padding: 0;
    transition: transform var(--transition-fast);
}

#app header #darkmode-toggle:active,
#app header #filter-toggle:active {
    transform: scale(var(--button-click-scale));
}

/* App-wide search: header actions group + the search overlay (Render.toggleSearch) */
#app header .header-actions {
    display: flex;
    align-items: center;
    gap: var(--padding-small);
}

#app header #search-toggle,
#app header #overdue-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: var(--font-size-icon);
    color: inherit;
    padding: 0;
    transition: transform var(--transition-fast);
}

#app header #search-toggle:active,
#app header #overdue-toggle:active {
    transform: scale(var(--button-click-scale));
}

/* The bell's red count disc; hidden while nothing is overdue. */
#app header #overdue-toggle { position: relative; }
#app .overdue-badge {
    display: none;
    position: absolute;
    top: -5px;
    right: -7px;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    border-radius: 7px;
    background: #dc2626;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 14px;
    text-align: center;
}
#app .overdue-badge.show { display: block; }

/* The bell dropdown reuses the search overlay shell; this is its static title. */
#app .notif-title { flex: 1; font-weight: 600; }

#app .search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 40;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

#app .search-panel {
    width: min(560px, calc(100% - 16px));
    margin-top: calc(var(--safe-top) + 8px);
    background: var(--bg-sheet);
    color: var(--bg-black);
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    max-height: 80dvh;
    overflow: hidden;
}

#app .search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 6px 2px 14px;
    border-bottom: 1px solid var(--bg-grey);
}
#app .search-bar > i { color: var(--text-grey-soft); }

#app .search-bar .search-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: inherit;
    font-family: var(--font-family);
    letter-spacing: var(--letter-spacing);
    font-size: var(--font-size-medium);
    padding: 13px 0;
    outline: none;
}
#app .search-bar .search-input::placeholder { color: var(--text-grey-soft); }

#app .search-close {
    background: transparent;
    border: none;
    color: var(--text-grey);
    cursor: pointer;
    font-size: var(--font-size-icon);
    padding: 10px;
}

#app .search-results {
    overflow-y: auto;
}

#app .search-result {
    display: flex;
    align-items: center;
    gap: var(--padding-small);
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--bg-grey);
    color: inherit;
    text-align: left;
    padding: var(--padding-small);
    cursor: pointer;
}

#app .search-result:active {
    background: var(--bg-grey);
}

#app .search-result-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

#app .search-result-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#app .search-result-sub {
    font-size: var(--font-size-small, 0.8rem);
    opacity: 0.7;
}

#app .search-result-group {
    font-size: var(--font-size-small, 0.8rem);
    opacity: 0.6;
    white-space: nowrap;
}

#app .search-empty {
    padding: var(--padding-small);
    opacity: 0.7;
    text-align: center;
}

#app header .profile  {
    font-size: var(--font-size-icon);
    color: inherit;
    width: 36px;
    height: 36px;
    box-sizing: border-box;
    border: 2px solid var(--bg-grey);
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform var(--transition-fast), opacity var(--transition-fast);
}

#app header .profile:active {
    transform: scale(var(--button-click-scale));
}

#app header .profile img  {
    width: inherit; 
    height: inherit; 
    object-fit: cover; 
    border-radius: 50%;
}

#app header .profile-dropdown {
    position: absolute;
    top: calc(100% - var(--padding-default));
    left: var(--padding-small);
    background: var(--bg-white);
    border: 1px solid var(--bg-grey);
    border-radius: 1rem;
    box-shadow: var(--box-shadow);
    overflow: hidden;
    animation: fadeSlideUp var(--transition-base) forwards;
    z-index: 20;
}

#app header .profile-dropdown button {
    display: flex;
    align-items: center;
    gap: var(--padding-small);
    width: 100%;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    font-family: var(--font-family);
    font-size: var(--font-size-medium);
    color: var(--bg-black);
    cursor: pointer;
    text-align: left;
    letter-spacing: var(--letter-spacing);
    transition: background var(--transition-fast);
}

#app header .profile-dropdown button:not(:last-child) {
    border-bottom: 1px solid var(--bg-grey);
}

#app header .profile-dropdown button:hover {
    background: var(--bg-grey);
}

#app header .profile-dropdown button i {
    opacity: 0.6;
    width: 14px;
    text-align: center;
}

/* profile drawer */
#app .profile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 30;
    transition: background var(--transition-base);
}

#app .profile-overlay.open {
    background: rgba(0, 0, 0, 0.4);
}

#app .profile-drawer {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    width: min(300px, 80vw);
    background: var(--bg-white);
    color: var(--bg-black);
    display: flex;
    flex-direction: column;
    z-index: 31;
    transform: translateX(-100%);
    transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
}

#app .profile-drawer.open {
    transform: translateX(0);
}

#app .profile-drawer-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: calc(var(--padding-small) + var(--safe-top)) var(--padding-small) var(--padding-small);
    border-bottom: 1px solid var(--bg-grey);
}

#app .profile-drawer-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-grey);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    flex-shrink: 0;
    overflow: hidden;
}

#app .profile-drawer-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

#app .profile-drawer-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

#app .profile-drawer-username {
    font-weight: 600;
    font-size: var(--font-size-medium);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#app .profile-drawer-role {
    font-size: var(--font-size-default);
    opacity: 0.5;
    text-transform: capitalize;
}

#app .profile-drawer-tier {
    font-size: 10px;
    opacity: 0.6;
    background: var(--bg-grey);
    padding: 1px 6px;
    border-radius: 3px;
    display: inline-block;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#app .profile-drawer-tier.tier-free { background: #e0e0e0; color: #333; }
#app .profile-drawer-tier.tier-starter { background: #c8e6c9; color: #2e7d32; }
#app .profile-drawer-tier.tier-family { background: #bbdefb; color: #1565c0; }
#app .profile-drawer-tier.tier-pro { background: #ffe082; color: #f57c00; }

#app .profile-drawer-menu {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: var(--padding-default) 0;
    overflow-y: auto;
    padding-bottom: var(--safe-bottom);
}

#app .profile-drawer-menu button {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    width: 100%;
    padding: 0.875rem var(--padding-small);
    background: transparent;
    border: none;
    font-family: var(--font-family);
    font-size: var(--font-size-medium);
    color: var(--bg-black);
    cursor: pointer;
    text-align: left;
    letter-spacing: var(--letter-spacing);
    transition: background var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

#app .profile-drawer-menu button:hover {
    background: var(--bg-grey);
}

#app .profile-drawer-menu button:active {
    background: var(--bg-grey);
}

#app .profile-drawer-menu button i {
    opacity: 0.5;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

#app .profile-drawer-spacer {
    flex: 1;
}

#app .profile-drawer-menu button#drawer-darkmode-btn {
    border-top: 1px solid var(--bg-grey);
}

#app .profile-drawer-lang {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0.5rem var(--padding-small);
    font-size: var(--font-size-small);
    color: var(--bg-black);
    opacity: 0.75;
}
#app .profile-drawer-lang .lang-label {
    margin-right: 2px;
    white-space: nowrap;
}
#app .profile-drawer-lang .lang-btn {
    background: transparent;
    border: 1px solid var(--bg-grey);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 11px;
    cursor: pointer;
    color: inherit;
    transition: all var(--transition-fast);
}
#app .profile-drawer-lang .lang-btn:hover {
    background: var(--bg-grey);
}
#app .profile-drawer-lang .lang-btn.active {
    background: var(--bg-black);
    color: var(--bg-white);
    border-color: var(--bg-black);
}

/* app footer */
#app footer {
    color: inherit;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: transparent;
    box-sizing: border-box;
    height: calc(var(--bar-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    overflow: hidden;
    overflow-x: auto;
}

#app footer > div {
    display: flex;
    flex: 1;
    justify-content: center;
    align-items: center;
    height: 100%;
    padding: 0 var(--padding-small);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

#app footer > div:not(.active) i {
    display: flex;
}

#app footer > div:not(.active):active i {
    transform: scale(var(--button-click-scale));
}

#app footer > div:not(.active) span {
    display: none;
}

#app footer > div.active i {
    display: none;
}

#app footer > div.active span {
    display: flex;
    font-weight: 700;
    color: var(--bg-white);
    padding: var(--padding-default) var(--padding-small);
    border-radius: var(--padding-medium);
    font-size: var(--font-size-default);
    background: var(--bg-black);
    animation: pillPop var(--transition-base) forwards;
    white-space: nowrap;    
}

#app main > div[data-module] {
    display: none;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    position: absolute;
    top: 0;
    left: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;    
}

#app main > div[data-module].active {
    display: flex;
    flex-direction: column;
}

/* Dashboard — a 2-column grid of live widgets. Monochrome like everything else: ink is the accent. */
.module-dashboard {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

/* header ⋮ dropdown — items come from the active module's menuActions() */
.head-menu {
    position: absolute;
    top: calc(var(--safe-top) + 52px);
    right: var(--padding-small);
    z-index: 900;
    background: var(--bg-sheet);
    border: 1px solid var(--bg-grey);
    border-radius: 12px;
    box-shadow: var(--box-shadow);
    padding: 4px;
    display: flex;
    flex-direction: column;
    min-width: 170px;
    animation: fadeSlideUp var(--transition-fast) forwards;
    /* Never taller than the viewport allows — long filter lists scroll inside the menu. */
    max-height: calc(100dvh - var(--safe-top) - 70px);
    overflow-y: auto;
    scrollbar-width: thin;
}
/* Non-interactive section divider (mirrors .mg-select-heading) — keeps a growing menu scannable. */
.head-menu-heading {
    font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
    color: var(--text-grey-soft); padding: 8px 12px 3px;
}
.head-menu-item {
    font-family: var(--font-family);
    letter-spacing: var(--letter-spacing);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--bg-black);
    background: transparent;
    border: 0;
    border-radius: 9px;
    padding: 10px 12px;
    text-align: left;
    cursor: pointer;
    transition: background var(--transition-fast), transform var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}
.head-menu-item:hover { background: var(--bg-track); }
.head-menu-item:active { transform: scale(var(--button-click-scale)); }
/* Select-menu look for filter entries: muted hint · label · trailing ✓ on active. */
.head-menu-item { display: flex; align-items: center; gap: 6px; }
.head-menu-item .menu-hint { color: var(--text-grey-soft); font-size: 11px; font-weight: 400; }
.head-menu-item .menu-label { flex: 1; text-align: left; }
.head-menu-item .menu-check { font-size: 10px; color: var(--text-grey); }
.head-menu-item.active { background: var(--bg-track); font-weight: 700; }

/* floating ✓ — leaves edit mode (changes save as they happen) */
.dash-done {
    position: absolute;
    right: 16px;
    bottom: 18px;
    z-index: 5;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 0;
    background: var(--bg-black);
    color: var(--bg-white);
    cursor: pointer;
    box-shadow: var(--box-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}
.dash-done:active { transform: scale(var(--button-click-scale)); }
.dash-done svg { width: 22px; height: 22px; }

/* Fresh-start screen — a brand-new group has no data, so no card is ON yet. The empty
   state is the grid's only child; .dash-start flex-centers it in the viewport. */
#app .dash-grid.dash-start {
    display: flex;
    align-items: center;
    justify-content: center;
}
#app .dash-empty {
    padding: 24px;
    text-align: center;
}
#app .dash-empty-title {
    font-weight: 700;
    margin-bottom: 8px;
}
#app .dash-empty-hint {
    opacity: 0.6;
    max-width: 420px;
    margin: 0 auto;
    line-height: 1.5;
}
#app .dash-empty-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 340px;
    margin: 24px auto 0;
}
#app .dash-empty-action {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: none;
    border-radius: 14px;
    background: var(--bg-track);
    color: inherit;
    font: inherit;
    cursor: pointer;
    text-align: left;
}
#app .dash-empty-action i {
    width: 20px;
    text-align: center;
    opacity: 0.75;
}
#app .dash-empty-action:active { transform: scale(var(--button-click-scale)); }

.dash-grid {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0;
    display: grid;
    /* The rule: full = 100%, half = a true stretched 50% — always two columns; under a narrow
       width every widget goes 100% (single column). Rows size to CONTENT (grid-auto-rows guards
       the row-collapse quirk that squashed every widget to its header). */
    grid-template-columns: 1fr;
    grid-auto-rows: min-content;
    gap: 0;
    align-content: start;
}
/* .fill is set by the dashboard AFTER layout, only when the content actually FITS the
   viewport: leftover space then distributes across the rows so widgets (and their dividers)
   reach the footer. Overflowing dashboards never get the class — scrolling stays intact
   (auto rows would let overflow-hidden widgets be squashed, so this cannot be CSS-only). */
.dash-grid.fill {
    grid-auto-rows: auto;
    align-content: stretch;
}
/* Natural column ladder: halves are one cell, full spans the row — wide screens get more
   columns instead of absurdly stretched widgets. */
@media (min-width: 480px)  { .dash-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1280px) { .dash-grid { grid-template-columns: repeat(4, 1fr); } }

.widget {
    /* Flat design: widgets are SECTIONS separated by hairlines, not cards. */
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    border-bottom: 1px solid var(--bg-grey);
}
/* A vertical hairline between two side-by-side half widgets — only where halves actually sit
   side by side (the two-column breakpoint); single-column phones stack, so no divider. */
@media (min-width: 480px) {
  .widget:not(.full) + .widget:not(.full) { border-left: 1px solid var(--bg-grey); }
}
/* The LAST VISUAL ROW is borderless: the last widget, and — when the grid ends on a
   side-by-side half pair — its left partner too (only at two-column widths: stacked
   single-column phones need the border between the last two). */
.dash-grid > .widget:last-child { border-bottom: 0; }
@media (min-width: 480px) {
  .dash-grid > .widget:not(.full):has(+ .widget:not(.full):last-child) { border-bottom: 0; }
}
@media (min-width: 1280px) {
  .dash-grid > .widget:not(.full):has(+ .widget:not(.full) + .widget:not(.full):last-child) { border-bottom: 0; }
  .dash-grid > .widget:not(.full):has(+ .widget:not(.full) + .widget:not(.full) + .widget:not(.full):last-child) { border-bottom: 0; }
}
.widget.full { grid-column: 1 / -1; }

/* widget header — the module's handle: tap opens the module, + quick-adds */
.w-head {
    display: flex;
    align-items: center;
    gap: 7px;
    /* A subtle band, FIXED height: heads align across widgets whether or not they carry a
       + disc (24px fits inside the 40px). */
    background: var(--bg-track);
    box-sizing: border-box;
    min-height: 40px;
    padding: 4px 12px;
    margin-bottom: 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.w-glyph {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    background: var(--bg-track);
    color: var(--text-grey);
    flex: none;
}
.w-title { font-size: 12px; font-weight: 700; letter-spacing: -0.01em; }
/* One badge style everywhere: ink on white — no grey/black split (.hot kept as a no-op class). */
.w-count {
    font-size: 9.5px;
    font-weight: 700;
    color: var(--bg-white);
    background: var(--bg-black);
    padding: 1px 6px;
    border-radius: 1rem;
    font-variant-numeric: tabular-nums;
}
.w-spacer { flex: 1; }
.w-add {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-grey-soft);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}
.w-add:hover { background: var(--bg-track); color: var(--bg-black); }
.w-add:active { transform: scale(var(--button-click-scale)); }
.w-add svg { width: 14px; height: 14px; }
/* The chevron is an AFFORDANCE, not a button: the whole head navigates; this just whispers
   "there's more behind this title" — kept small and quiet. */
.w-chev { color: var(--text-grey-soft); font-size: 11px; line-height: 1; opacity: 0.8; }

.w-body { padding: 0 12px 11px; display: flex; flex-direction: column; gap: 6px; }

/* live rows inside widgets — ticking sends the module's own write */
.w-row { display: flex; align-items: center; gap: 8px; font-size: 12px; line-height: 1.35; min-height: 20px; }
.w-check {
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
    cursor: pointer;
    flex: none;
    width: 16px;
    height: 16px;
    border-radius: 5px;
    border: 1.5px solid var(--text-grey-soft);
    background: transparent;
    position: relative;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}
.w-check:checked { background: var(--bg-black); border-color: var(--bg-black); }
.w-check:checked::after {
    content: "";
    position: absolute;
    left: 4.5px;
    top: 1.5px;
    width: 4px;
    height: 8px;
    border: solid var(--bg-white);
    border-width: 0 1.8px 1.8px 0;
    transform: rotate(43deg);
}
.w-row .txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-row .q { color: var(--text-grey); }
.w-more { font-size: 10px; color: var(--text-grey-soft); margin-top: 2px; }
/* Full-scope Für badges: one chip per person, side by side on the RIGHT of the row text
   (the flexed text pushes them there); when they'd collide with the text they wrap
   underneath as a right-aligned group. */
.w-row { flex-wrap: wrap; }
.w-detail { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; align-items: center; }
.w-row:has(.w-detail) .txt { min-width: 50%; }
.w-detail .notes-chip { white-space: nowrap; flex: none; }

w-pin { color: var(--bg-black); flex: none; font-size: 11px; }

/* weather widget */
/* Multiple weather locations swipe horizontally (one full-width snap page per place) */
.wx-pager { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.wx-pager::-webkit-scrollbar { display: none; }
.wx-page { flex: 0 0 100%; min-width: 0; scroll-snap-align: start; }
@media (min-width: 700px) {
  .wx-page { display: grid; grid-template-columns: auto 1fr; align-items: center; }
  .wx-page .wx-now   { grid-column: 1; grid-row: 1; }
  .wx-page .wx-days  { grid-column: 2; grid-row: 1; padding-bottom: 0; }
  .wx-page .wx-strip { grid-column: 1 / -1; grid-row: 2; }
}
.wx-now { display: flex; align-items: center; gap: 12px; padding: 2px 12px 10px; }
.wx-icon { font-size: 30px; line-height: 1; }
.wx-temp { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; }
.wx-desc { font-size: 11px; color: var(--text-grey); line-height: 1.5; }
.wx-hilo { font-size: 10px; color: var(--text-grey-soft); }
/* hourly strip: a full day from the starting hour, scrolled horizontally */
.wx-strip {
    display: flex;
    gap: var(--gap-chip);
    padding: 8px 12px 10px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.wx-strip::-webkit-scrollbar { display: none; }
.wx-hour {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    /* Grow to fill the card width when the chips fit; the 34px basis keeps the scroll on overflow. */
    flex: 1 0 34px;
    font-size: var(--font-size-chip);
    color: var(--text-grey);
    font-variant-numeric: tabular-nums;
}
.wx-hour .i { font-size: var(--font-size-chip-icon); }
.wx-hour .t { font-weight: 600; font-size: var(--font-size-chip-strong); color: var(--bg-black); }

/* EDIT MODE — drag & drop to reorder, resize toggle per widget */
.w-tools {
    position: absolute;
    top: 6px;
    right: 6px;
    display: none;
    gap: 2px;
    background: var(--bg-sheet);
    border: 1px solid var(--bg-grey);
    border-radius: 9px;
    box-shadow: var(--box-shadow);
    padding: 2px;
    z-index: 3;
}
.module-dashboard.editing .w-tools { display: flex; }
.w-tool {
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text-grey);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}
.w-tool:hover { background: var(--bg-track); color: var(--bg-black); }
.w-tool:active { transform: scale(var(--button-click-scale)); }
/* Active tool state — the setting is ON (hidden / full width / full info): filled ink. */
.w-tool.on, .w-tool.on:hover { background: var(--bg-black); color: var(--bg-white); }
.w-tool svg { width: 13px; height: 13px; }
.module-dashboard.editing .widget {
    outline: 1.5px dashed var(--text-grey-soft);
    outline-offset: 2px;
    touch-action: pan-y;  /* swipes scroll normally; a LONG-PRESS lifts the card (see _bindDrag) */
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}
.module-dashboard.editing .w-head,
.module-dashboard.editing .w-body,
.module-dashboard.editing .wx-now,
.module-dashboard.editing .wx-strip { pointer-events: none; opacity: .55; }
.module-dashboard.editing .w-tools { pointer-events: auto; }
.widget.drag-src {
    opacity: .85;
    transform: scale(.97);
    box-shadow: var(--shadow-lg, 0 12px 40px -12px rgba(0,0,0,.28));
    z-index: 4;
    cursor: grabbing;
}
/* deselected widget: absent from the normal view, ghosted in edit mode */
.module-dashboard.editing .widget.w-off { opacity: .45; outline-style: dotted; }

/* Calendar module — month grid + agenda, monochrome (ink accent). */
.module-calendar { display: flex; flex-direction: column; height: 100%; position: relative; }

.cal-head { display: flex; align-items: center; gap: 8px; padding: var(--padding-small) var(--padding-small) 6px; flex: none; }
.cal-nav {
    width: 38px; height: 38px; border: 0; background: var(--bg-track); color: var(--bg-black);
    border-radius: 1rem; font-size: 18px; line-height: 1; cursor: pointer; padding: 0;
    transition: transform var(--transition-fast); -webkit-tap-highlight-color: transparent;
}
.cal-nav:active { transform: scale(var(--button-click-scale)); }
.cal-title { flex: 1; font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.cal-today {
    font-family: var(--font-family); letter-spacing: var(--letter-spacing);
    font-size: 11px; font-weight: 600; color: var(--text-grey); background: var(--bg-track);
    border: 0; border-radius: 1rem; padding: 6px 12px; cursor: pointer;
    transition: transform var(--transition-fast);
}
.cal-today:active { transform: scale(var(--button-click-scale)); }

/* Calendar view switcher — segmented control, matches Notes' .seg-tabs */
.cal-views {
    display: flex; gap: 3px; background: var(--bg-track); padding: 3px;
    border-radius: 12px; margin: 0 var(--padding-small) 8px; flex: none;
    /* Same scroll behavior as .seg-tabs: with count badges the four buttons can outgrow
       narrow phones — the bar scrolls and the active button is centered into view. */
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.cal-views::-webkit-scrollbar { display: none; }
.cal-view-btn {
    flex: 1 0 auto; border: 0; background: transparent; cursor: pointer;
    font-family: var(--font-family); letter-spacing: var(--letter-spacing);
    font-size: 11.5px; font-weight: 600; color: var(--text-grey);
    padding: 7px 6px; border-radius: 9px;
    transition: background var(--transition-base), color var(--transition-base);
    -webkit-tap-highlight-color: transparent;
}
.cal-view-btn.active { background: var(--bg-black); color: var(--bg-white); box-shadow: var(--box-shadow); }

/* Subject filter — a scrollable row of monochrome pills (All · people · entities).
   Shared primitive (Module.buildSubjectFilter), reused by any module that tags subjects. */
.subject-filter {
    display: flex; gap: 6px; flex: none;
    padding: var(--padding-small) var(--padding-small) 0;
    overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.subject-filter::-webkit-scrollbar { display: none; }
.subject-chip {
    flex: none; border: 0; cursor: pointer; white-space: nowrap;
    background: var(--bg-track); color: var(--text-grey);
    font-family: var(--font-family); letter-spacing: var(--letter-spacing);
    font-size: 11.5px; font-weight: 600; padding: 6px 12px; border-radius: 1rem;
    transition: background var(--transition-base), color var(--transition-base), transform var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}
.subject-chip:active { transform: scale(var(--button-click-scale)); }
.subject-chip.active { background: var(--bg-black); color: var(--bg-white); }

/* Week / Day / Upcoming views — same scroll + padding shell as the month agenda */
.cal-week, .cal-day, .cal-upcoming {
    flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding: 6px var(--padding-small) 96px;
}
/* Dashboard grammar: days are flat SECTIONS separated by hairlines, headed by a 40px
   track band (full-bleed via negative margins; text aligns with the event rows below). */
.cal-week-day { border-bottom: 1px solid var(--bg-grey); }
.cal-week-day:last-child { border-bottom: 0; }
.cal-week-hd, .cal-agenda-label, .cal-up-day {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-track);
    box-sizing: border-box;
    min-height: 40px;
    margin: 0 calc(-1 * var(--padding-small)) 8px;
    padding: 4px calc(var(--padding-small) + 11px);
}
.cal-week-name { font-size: 12px; font-weight: 700; letter-spacing: -0.01em; color: var(--bg-black); }
.cal-week-date { font-size: 11px; font-weight: 600; color: var(--text-grey-soft); font-variant-numeric: tabular-nums; }
.cal-week-add {
    /* Same disc as the widget + (one add-button look everywhere). */
    margin-left: auto; flex: none; width: 24px; height: 24px; border-radius: 50%;
    border: 0; cursor: pointer;
    font-size: 12px; line-height: 1; display: grid; place-items: center;
    transition: transform var(--transition-fast); -webkit-tap-highlight-color: transparent;
}
.cal-week-add:active { transform: scale(var(--button-click-scale)); }
.cal-week-day.cal-todaycell .cal-week-name { text-decoration: underline; text-underline-offset: 3px; }

/* Upcoming — month separators above the banded day sections */
.cal-up-month {
    font-size: 14px; font-weight: 700; letter-spacing: -0.01em; color: var(--bg-black);
    margin: 20px 2px 8px;
}
.cal-up-month:first-child { margin-top: 4px; }
.cal-up-day { font-size: 12px; font-weight: 700; letter-spacing: -0.01em; color: var(--bg-black); }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; padding: 0 var(--padding-small); flex: none; }
.cal-wd { text-align: center; font-size: 9.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-grey-soft); padding: 4px 0; }
.cal-cell {
    position: relative; min-height: 44px; border: 0; background: transparent; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border-radius: 9px; padding: 4px 0; -webkit-tap-highlight-color: transparent;
}
.cal-num {
    font-size: 12px; font-weight: 500; color: var(--bg-black);
    width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: 50%;
    font-variant-numeric: tabular-nums;
}
.cal-other .cal-num { color: var(--text-grey-soft); }
.cal-todaycell .cal-num { box-shadow: inset 0 0 0 1.5px var(--text-grey-soft); }
.cal-selected .cal-num { background: var(--bg-black); color: var(--bg-white); box-shadow: none; }
/* Month-grid dots — monochrome-coded by category: solid ink = events/todos,
   ring = birthdays/anniversaries (entity dates), grey = public holidays. */
.cal-dots { display: flex; gap: 2px; height: 5px; align-items: center; }
.cal-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--bg-black); box-sizing: border-box; }
.cal-dot.ent { width: 5px; height: 5px; background: transparent; border: 1.2px solid var(--bg-black); }
.cal-dot.holiday { background: var(--text-grey-soft); }
.cal-other .cal-dot { background: var(--text-grey-soft); }
.cal-other .cal-dot.ent { background: transparent; border-color: var(--text-grey-soft); }

.cal-agenda { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 10px var(--padding-small) 96px; }
.cal-agenda-label { font-size: 12px; font-weight: 700; letter-spacing: -0.01em; color: var(--bg-black); }
/* Day-header forecast hint ("☀️ 31°/20°") — agenda label, week headers, upcoming day labels */
.cal-wx { margin-left: 8px; font-size: 11px; font-weight: 600; color: var(--text-grey-soft); text-transform: none; letter-spacing: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* The day forecast sits on the RIGHT in every day header (month agenda, week, Demnächst). */
.cal-week-hd .cal-wx { margin-left: auto; }
.cal-agenda-label, .cal-up-day { display: flex; align-items: center; }
.cal-agenda-label .cal-wx, .cal-up-day .cal-wx { margin-left: auto; }
.cal-wx + .cal-week-add { margin-left: 8px; } /* the forecast takes the auto-gap when present */
.cal-empty { color: var(--text-grey-soft); font-size: var(--font-size-default); text-align: center; margin-top: 1.5rem; }

/* One SECTION per day (dashboard grammar — no card frame): plain rows with hairline
   dividers, a little air before the next day's band. */
.cal-daylist { padding-bottom: 11px; }
.cal-event {
    display: flex; gap: 10px; align-items: center; padding: 10px 11px;
    border-bottom: 1px solid var(--bg-grey); cursor: pointer;
}
.cal-event:last-child { border-bottom: 0; }
.cal-event .cal-edit { flex: none; align-self: center; margin: -4px -4px -4px 0; }
.cal-event.cal-static { cursor: default; } /* nothing to open (holiday, someone else's birthday) */

/* Comfortable tap targets: the small icon buttons are simply BIGGER (their visual weight
   stays light — transparent background, small glyph). */
.icon-btn { width: 38px; height: 38px; }
.popup-close, .popup-back { padding: 8px 12px; }
.cal-time { font-size: 11px; font-weight: 700; color: var(--bg-black); width: 52px; flex: none; font-variant-numeric: tabular-nums; padding-top: 1px; }
.cal-time-end { display: block; }
/* The vertical connector between a timed event's start and end ("09:00 | 17:00" as a timeline). */
.cal-time-line { display: block; width: 2px; height: 8px; border-radius: 1px; background: var(--text-grey-soft); margin: 2px 0 2px 16px; }
.cal-event-body { min-width: 0; flex: 1; }
.cal-event-title { font-size: 13px; font-weight: 550; line-height: 1.35; word-break: break-word; }
.cal-event-meta { display: flex; flex-wrap: wrap; gap: 5px 8px; margin-top: 5px; }
.cal-meta-chip { font-size: 10px; color: var(--text-grey-soft); }
.cal-badge {
    font-size: 9px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
    color: var(--text-grey); background: var(--bg-track);
    padding: 2px 7px; border-radius: 999px;
}
.cal-widget-time { font-size: 11px; font-weight: 700; color: var(--bg-black); flex: none; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Gift nudge widget (dashboard): "Geburtstag: Anna · 3 Wünsche · nichts besorgt" */
.gift-when { font-size: 11px; font-weight: 700; color: var(--bg-black); flex: none; white-space: nowrap; font-variant-numeric: tabular-nums; }
.gift-status { color: var(--text-grey-soft); }

.cal-fab {
    position: absolute; right: 16px; bottom: 18px; z-index: 5; width: 52px; height: 52px;
    border-radius: 50%; border: 0; background: var(--bg-black); color: var(--bg-white);
    box-shadow: var(--box-shadow); display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: transform var(--transition-fast); -webkit-tap-highlight-color: transparent;
}
.cal-fab:active { transform: scale(var(--button-click-scale)); }
.cal-fab svg { width: 22px; height: 22px; }

/* editor sheet extras */
.cal-hidden { display: none !important; }
.cal-check-row { flex-direction: row; align-items: center; justify-content: space-between; }
.cal-check-row label { margin-bottom: 0; }
.popup-body input.cal-check {   /* beat the generic .popup-body input width:100% */
    width: 20px; height: 20px; flex: none; padding: 0; cursor: pointer;
    appearance: none; -webkit-appearance: none; border: 1.5px solid var(--text-grey-soft);
    border-radius: 6px; background: transparent; position: relative;
}
.popup-body input.cal-check:checked { background: var(--bg-black); border-color: var(--bg-black); }
.popup-body input.cal-check:checked::after {
    content: ""; position: absolute; left: 6px; top: 2.5px; width: 5px; height: 9px;
    border: solid var(--bg-white); border-width: 0 1.8px 1.8px 0; transform: rotate(43deg);
}

/* CSP-safe styles (no inline style= or element.style.*) */
.hidden-file-input {
    display: none;
}

.weather-hourly-note {
    font-size: 11px;
    color: var(--text-grey);
    padding: 6px 4px;
    background: var(--bg-track);
    border-radius: 4px;
    text-align: center;
}

/* Reusable UI components (filters, buttons, timers) - CSP safe, no inline styles.
   Monochrome: black is the accent (flips to white under #app.dark). */
.filter-bar.reusable {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin: 4px 0;
}
.filter-btn.reusable {
  font-family: var(--font-family);
  letter-spacing: var(--letter-spacing);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  background: var(--bg-track);
  color: var(--text-grey);
  border: 1px solid transparent;
  border-radius: 1rem;
  cursor: pointer;
  transition: background var(--transition-base), color var(--transition-base);
}
.filter-btn.reusable.active {
  background: var(--bg-black);
  color: var(--bg-white);
}
.action-btn.reusable {
  font-family: var(--font-family);
  letter-spacing: var(--letter-spacing);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  background: var(--bg-black);
  color: var(--bg-white);
  border: 1px solid var(--bg-black);
  border-radius: 1rem;
  cursor: pointer;
  margin: 2px;
  transition: transform var(--transition-fast), box-shadow var(--transition-base);
}
.action-btn.reusable:hover {
  box-shadow: var(--box-shadow);
}
.action-btn.reusable:active {
  transform: scale(var(--button-click-scale));
}
.action-btn.reusable.cancel-btn {
  background: transparent;
  color: var(--bg-black);
  border-color: var(--bg-grey);
}
/* Destructive action — always red, in every context (sheet or centered modal). */
.action-btn.reusable.delete-btn {
  background: transparent;
  color: #dc2626;
  border-color: transparent;
}
/* Semantic action colors on the mono UI: add = green, delete = red (above); edit stays the
   default mono grey. Filled add-buttons + FABs + the week-view day-add go green. */
#app .notes-fab, #app .cal-fab { background: #16a34a; }
/* The widget + is a small filled green disc (white glyph — reads in dark mode too). */
#app .w-add:not(.w-edit) {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #16a34a;
    color: #fff;
    font-size: 12px;
}
#app .w-add:not(.w-edit):hover { background: #15803d; color: #fff; }
@media (min-width: 900px) {
  #app .dash-grid .w-add:not(.w-edit) { position: absolute; right: 12px; bottom: 12px; z-index: 2; }
}
#app .w-add.w-edit { color: inherit; width: 24px; height: 24px; } /* the weather ✎: same footprint as the + disc, mono */
#app .cal-week-add { background: #16a34a; color: #fff; }
#app .ent-file-add,
#app .ent-add .action-btn,
#app .ent-rec-add .action-btn { background: #16a34a; border-color: #16a34a; }

/* Household member list (Render.openUsers) */
#app .user-row { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--bg-grey); }
#app .user-row:last-child { border-bottom: 0; }
#app .user-row > i { width: 18px; text-align: center; color: var(--text-grey); }
#app .user-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#app .user-row-role { font-size: 10px; font-weight: 600; padding: 2.5px 8px; border-radius: 1rem; background: var(--bg-track); color: var(--text-grey); }
#app .user-row-role.is-admin { background: #16a34a; color: #fff; }
#app .user-role-btn { flex-shrink: 0; }
#app .user-role-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.timer-display {
  font-family: monospace;
  font-size: 14px;
  background: #fff3cd;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #ffeaa7;
  display: inline-block;
  min-width: 80px;
  text-align: center;
}

/* Tiny offline changes layered indicator (CSP-safe class, no inline style) */
.offline-status {
  position: fixed;
  bottom: 2px;
  right: 4px;
  font-size: 9px;
  background: #fff3cd;
  padding: 1px 4px;
  border: 1px solid #f0c36b;
  opacity: 0.85;
  z-index: 999;
  border-radius: 2px;
}

/* Weather pager dots — which location page is active, and that there ARE more pages. */
.wx-dots { display: flex; justify-content: center; gap: 5px; padding: 6px 0 8px; }
.wx-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--bg-grey); transition: background var(--transition-fast); }
.wx-dot.active { background: var(--bg-black); }

/* Full-scope weather: the coming days as ONE swipeable line (mirrors the hourly strip) —
   each chip is weekday / icon / max° / min°. */
.wx-days {
  display: flex;
  gap: var(--gap-chip);
  padding: 0 12px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.wx-days::-webkit-scrollbar { display: none; }
/* Swipe affordance: a soft shadow at an edge means "more content that way". The cover
   gradients scroll WITH the content (local) and hide the shadow at the row's ends. */
.wx-strip, .wx-days {
  background:
    linear-gradient(to right, var(--bg-white) 40%, transparent) left / 28px 100%,
    linear-gradient(to left,  var(--bg-white) 40%, transparent) right / 28px 100%,
    radial-gradient(farthest-side at 0 50%, var(--scroll-shadow), transparent) left / 10px 100%,
    radial-gradient(farthest-side at 100% 50%, var(--scroll-shadow), transparent) right / 10px 100%;
  background-repeat: no-repeat;
  background-attachment: local, local, scroll, scroll;
}
/* Day chips share the hourly strip's chip scale exactly. */
.wx-day {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  flex: 1 0 40px; /* fill the card width; still scrolls when it overflows on narrow screens */
  font-size: var(--font-size-chip);
  color: var(--text-grey);
  font-variant-numeric: tabular-nums;
}
.wx-day-name { font-weight: 600; }
.wx-day-icon { font-size: var(--font-size-chip-icon); }
.wx-day-temps { display: flex; align-items: baseline; gap: 4px; }
.wx-day-max { font-weight: 600; font-size: var(--font-size-chip-strong); color: var(--bg-black); }
.wx-day-min { color: var(--text-grey-soft); }

/* In stretched rows the body fills the card so bottom-pinned actions actually reach the bottom. */
.dash-grid .widget > .w-body { flex: 1; }
.dash-grid .widget > .wx-pager { flex: 1; }

/* Progress pill while attachments download into the offline cache (app._precachePill). */
.precache-status {
  position: fixed;
  bottom: calc(var(--safe-bottom, 0px) + 64px);
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--bg-white);
  background: var(--bg-black);
  padding: 7px 13px;
  border-radius: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  z-index: 1000;
  white-space: nowrap;
}

/* Toast shown when a write exhausted its retries (dead-lettered). */
.write-error-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  color: #fff;
  background: #dc2626;
  padding: 8px 14px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  z-index: 1000;
}

/* General reusable Popup / Modal (CSP-safe, no inline styles) */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.popup-modal {
  background: #fff;
  border-radius: 8px;
  width: 90%;
  max-width: 420px;
  max-height: 80vh;
  overflow: auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
}
.popup-header {
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 14px;
}
.popup-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.popup-body {
  padding: 16px;
  flex: 1;
  overflow: auto;
}
.popup-footer {
  padding: 12px 16px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.popup-body .form-row {
  margin-bottom: 10px;
}
.popup-body label {
  display: block;
  font-size: 11px;
  margin-bottom: 2px;
  color: #555;
}
.popup-body input,
.popup-body select,
.popup-body textarea {
  width: 100%;
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
}

/* Popup — monochrome + theme-aware overrides. The overlay is appended inside #app (see
   Module.openFormPopup), so the #app.dark token flips reach it. */
.popup-modal {
  background: var(--bg-sheet);
  color: var(--bg-black);
}
.popup-header { border-bottom-color: var(--bg-grey); }
.popup-footer { border-top-color: var(--bg-grey); }
.popup-close { color: var(--text-grey); }
.popup-body label {
  color: var(--text-grey-soft);
  font-weight: 700;
  font-size: 9.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.popup-body input,
.popup-body select,
.popup-body textarea {
  font-family: var(--font-family);
  letter-spacing: var(--letter-spacing);
  background: transparent;
  color: var(--bg-black);
  border: 1px solid var(--bg-grey);
  border-radius: 8px;
  padding: 10px 11px;
}
.popup-body input:focus,
.popup-body select:focus,
.popup-body textarea:focus {
  outline: none;
  border-color: var(--bg-black);
}
.popup-body textarea { resize: none; min-height: 60px; line-height: 1.45; }
.popup-body .form-row { margin-bottom: 12px; }

/* Bottom-sheet variant (openFormPopup({ variant: 'sheet' })) */
.popup-overlay.sheet { align-items: flex-end; }
.popup-modal.sheet {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  border-radius: 18px 18px 0 0;
  animation: fadeSlideUp var(--transition-base) forwards;
}
.popup-modal.sheet::before {
  content: "";
  display: block;
  width: 36px;
  height: 4px;
  border-radius: 4px;
  background: var(--bg-grey);
  margin: 10px auto 0;
}
.popup-modal.sheet .popup-header {
  border-bottom: 0;
  font-size: 16px;
  padding: 8px 16px 4px;
}
.popup-modal.sheet .popup-body { padding: 8px 16px 4px; }
.popup-modal.sheet .popup-footer {
  border-top: 0;
  padding: 12px 16px calc(14px + var(--safe-bottom));
}
.popup-modal.sheet .popup-footer .action-btn {
  flex: 1;
  padding: 12px;
  font-size: 13px;
  border-radius: 10px;
  margin: 0;
}
.popup-modal.sheet .popup-footer .action-btn.delete-btn {
  flex: 0 0 auto;
  margin-right: auto;
  background: transparent;
  border-color: transparent;
  color: #dc2626;
  padding: 12px 6px;
}

/* Segmented visibility toggle (Everyone / Only me) */
.seg-toggle {
  display: flex;
  gap: 3px;
  background: var(--bg-track);
  padding: 3px;
  border-radius: 10px;
}
.seg-toggle button {
  flex: 1;
  border: 0;
  background: transparent;
  font-family: var(--font-family);
  letter-spacing: var(--letter-spacing);
  cursor: pointer;
  color: var(--text-grey);
  font-size: 12px;
  font-weight: 600;
  padding: 9px 4px;
  border-radius: 8px;
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-base), color var(--transition-base);
}
.seg-toggle button svg { width: 13px; height: 13px; }
.seg-toggle button.active {
  background: var(--bg-black);
  color: var(--bg-white);
  box-shadow: var(--box-shadow);
}
.seg-toggle button:disabled { opacity: .55; cursor: default; }
.seg-hint {
  color: var(--text-grey-soft);
  font-size: 10.5px;
  margin: 7px 2px 0;
}

/* Notes module — monochrome design: segmented tabs, item cards, ink FAB, authorship by-lines.
   Zero chroma: state is weight, fill and strikethrough. */
.module-notes {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}

/* segmented tabs — active is solid ink (mirrors the footer's active pill).
   The bar scrolls horizontally once more kinds exist than fit (scrollbar hidden;
   the module keeps the active tab in view). */
.seg-tabs {
  display: flex;
  gap: 3px;
  background: var(--bg-track);
  padding: 3px;
  border-radius: 12px;
  margin: var(--padding-small) var(--padding-small) 0;
  flex: none;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.seg-tabs::-webkit-scrollbar { display: none; }
.seg-tab {
  flex: 1 0 auto; /* grow to fill while few, keep natural width (→ overflow) when many */
  border: 0;
  background: transparent;
  font-family: var(--font-family);
  letter-spacing: var(--letter-spacing);
  cursor: pointer;
  color: var(--text-grey);
  font-size: 11.5px;
  font-weight: 600;
  padding: 8px 12px; /* real horizontal padding: tabs keep a tappable natural width when the bar scrolls */
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background var(--transition-base), color var(--transition-base);
  -webkit-tap-highlight-color: transparent;
}
.seg-tab .seg-count {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-grey-soft);
  background: var(--bg-track);
  padding: 1px 6px;
  border-radius: 1rem;
  font-variant-numeric: tabular-nums;
  transition: background var(--transition-base), color var(--transition-base);
}
.seg-tab.active {
  background: var(--bg-black);
  color: var(--bg-white);
  box-shadow: var(--box-shadow);
}
.seg-tab.active .seg-count {
  background: var(--on-ink-soft);
  color: var(--bg-white);
}

/* Generic swipeable tab layer (calendar views, baby card tabs) — the same mechanics as
   .notes-layer below: 1:1 finger follow via --tab-drag (CSSOM, CSP-safe), spring-back,
   directional slide-in; pan-y keeps vertical scrolling native AND stops any horizontal
   ancestor scroller (the baby pager) from grabbing gestures that start here. */
.tab-layer {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  touch-action: pan-y;
  transform: translateX(var(--tab-drag, 0px));
  transition: transform var(--transition-base);
}
.tab-layer.dragging { transition: none; }
.tab-layer.slide-from-right { animation: notesSlideFromRight var(--transition-base); }
.tab-layer.slide-from-left  { animation: notesSlideFromLeft  var(--transition-base); }
@media (prefers-reduced-motion: reduce) {
  .tab-layer.slide-from-right, .tab-layer.slide-from-left { animation: none; }
  .tab-layer { transition: none; }
}
/* The calendar's view switcher reuses the seg-count badge look. */
.cal-view-btn .seg-count {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-grey-soft);
  background: var(--bg-track);
  padding: 1px 6px;
  border-radius: 1rem;
  font-variant-numeric: tabular-nums;
  margin-left: 6px;
  transition: background var(--transition-base), color var(--transition-base);
}
.cal-view-btn.active .seg-count {
  background: var(--on-ink-soft);
  color: var(--bg-white);
}

/* scrolling layer.
   Swipe feedback: while dragging horizontally the layer follows the finger via
   --notes-drag (set through CSSOM from the module — CSP-safe), X/Twitter-style,
   so you see how far you've swiped. Releasing below the threshold springs back
   (the transition below); `touch-action: pan-y` keeps vertical scrolling native. */
.notes-layer {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 4px var(--padding-small) 96px;
  display: flex;
  flex-direction: column;
  transform: translateX(var(--notes-drag, 0px));
  transition: transform var(--transition-base);
}
.notes-layer.dragging { transition: none; } /* 1:1 finger follow while dragging */
/* directional slide when switching type layers (tap or swipe commit) */
@keyframes notesSlideFromRight { from { opacity: .5; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes notesSlideFromLeft  { from { opacity: .5; transform: translateX(-20px); } to { opacity: 1; transform: none; } }
.notes-layer.slide-from-right { animation: notesSlideFromRight var(--transition-base); }
.notes-layer.slide-from-left  { animation: notesSlideFromLeft  var(--transition-base); }
@media (prefers-reduced-motion: reduce) {
  .notes-layer.slide-from-right, .notes-layer.slide-from-left { animation: none; }
  .notes-layer { transition: none; }
}
/* List-group headers as 40px track bands (dashboard grammar), full-bleed like the
   calendar's day bands. */
.notes-group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-track);
  box-sizing: border-box;
  min-height: 40px;
  margin: 8px calc(-1 * var(--padding-small)) 0;
  padding: 4px calc(var(--padding-small) + 2px);
  color: var(--bg-black);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.notes-group-label:first-child { margin-top: 0; }
.notes-empty {
  color: var(--text-grey-soft);
  font-size: var(--font-size-default);
  text-align: center;
  margin-top: 2rem;
}

/* item row — dashboard grammar: flat hairline rows, no card frame */
.notes-item {
  padding: 11px 2px 10px;
  border-bottom: 1px solid var(--bg-grey);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  position: relative;
}
.notes-item:last-child { border-bottom: 0; }
.notes-item.pinned::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 11px;
  bottom: 11px;
  width: 2px;
  background: var(--bg-black);
  border-radius: 0 2px 2px 0;
}

/* leading control: custom checkbox / kind glyph */
.notes-lead { padding-top: 1px; }
.notes-check {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  cursor: pointer;
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--text-grey-soft);
  background: transparent;
  position: relative;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.notes-check:hover { border-color: var(--bg-black); }
.notes-check:checked { background: var(--bg-black); border-color: var(--bg-black); }
.notes-check:checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2.5px;
  width: 5px;
  height: 9px;
  border: solid var(--bg-white);
  border-width: 0 2px 2px 0;
  transform: rotate(43deg);
}
.notes-glyph {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  background: var(--bg-track);
  color: var(--text-grey);
  flex: none;
}

/* body: title + meta */
.notes-body { min-width: 0; }
.notes-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: var(--letter-spacing);
  word-break: break-word;
}
.notes-q { color: var(--text-grey); font-weight: 400; }
/* Overdue signal (due date passed / chore turn missed) — the app's destructive red, bold. */
#app .notes-overdue { color: #dc2626; font-weight: 700; }
/* Due-today signal — the same bold line, neutral ink. */
#app .notes-duetoday { color: var(--bg-black); font-weight: 700; }
.notes-item.done .notes-title { color: var(--text-grey-soft); text-decoration: line-through; }
.notes-meta {
  display: flex;
  align-items: center;
  gap: 6px 8px;
  flex-wrap: wrap;
  margin-top: 7px;
}
.notes-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 2.5px 8px;
  border-radius: 1rem;
  background: var(--bg-track);
  color: var(--text-grey);
}
.notes-chip svg { width: 10px; height: 10px; }
/* A linked-entity chip: a tappable body (hop to the person/thing) + an × to remove the link. */
.notes-linkchip { padding: 0; }
.notes-linkgo {
  border: 0; background: transparent; cursor: pointer; color: inherit;
  font: inherit; letter-spacing: inherit;
  display: inline-flex; align-items: center; gap: 4px; padding: 2.5px 2px 2.5px 8px;
}
.notes-linkx {
  border: 0; background: transparent; cursor: pointer; color: inherit;
  display: inline-flex; align-items: center; padding: 2.5px 7px 2.5px 3px;
}
.notes-linkx:hover, .notes-linkx:active { color: #dc2626; }
.notes-by { font-size: 10px; color: var(--text-grey-soft); }
.notes-by b { font-weight: 600; color: var(--text-grey); }

/* trailing icon actions */
.notes-acts { display: flex; gap: 1px; align-self: center; }
.icon-btn {
  width: 29px;
  height: 29px;
  border: 0;
  background: transparent;
  color: var(--text-grey-soft);
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--bg-track); color: var(--bg-black); }
.icon-btn:active { transform: scale(var(--button-click-scale)); }
.icon-btn.star.on { color: var(--bg-black); }
.icon-btn svg { width: 15px; height: 15px; }

/* FAB — solid ink */
.notes-fab {
  position: absolute;
  right: 16px;
  bottom: 18px;
  z-index: 5;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 0;
  background: var(--bg-black);
  color: var(--bg-white);
  cursor: pointer;
  box-shadow: var(--box-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}
.notes-fab:active { transform: scale(var(--button-click-scale)); }
.notes-fab svg { width: 22px; height: 22px; }

/* (the Notes dashboard cards use the shared .widget / .w-* styles above) */

/* Entity manager (People & things) + per-entity attribute editor, and the profile drawer's
   "your birthday" row. Monochrome, matches the popup form system. */
#app .ent-tabs { margin: 2px 0 10px; }
#app .ent-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--bg-grey);
}
#app .ent-row:last-of-type { border-bottom: none; }
#app .ent-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
#app .ent-sub {
  font-size: 10.5px;
  color: var(--text-grey-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 1px;
}
/* edit / delete use the shared .icon-btn (borderless, hover fill); just size the × glyph a touch bigger */
#app .ent-edit,
#app .ent-del { flex-shrink: 0; }
#app .ent-del { font-size: 20px; }

/* the expand-in-place attribute form under a row */
#app .ent-attrs {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  margin: 2px 0 10px;
  background: var(--bg-track);
  border-radius: 10px;
}
#app .ent-attr-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#app .ent-attr-row span {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-grey-soft);
}
#app .ent-attrs .action-btn { align-self: flex-end; }

/* Settings: email verification state + partner invite link */
#app .settings-email { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#app .settings-email-addr { font-size: 13px; overflow-wrap: anywhere; }
#app .settings-email-state { font-size: 11px; font-weight: 600; color: var(--text-grey); }
#app .settings-invite { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
#app .settings-invite-create { display: flex; gap: 8px; width: 100%; }
#app #settings-invite-email { flex: 1; min-width: 0; }
#app #settings-invite-result { display: flex; gap: 8px; width: 100%; }
#app #settings-invite-link { flex: 1; min-width: 0; font-size: 12px; }
#app #settings-invite-msg { font-size: 11px; color: var(--text-grey); }

/* attachments inside the attribute form: head label, file rows, add button */
#app .ent-files { display: flex; flex-direction: column; gap: 6px; }
#app .ent-files-head {
  font-size: 9.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-grey-soft);
}
#app .ent-files-head i { margin-right: 4px; }
#app .ent-file-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
#app .ent-file-name {
  background: none; border: 0; padding: 0; cursor: pointer; text-align: left;
  color: var(--bg-black); font-size: 13px; text-decoration: underline;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1;
}
#app .ent-file-size { font-size: 11px; color: var(--text-grey); white-space: nowrap; }
#app .ent-file-del { font-size: 16px; }
#app .ent-file-ren { font-size: 12px; }
#app .ent-file-rename { flex: 1; min-width: 0; font-size: inherit; }
#app .ent-files .ent-file-add { align-self: flex-start; }
#app .ent-files-status { font-size: 11px; color: var(--text-grey); min-height: 0; }
/* Related-entity / linked-note chips (the entity "hub") */
#app .ent-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
#app .ent-link-chip {
  display: inline-flex; align-items: center;
  background: var(--bg-grey); border-radius: 1rem;
  font-size: var(--font-size-small, 0.8rem);
}
#app .ent-link-go {
  display: inline-flex; align-items: center; gap: 5px;
  background: transparent; border: 0; color: inherit; cursor: pointer;
  font: inherit; padding: 4px 4px 4px 10px;
}
#app .ent-link-x {
  display: inline-flex; align-items: center;
  background: transparent; border: 0; cursor: pointer;
  color: var(--text-grey); padding: 4px 8px 4px 4px;
}
#app .ent-link-x:hover, #app .ent-link-x:active { color: #dc2626; }

/* person-bound records (notes + medications) in the entity editor */
#app .ent-records { display: flex; flex-direction: column; gap: 6px; }
#app .ent-rec-list { display: flex; flex-direction: column; gap: 4px; }
#app .ent-rec-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
#app .ent-rec-txt { flex: 1; min-width: 0; font-size: 13px; color: var(--bg-black); overflow-wrap: anywhere; }
#app .ent-rec-off .ent-rec-txt { color: var(--text-grey-soft); text-decoration: line-through; }
#app .ent-rec-del { font-size: 15px; }
#app .ent-rec-add { display: flex; gap: 6px; }
#app .ent-rec-add input { flex: 1; min-width: 0; }
#app .ent-rec-edit { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; text-decoration: underline; }
#app .ent-medform {
  display: flex; flex-direction: column; gap: 8px; padding: 10px;
  margin: 4px 0; background: var(--bg-track); border-radius: 10px;
}
#app .ent-medform-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* the "add entity" row: type + name + button on one line */
#app .ent-add {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--bg-grey);
}
#app .popup-body .ent-add input { flex: 1; width: auto; min-width: 0; }
#app .ent-add .action-btn { flex-shrink: 0; }
#app .ent-empty {
  color: var(--text-grey-soft);
  font-size: var(--font-size-default);
  padding: 12px 0;
  text-align: center;
}

/* Unified Settings sheet — You | Group tabs (avatar, birthday, language + household settings) */
#app .settings-tabs { margin: 2px 16px 10px; }
#app .settings-panel { display: flex; flex-direction: column; }
#app .settings-panel[hidden] { display: none; } /* beat .settings-panel's display:flex so the inactive tab hides */
#app .settings-avatar { display: flex; align-items: center; gap: 12px; }
#app .settings-avatar-preview {
  width: 52px; height: 52px; flex: none; border-radius: 50%; overflow: hidden;
  background: var(--bg-track); display: grid; place-items: center;
  font-size: 30px; color: var(--text-grey-soft);
}
#app .settings-avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
#app .settings-avatar-actions { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
#app .settings-avatar-actions .action-btn { width: 100%; }
#app .settings-lang { display: flex; gap: 6px; }
#app .settings-lang .lang-btn {
  background: transparent; border: 1px solid var(--bg-grey); border-radius: 8px;
  padding: 8px 16px; font-size: 12px; cursor: pointer; color: var(--bg-black);
  font-family: var(--font-family); letter-spacing: var(--letter-spacing);
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
#app .settings-lang .lang-btn:hover { background: var(--bg-grey); }
#app .settings-lang .lang-btn.active { background: var(--bg-black); color: var(--bg-white); border-color: var(--bg-black); }

/* Weather places (Settings → Group): followed-location chips + geocoding search */
#app .settings-weather { display: flex; flex-direction: column; gap: 8px; }
#app #weather-current { display: flex; flex-wrap: wrap; gap: 6px; }
#app .weather-none { font-size: 12px; color: var(--text-grey-soft); }
#app .weather-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg-track); border-radius: 999px; padding: 5px 6px 5px 12px;
  font-size: 12px; color: var(--bg-black);
}
#app .weather-chip-x {
  border: 0; background: transparent; color: var(--text-grey); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 0 5px; border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
}
#app .weather-chip-x:hover { color: var(--bg-black); }
#app .weather-search-row { display: flex; gap: 8px; }
#app .popup-body .weather-search-row input { flex: 1; width: auto; min-width: 0; }
#app .weather-search-row .action-btn { flex: none; }
#app #weather-results { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--text-grey-soft); }
#app .weather-result {
  text-align: left; border: 0; background: transparent; cursor: pointer;
  padding: 9px 10px; border-radius: 8px; font-family: var(--font-family);
  font-size: 13px; color: var(--bg-black); letter-spacing: var(--letter-spacing);
  transition: background var(--transition-fast); -webkit-tap-highlight-color: transparent;
}
#app .weather-result:hover { background: var(--bg-track); }

/* Tier usage ("82 / 100") — label + count on one line, a thin ink-on-track bar below */
#app .settings-usage { display: flex; flex-direction: column; gap: 10px; }
#app .usage-row { display: grid; grid-template-columns: 1fr auto; row-gap: 4px; align-items: baseline; }
#app .usage-label { font-size: 12px; color: var(--bg-black); }
#app .usage-count { font-size: 11px; font-weight: 600; color: var(--text-grey); font-variant-numeric: tabular-nums; }
#app .usage-track { grid-column: 1 / -1; height: 4px; border-radius: 999px; background: var(--bg-track); overflow: hidden; }
#app .usage-fill { display: block; height: 100%; border-radius: 999px; background: var(--bg-black); transition: width var(--transition-base); }

/* Header back arrow (popups opened from another sheet, e.g. People & things from Settings) */
.popup-back { background: none; border: 0; color: var(--text-grey); font-size: 22px; line-height: 1; cursor: pointer; padding: 0 6px 0 0; -webkit-tap-highlight-color: transparent; }

/* Custom monochrome <select> replacement — the menu is portaled to #app (fixed-positioned). */
.mg-select { position: relative; }
.mg-select-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: transparent; border: 1px solid var(--bg-grey); border-radius: 8px;
  padding: 10px 11px; cursor: pointer; text-align: left;
  font-family: var(--font-family); letter-spacing: var(--letter-spacing); font-size: 13px; color: var(--bg-black);
  transition: border-color var(--transition-fast); -webkit-tap-highlight-color: transparent;
}
.mg-select.open .mg-select-btn { border-color: var(--bg-black); }
.mg-select-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-select-chev { flex: none; color: var(--text-grey-soft); font-size: 11px; transition: transform var(--transition-fast); }
.mg-select.open .mg-select-chev { transform: rotate(180deg); }
.mg-select-menu {
  position: fixed; z-index: 1000;
  background: var(--bg-sheet); border: 1px solid var(--bg-grey); border-radius: 10px;
  box-shadow: var(--box-shadow); padding: 4px; overflow-y: auto; scrollbar-width: thin;
}
.mg-select-opt {
  width: 100%; text-align: left; background: transparent; border: 0; border-radius: 7px;
  padding: 9px 10px; cursor: pointer;
  font-family: var(--font-family); letter-spacing: var(--letter-spacing); font-size: 13px; color: var(--bg-black);
  transition: background var(--transition-fast); -webkit-tap-highlight-color: transparent;
}
/* Muted side info before an option's label (entity type / note kind in the link pickers). */
.mg-select-hint { color: var(--text-grey-soft); font-size: 11px; margin-right: 6px; }
.mg-select-opt:hover { background: var(--bg-track); }
.mg-select-heading {
  font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-grey-soft); padding: 8px 10px 3px;
}

/* Baby module — a full-height pager: each baby is ONE full card between header and the
   swipe dots above the footer; the card scrolls vertically on its own. */
#app .baby-wrap { position: relative; height: 100%; display: flex; flex-direction: column; }
#app .baby-today, #app .baby-growth { display: flex; flex-direction: column; gap: 14px; }

/* One full-width snap page per baby — the same pager mechanics as the weather widget. */
#app .baby-pager {
  flex: 1; min-height: 0;
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
#app .baby-pager::-webkit-scrollbar { display: none; }
#app .baby-page {
  flex: 0 0 100%; min-width: 0; scroll-snap-align: start;
  box-sizing: border-box; padding: 12px 12px 84px;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 14px;
}

/* Swipe indicator — directly above the footer, always visible. */
#app .baby-dots { flex: none; display: flex; justify-content: center; gap: 5px; padding: 8px 0 10px; }

/* The module's one + (green disc like Notes/Calendar), floating above the dots. */
#app .baby-fab {
  position: absolute; right: 16px; bottom: 44px; z-index: 5; width: 52px; height: 52px;
  border-radius: 50%; border: 0; background: #16a34a; color: #fff; font-size: 20px;
  box-shadow: var(--box-shadow); display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform var(--transition-fast); -webkit-tap-highlight-color: transparent;
}
#app .baby-fab:active { transform: scale(var(--button-click-scale)); }

/* The card's hero: avatar/glyph + prominent name/age, today's counts on the right. */
#app .baby-hero { display: flex; align-items: center; gap: 12px; padding: 2px 2px 0; flex-wrap: wrap; }
#app .baby-hero-glyph {
  width: 56px; height: 56px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 24px;
  background: var(--bg-track); color: var(--text-grey);
  overflow: hidden;
}
#app .baby-hero-glyph img { width: 100%; height: 100%; object-fit: cover; }
#app .baby-hero-name { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; color: var(--bg-black); line-height: 1.2; }
#app .baby-hero-age { font-size: 12.5px; color: var(--text-grey); }
#app .baby-hero-counts {
  margin-left: auto; white-space: nowrap; align-self: center;
  font-size: 12.5px; color: var(--text-grey); font-variant-numeric: tabular-nums;
}
#app .baby-hero-counts i { color: var(--text-grey-soft); font-size: 11px; }
/* The tab bar sits exactly like the calendar's view switcher: padding-small from the screen
   edge (the page's own 12px padding is netted out), rounded. */
#app .baby-tabs { flex: none; margin: 0 calc(var(--padding-small) - 12px); }
#app .baby-editable { cursor: pointer; -webkit-tap-highlight-color: transparent; }
/* The uniform edit button in baby rows — same .icon-btn pen as calendar/notes rows; the
   negative margins keep compact rows from growing around its 38px tap target. */
#app .baby-ev-edit { margin: -8px -8px -8px auto; flex: none; align-self: center; color: var(--text-grey-soft); }
/* Two-line row body (title + meta) — the shared anatomy for vaccine and med rows. */
#app .baby-ev-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
#app .baby-ev-meta { font-size: 11px; color: var(--text-grey); }
/* State lines win over the muted meta (same red/bold as the notes rows). */
#app .baby-ev-meta.notes-overdue { color: #dc2626; font-weight: 700; }
#app .baby-ev-meta.notes-duetoday { color: var(--bg-black); font-weight: 700; }
#app .baby-vx-ic-done { color: #16a34a; }
#app .baby-vx-ic-overdue { color: #dc2626; }
#app .baby-rec-row.baby-editable { display: flex; align-items: center; gap: 8px; }
#app .baby-rec-text { flex: 1; min-width: 0; }

/* The avatar's edit pencil — a small ink disc pinned to the photo's corner. */
#app .baby-hero-avatar { position: relative; flex: none; }
#app .baby-avatar-edit {
  position: absolute; right: -4px; bottom: -4px; width: 22px; height: 22px;
  border-radius: 50%; border: 0; background: var(--bg-black); color: var(--bg-white);
  font-size: 10px; display: grid; place-items: center; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* The vaccination tab container (rows use the shared .baby-ev anatomy). */
#app .baby-guide { display: flex; flex-direction: column; }
#app .baby-hero-age i { font-size: 11px; color: var(--text-grey-soft); }
/* Today at a glance: three soft stat blocks under the name (value vs typical). */
#app .baby-hero-wrap { display: flex; flex-direction: column; gap: 10px; }
#app .baby-stats { display: flex; gap: 8px; }
#app .baby-stat {
  flex: 1; min-width: 0; background: var(--bg-track); border-radius: 14px; padding: 10px 8px;
  display: flex; flex-direction: column; gap: 2px; align-items: center; text-align: center;
}
#app .baby-stat-val { font-size: 16px; font-weight: 800; color: var(--bg-black); letter-spacing: -0.01em; white-space: nowrap; }
#app .baby-stat-val i { font-size: 12px; color: var(--text-grey); margin-right: 4px; }
#app .baby-stat-sub { font-size: 10.5px; color: var(--text-grey); white-space: nowrap; }

/* Entity list rows are read-only (editing happens in the stacked editor sheet). */
.ent-name-ro { font-size: 14px; font-weight: 600; color: var(--bg-black); word-break: break-word; }

/* Attachment category headings + the per-file category picker (compact select). */
.ent-file-cat {
  font-size: 9.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-grey-soft); margin: 8px 2px 2px;
}
.ent-file-catsel { flex: none; max-width: 130px; }
.ent-file-catsel .mg-select-btn { padding: 3px 8px; font-size: 11px; }

/* status card — the module's one soft "hero" surface (friendly: generous radius + padding) */
#app .baby-status {
  background: var(--bg-track); border-radius: 18px; padding: 16px;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
}
#app .baby-status-main { font-size: 17px; font-weight: 700; color: var(--bg-black); }
#app .baby-status-main i { margin-right: 6px; }
#app .baby-status-sub { font-size: 14px; color: var(--text-grey); }
#app .baby-status-warn { color: var(--bg-black); font-weight: 700; }
#app .baby-disclaimer { font-size: 10px; color: var(--text-grey-soft); }
#app .baby-stop { align-self: stretch; }

/* quick-add grid */
#app .baby-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
#app .baby-action {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--bg-track); border: 0; border-radius: 14px; padding: 12px 4px;
  color: var(--bg-black); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
#app .baby-action i { font-size: 20px; }
#app .baby-action span { font-size: 10.5px; text-align: center; line-height: 1.15; }
#app .baby-action:active { transform: scale(0.96); }

/* timeline + event rows — flat hairline rows (dashboard grammar) with soft round type chips */
#app .baby-timeline, #app .baby-growth { }
#app .baby-ev {
  display: flex; align-items: center; gap: 10px; padding: 8px 2px;
  border-bottom: 1px solid var(--bg-grey);
}
#app .baby-ev:last-child { border-bottom: 0; }
#app .baby-ev-icon {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--bg-track); color: var(--text-grey); font-size: 12px;
}
/* The universal date+time column: full date on top, time (or window unit) muted beneath. */
#app .baby-ev-time {
  display: flex; flex-direction: column; line-height: 1.25;
  font-size: 12px; color: var(--text-grey); font-variant-numeric: tabular-nums;
  min-width: 68px; flex: none;
}
#app .baby-ev-time2 { font-size: 10.5px; color: var(--text-grey-soft); }
#app .baby-ev-desc { flex: 1; min-width: 0; font-size: 13px; color: var(--bg-black); }
#app .baby-ev-del { color: var(--text-grey-soft); }
/* Section heads as 40px track bands (dashboard grammar), full-bleed within the 12px page. */
#app .baby-rec-h {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-track); box-sizing: border-box; min-height: 40px;
  margin: 0 -12px; padding: 4px 14px;
  font-size: 12px; font-weight: 700; letter-spacing: -0.01em; text-transform: none;
  color: var(--bg-black);
}
#app .baby-empty, #app .baby-empty-line { color: var(--text-grey); }
#app .baby-empty { display: flex; flex-direction: column; gap: 10px; padding: 24px 16px; align-items: flex-start; }
#app .baby-empty-line { font-size: 13px; padding: 14px 2px; }
#app .baby-empty-hint { font-size: 12px; color: var(--text-grey-soft); }

/* person-bound records surfaced in the baby module (meds + notes) — heads styled as
   track bands above (shared .baby-rec-h rule). */
#app .baby-records { display: flex; flex-direction: column; gap: 5px; }
#app .baby-rec-manage { margin-left: auto; background: none; border: 0; color: var(--text-grey); font-size: 11px; text-decoration: underline; cursor: pointer; text-transform: none; letter-spacing: 0; }
#app .baby-rec-row { font-size: 13px; color: var(--bg-black); padding: 3px 2px; }

/* dashboard widget bits */
#app .baby-w-counts .txt i { color: var(--text-grey); }
#app .baby-w-quick { margin-top: auto; } /* pinned to the card bottom in stretched rows */
/* Selected option: a SUBTLE cue (soft fill + bold + trailing check), not a full inversion —
   the muted type hint must stay readable, in dark mode too (all token-based). */
.mg-select-opt.active { background: var(--bg-track); font-weight: 700; }
.mg-select-check { display: none; }
.mg-select-opt.active .mg-select-check {
  display: inline-block; float: right; margin-top: 2px;
  font-size: 10px; color: var(--text-grey);
}