/* My Diary — base styles
   Warm palette with amber accents.
   Theme resolution: [data-effective-theme="light"|"dark"] set by tiny inline JS
   in <head>. That ensures no flash-of-wrong-theme on first paint. */

/* ============ LIGHT THEME (default) ============ */
:root,
[data-effective-theme="light"] {
    --bg:            #fdf9f3;           /* warm off-white */
    --bg-alt:        #f7f1e7;
    --card:          #ffffff;
    --ink:           #1c1917;           /* near-black, warm */
    --ink-soft:      #44403c;
    --muted:         #78716c;
    --muted-2:       #a8a29e;
    --border:        #eee5d6;
    --border-strong: #e0d4bd;

    --accent:        #ea7d1a;           /* amber-orange */
    --accent-hover:  #c9661a;
    --accent-soft:   #fef3e2;
    --accent-ink:    #9a4b0e;           /* dark accent text on light bg */

    --danger:        #dc2626;
    --danger-soft:   #fee2e2;
    --danger-ink:    #991b1b;
    --success:       #16a34a;
    --success-soft:  #dcfce7;
    --success-ink:   #14532d;

    --shadow-sm:     0 1px 2px rgba(28, 25, 23, .06);
    --shadow:        0 4px 12px rgba(28, 25, 23, .08);
    --shadow-lg:     0 12px 32px rgba(28, 25, 23, .14);

    --input-bg:      #ffffff;
    --table-head-bg: #faf6ee;
    --table-row-hov: #fdfaf3;

    --avatar-grad: linear-gradient(135deg, #f59e0b, #ea580c);
    --brand-grad:  linear-gradient(135deg, #f59e0b, #ea580c);
    --auth-glow-a: rgba(245, 158, 11, .10);
    --auth-glow-b: rgba(234, 88, 12, .10);
}

/* ============ DARK THEME ============ */
[data-effective-theme="dark"] {
    --bg:            #1a1614;           /* warm dark */
    --bg-alt:        #141110;
    --card:          #262220;           /* slightly lifted */
    --ink:           #f5f1ea;
    --ink-soft:      #d6cfc2;
    --muted:         #9a8f80;
    --muted-2:       #6b6258;
    --border:        #3a342f;
    --border-strong: #4d463f;

    --accent:        #fbbf24;           /* brighter amber, readable on dark */
    --accent-hover:  #f59e0b;
    --accent-soft:   rgba(251, 191, 36, .12);
    --accent-ink:    #fbbf24;

    --danger:        #f87171;
    --danger-soft:   rgba(248, 113, 113, .14);
    --danger-ink:    #fca5a5;
    --success:       #4ade80;
    --success-soft:  rgba(74, 222, 128, .14);
    --success-ink:   #86efac;

    --shadow-sm:     0 1px 2px rgba(0, 0, 0, .3);
    --shadow:        0 4px 12px rgba(0, 0, 0, .4);
    --shadow-lg:     0 12px 32px rgba(0, 0, 0, .55);

    --input-bg:      #1f1b19;
    --table-head-bg: #1f1b19;
    --table-row-hov: #2e2925;

    --avatar-grad: linear-gradient(135deg, #f59e0b, #b45309);
    --brand-grad:  linear-gradient(135deg, #f59e0b, #b45309);
    --auth-glow-a: rgba(245, 158, 11, .15);
    --auth-glow-b: rgba(234, 88, 12, .10);

    color-scheme: dark;
}

/* ============ BASE ============ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background-color .2s, color .2s;
}

h1 { font-size: 22px; margin: 0 0 4px; color: var(--ink); }
h2 { font-size: 16px; margin: 0; color: var(--ink); }

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

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

hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }

/* ============ TOPBAR ============ */

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    height: 60px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--ink);
    font-weight: 700;
    white-space: nowrap;
}
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--brand-grad);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -.5px;
    box-shadow: 0 2px 6px rgba(234, 125, 26, .3);
}
.brand-name { font-size: 15px; }

.main-nav { flex: 1; }
.main-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 2px; }
.main-nav a {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 8px;
    color: var(--ink-soft);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: background .12s, color .12s;
}
.main-nav a:hover { background: var(--bg-alt); color: var(--ink); }
.main-nav a.is-active {
    background: var(--accent-soft);
    color: var(--accent-ink);
    font-weight: 600;
}

.nav-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 38px;
    height: 38px;
    padding: 0;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
}
.nav-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--ink);
    border-radius: 2px;
}

/* ============ USER MENU ============ */

.user-menu { position: relative; }

.user-menu-trigger {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--card);
    border: 1px solid var(--border);
    padding: 5px 12px 5px 5px;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    color: var(--ink);
    transition: border-color .12s, background .12s;
}
.user-menu-trigger:hover {
    border-color: var(--border-strong);
    background: var(--bg-alt);
}
.user-menu-name {
    font-size: 14px;
    font-weight: 500;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chev { color: var(--muted); transition: transform .15s; }
.user-menu.open .chev { transform: rotate(180deg); }

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--avatar-grad);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(234, 125, 26, .25);
}

.user-menu-pop {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 240px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 50;
}
.user-menu-head {
    padding: 10px 12px 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
}
.user-menu-name-lg {
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-menu-email {
    font-size: 12px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    font-size: 14px;
    color: var(--ink-soft);
    text-decoration: none;
    border-radius: 6px;
}
.user-menu-item:hover { background: var(--bg-alt); color: var(--ink); }
.user-menu-item svg { color: var(--muted); flex-shrink: 0; }
.user-menu-item-danger { color: var(--danger); }
.user-menu-item-danger svg { color: var(--danger); }
.user-menu-item-danger:hover { background: var(--danger-soft); color: var(--danger); }
.user-menu-pop hr { margin: 6px 0; border: 0; border-top: 1px solid var(--border); }

/* Theme switcher inside the menu */
.theme-switcher {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px 4px;
}
.theme-switcher-label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.theme-switcher-form {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.theme-btn {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 24px;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    border-radius: 5px;
    padding: 0;
    transition: background .12s, color .12s;
}
.theme-btn:hover { color: var(--ink); }
.theme-btn.is-active {
    background: var(--card);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}

/* ============ PAGE ============ */

.page { max-width: 1200px; margin: 0 auto; padding: 28px 20px 80px; }
.page-narrow { max-width: 760px; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}
.page-head h1 { margin: 0; }

.back-link {
    display: inline-block;
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    margin-bottom: 8px;
}
.back-link:hover { color: var(--accent); }

/* ============ AUTH ============ */

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(1200px 600px at 10% -10%, var(--auth-glow-a), transparent 60%),
        radial-gradient(1000px 600px at 110% 110%, var(--auth-glow-b), transparent 60%),
        var(--bg);
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 36px;
}
.auth-card h1 { margin-bottom: 4px; }
.auth-card p { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.auth-card label {
    display: block;
    margin-top: 16px;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
}
.auth-card input[type="email"],
.auth-card input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    background: var(--input-bg);
    color: var(--ink);
}
.auth-card input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.auth-card button[type="submit"] {
    margin-top: 22px;
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: 0;
    padding: 11px 14px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.auth-card button[type="submit"]:hover { background: var(--accent-hover); }

/* ============ CARD / FORMS ============ */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}
.card h2 { margin-top: 8px; margin-bottom: 4px; }
.card hr { margin: 22px 0 14px; }

.card label {
    display: block;
    margin-top: 14px;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-soft);
}
.card input[type="text"],
.card input[type="email"],
.card input[type="password"],
.card input[type="date"],
.card input[type="time"],
.card textarea,
.card select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    background: var(--input-bg);
    color: var(--ink);
    font-family: inherit;
}
.card input:focus,
.card textarea:focus,
.card select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

.check-inline {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    margin-top: 16px !important;
    margin-bottom: 0 !important;
    font-weight: 500;
    cursor: pointer;
    color: var(--ink-soft);
}
.check-inline input { margin: 0; accent-color: var(--accent); }

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 22px;
}

/* ============ BUTTONS ============ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    line-height: 1.2;
    font-family: inherit;
    transition: background .12s, border-color .12s, color .12s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost {
    background: var(--card);
    color: var(--ink-soft);
    border-color: var(--border);
}
.btn-ghost:hover {
    background: var(--bg-alt);
    color: var(--ink);
    border-color: var(--border-strong);
}

/* ============ VIEWER PICKER ============ */

.viewer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 8px;
    margin-top: 12px;
}
.viewer-row {
    display: flex !important;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 0 !important;
    cursor: pointer;
    font-weight: 500 !important;
    background: var(--card);
    color: var(--ink);
    transition: border-color .12s, background .12s;
}
.viewer-row[hidden] { display: none !important; }
.viewer-row:hover { border-color: var(--accent); background: var(--accent-soft); }
.viewer-row input { margin: 0; accent-color: var(--accent); }
.viewer-row span { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ============ DATA TABLE ============ */

.table-wrap {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; color: var(--ink); }
.data-table thead { background: var(--table-head-bg); text-align: left; }
.data-table thead th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    font-weight: 600;
}
.data-table th, .data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--table-row-hov); }
.data-table .actions { text-align: right; }
.data-table .actions a { color: var(--accent); text-decoration: none; margin-left: 10px; font-weight: 500; }
.data-table .actions a:hover { text-decoration: underline; }

/* ============ BADGES ============ */

.badge {
    display: inline-block;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: .3px;
}
.badge-ok    { background: var(--success-soft); color: var(--success-ink); }
.badge-muted { background: var(--bg-alt); color: var(--muted); border: 1px solid var(--border); }
.badge-admin { background: var(--accent-soft); color: var(--accent-ink); }

/* ============ ALERTS ============ */

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-success { background: var(--success-soft); color: var(--success-ink); border: 1px solid var(--border); }
.alert-error   { background: var(--danger-soft);  color: var(--danger-ink);  border: 1px solid var(--border); }
.alert-list { margin: 0; padding-left: 20px; }

/* ============ RESPONSIVE ============ */

@media (max-width: 720px) {
    .nav-toggle { display: inline-flex; }
    .main-nav {
        position: absolute;
        top: 60px;
        left: 0; right: 0;
        background: var(--card);
        border-bottom: 1px solid var(--border);
        padding: 8px 16px 16px;
        box-shadow: var(--shadow);
        display: none;
    }
    .main-nav.is-open { display: block; }
    .main-nav ul { flex-direction: column; gap: 2px; }
    .main-nav a { display: block; padding: 10px 12px; }

    .user-menu-name { display: none; }
    .user-menu-trigger { padding: 4px; }
    .brand-name { display: none; }

    .page-head { flex-direction: column; align-items: flex-start; }
}

/* ============ CALENDAR TOOLBAR ============ */

.cal-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}
.cal-toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.cal-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}
.cal-title {
    margin: 0 0 0 4px;
    font-size: 18px;
    font-weight: 600;
}

.view-switch {
    display: inline-flex;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px;
}
.view-switch a {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    border-radius: 5px;
    transition: color .12s, background .12s;
}
.view-switch a:hover { color: var(--ink); }
.view-switch a.is-active {
    background: var(--card);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

.cal-nav { display: inline-flex; gap: 4px; }
.btn.btn-icon { padding: 6px 10px; font-size: 18px; line-height: 1; }

.cal-owner-select {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}
.cal-owner-select select {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    color: var(--ink);
    font-size: 13px;
    font-family: inherit;
}

/* ============ DAY VIEW ============ */

.day-view {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.allday-strip {
    display: grid;
    grid-template-columns: 72px 1fr;
    border-bottom: 1px solid var(--border);
    background: var(--bg-alt);
}
.allday-label {
    padding: 10px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    font-weight: 600;
    border-right: 1px solid var(--border);
}
.allday-items {
    padding: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.hour-grid { display: block; }
.hour-row {
    display: grid;
    grid-template-columns: 72px 1fr;
    border-top: 1px solid var(--border);
    min-height: 32px;
}
.hour-row:first-child { border-top: 0; }
.hour-row.is-half { border-top-style: dashed; }
.hour-label {
    padding: 4px 12px;
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
    border-right: 1px solid var(--border);
    background: var(--bg-alt);
}
.hour-slot {
    padding: 2px 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: background .12s;
}
.hour-slot:hover { background: var(--accent-soft); }

/* ============ APPOINTMENT BLOCKS ============ */

.appt {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 10px;
    background: var(--accent);
    color: #fff;
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
    line-height: 1.35;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
    transition: transform .08s, box-shadow .12s;
}
.appt:hover {
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,.18);
}
.appt-time { font-size: 11px; font-weight: 600; opacity: .95; }
.appt-title { font-weight: 600; }
.appt-loc { font-size: 11px; opacity: .9; }
.appt-allday {
    background: var(--accent);
    color: #fff;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
}
.appt-compact, .appt-pill {
    padding: 3px 6px;
    font-size: 12px;
    flex-direction: row;
    align-items: baseline;
    gap: 4px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.appt-compact .appt-time,
.appt-pill    .appt-time { font-size: 11px; }
.appt-compact .appt-title,
.appt-pill    .appt-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============ WEEK VIEW ============ */

.week-view {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.week-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
}
.week-day-head {
    padding: 10px 8px;
    text-align: center;
    border-left: 1px solid var(--border);
}
.week-day-head:first-child { border-left: 0; }
.week-dow {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    font-weight: 600;
}
.week-dom {
    font-size: 20px;
    font-weight: 600;
    color: var(--ink);
    margin-top: 2px;
}
.week-day-head.is-today .week-dom {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    margin-top: 0;
    font-size: 16px;
}
.week-body {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    min-height: 500px;
}
.week-cell {
    border-left: 1px solid var(--border);
    padding: 6px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    transition: background .12s;
}
.week-cell:first-child { border-left: 0; }
.week-cell:hover { background: var(--accent-soft); }

/* ============ MONTH VIEW ============ */

.month-view {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.month-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
}
.month-dow-head {
    padding: 10px 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    font-weight: 600;
    text-align: center;
    border-left: 1px solid var(--border);
}
.month-dow-head:first-child { border-left: 0; }
.month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: minmax(110px, 1fr);
}
.month-cell {
    border-left: 1px solid var(--border);
    border-top: 1px solid var(--border);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    cursor: pointer;
    transition: background .12s;
    overflow: hidden;
}
.month-cell:nth-child(7n+1) { border-left: 0; }
.month-cell:nth-child(-n+7) { border-top: 0; }
.month-cell:hover { background: var(--accent-soft); }
.month-cell.is-other { background: var(--bg-alt); color: var(--muted); }
.month-cell.is-other .month-num { color: var(--muted-2); }
.month-num {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: 2px;
}
.month-cell.is-today .month-num {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
}
.appt-more {
    font-size: 11px;
    color: var(--muted);
    padding: 0 4px;
}

/* ============ MODAL ============ */

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    overflow-y: auto;
}
.modal[hidden] { display: none; }
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, .55);
    backdrop-filter: blur(2px);
}
.modal-card {
    position: relative;
    width: 100%;
    max-width: 560px;
    background: var(--card);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    z-index: 1;
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-close {
    background: none;
    border: 0;
    font-size: 24px;
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
    padding: 0 6px;
}
.modal-close:hover { color: var(--ink); }
.modal-body {
    padding: 20px;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
}
.modal-body input[type="text"],
.modal-body input[type="email"],
.modal-body input[type="date"],
.modal-body input[type="time"],
.modal-body textarea,
.modal-body select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    background: var(--input-bg);
    color: var(--ink);
    font-family: inherit;
}
.modal-body input:focus,
.modal-body textarea:focus,
.modal-body select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.modal-body label {
    display: block;
    margin-top: 14px;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-soft);
}
.modal-body hr { margin: 20px 0 12px; }
.modal-body h2 { font-size: 15px; margin-bottom: 4px; }
.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.invitee-grid { max-height: 180px; overflow-y: auto; padding: 2px; }
.invitee-row { font-size: 13px; }

.btn-danger {
    background: var(--danger);
    color: #fff;
    margin-right: auto; /* push to the left */
}
.btn-danger:hover { background: #b91c1c; color: #fff; }

/* ============ SENDING / WAIT MODAL ============ */
.sending-modal { align-items: center; }
.sending-card {
    position: relative;
    z-index: 1;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 28px 32px;
    text-align: center;
    min-width: 280px;
    max-width: 360px;
}
.sending-text {
    font-weight: 600;
    color: var(--ink);
    margin-top: 16px;
}
.sending-sub { font-size: 13px; margin-top: 4px; }

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ SETTINGS PAGE ============ */
.settings-form textarea { min-height: 60px; }
.settings-test-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 8px;
}
.settings-test-bar input {
    flex: 1;
    min-width: 200px;
}

.settings-result { margin-top: 14px; }

/* ============ RECURRENCE UI ============ */
.weekday-picker {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.weekday-chip {
    display: inline-flex !important;
    align-items: center;
    margin: 0 !important;
    cursor: pointer;
    position: relative;
}
.weekday-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.weekday-chip span {
    display: inline-block;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--card);
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 500;
    transition: border-color .12s, background .12s, color .12s;
}
.weekday-chip input:checked + span {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.weekday-chip:hover span {
    border-color: var(--accent);
}

.recur-end {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 8px;
}
.recur-end .check-inline {
    margin-top: 0 !important;
}
.recur-end-field {
    max-width: 170px;
    padding: 7px 10px !important;
    font-size: 14px !important;
}
.recur-end-field:disabled {
    opacity: .5;
}

/* ============ DRAG / DROP / RESIZE ============ */

.appt { position: relative; cursor: grab; }
.appt:active { cursor: grabbing; }
.appt.is-dragging { opacity: .35; }

/* Resize handle - 6px bottom strip, only on full day-view blocks */
.appt-resize {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 6px;
    cursor: ns-resize;
    background: transparent;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}
.appt-resize:hover {
    background: rgba(255,255,255,.35);
}
.appt.is-resizing { cursor: ns-resize; }

/* Drop-target hover states */
.hour-slot.is-drop-over,
.week-cell.is-drop-over,
.month-cell.is-drop-over {
    background: var(--accent-soft);
    outline: 2px dashed var(--accent);
    outline-offset: -4px;
}

/* ============ CONFIRM TOAST ============ */
.confirm-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 120;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: 14px 16px;
    min-width: 320px;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: toast-in .18s ease-out;
}
.confirm-toast[hidden] { display: none; }
.confirm-toast-msg {
    color: var(--ink);
    font-size: 14px;
    line-height: 1.4;
}
.confirm-toast-msg strong { color: var(--accent); }
.confirm-toast-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.confirm-toast .btn { padding: 7px 14px; font-size: 13px; }
@keyframes toast-in {
    from { transform: translateX(-50%) translateY(20px); opacity: 0; }
    to   { transform: translateX(-50%) translateY(0);     opacity: 1; }
}

/* When resize mode is active, prevent pointer-events on child spans that could confuse the drag start */
.appt.is-resizing .appt-title,
.appt.is-resizing .appt-time,
.appt.is-resizing .appt-loc {
    pointer-events: none;
}


/* ============ MEETING NOTES ============ */

.notes-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 16px;
    align-items: start;
}

.notes-sidebar {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 400px;
}

.notes-search-form input[type="search"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--input-bg);
    color: var(--ink);
}

.notes-sidebar-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 6px;
}

.notes-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.notes-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12px;
    color: var(--ink-soft);
    text-decoration: none;
    transition: background .12s, border-color .12s, color .12s;
}
.notes-tag-chip:hover {
    border-color: var(--accent);
    color: var(--accent-ink);
}
.notes-tag-chip.is-active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.notes-tag-chip.is-active:hover {
    color: #fff;
}
.notes-tag-count {
    font-size: 10px;
    opacity: .8;
}
.notes-tag-clear {
    color: var(--muted);
    background: transparent;
    border-color: transparent;
}

.notes-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    max-height: calc(100vh - 280px);
    margin: -4px;
    padding: 4px;
}
.notes-list-item {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--ink);
    border: 1px solid transparent;
    transition: background .12s, border-color .12s;
}
.notes-list-item:hover {
    background: var(--bg-alt);
    color: var(--ink);
}
.notes-list-item.is-active {
    background: var(--accent-soft);
    border-color: var(--accent);
}
.notes-list-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.notes-list-preview {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}
.notes-list-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    font-size: 11px;
    align-items: center;
    margin-top: 6px;
}
.notes-appt-pill {
    font-size: 11px;
    background: var(--bg-alt);
    padding: 1px 6px;
    border-radius: 4px;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.notes-mini-tag {
    font-size: 11px;
    color: var(--accent-ink);
    background: var(--accent-soft);
    padding: 0 6px;
    border-radius: 999px;
}

.notes-empty {
    padding: 40px 16px;
    text-align: center;
    font-size: 13px;
}

/* Editor pane */
.notes-editor {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    min-height: 500px;
    display: flex;
    flex-direction: column;
}

.notes-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
    color: var(--muted);
    flex: 1;
}
.notes-placeholder-icon { font-size: 40px; margin-bottom: 8px; }

.notes-form {
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 12px;
    flex: 1;
}

.notes-title-input {
    width: 100%;
    font-size: 22px;
    font-weight: 600;
    padding: 6px 2px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--ink);
    font-family: inherit;
}
.notes-title-input:focus {
    outline: none;
    border-bottom-color: var(--accent);
}

.notes-meta-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.notes-meta-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
}
.notes-meta-label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
}
.notes-meta-field input,
.notes-meta-field select {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    background: var(--input-bg);
    color: var(--ink);
    font-family: inherit;
}
.notes-meta-field input:focus,
.notes-meta-field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.notes-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 6px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 8px 8px 0 0;
    margin-bottom: -1px; /* blend into body top border */
    align-items: center;
}
.notes-tb-btn {
    background: transparent;
    border: 1px solid transparent;
    padding: 4px 9px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    color: var(--ink-soft);
    font-family: inherit;
    min-width: 28px;
}
.notes-tb-btn:hover {
    background: var(--card);
    border-color: var(--border);
    color: var(--ink);
}
.notes-tb-sep {
    width: 1px;
    height: 16px;
    background: var(--border);
    margin: 0 4px;
}

.notes-body {
    flex: 1;
    min-height: 280px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 0 0 8px 8px;
    background: var(--input-bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.55;
    outline: none;
    overflow-y: auto;
}
.notes-body:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.notes-body.is-empty::before {
    content: attr(data-placeholder);
    color: var(--muted);
    pointer-events: none;
}
.notes-body p  { margin: 0 0 8px; }
.notes-body h1, .notes-body h2, .notes-body h3 { margin: 12px 0 6px; line-height: 1.25; }
.notes-body ul, .notes-body ol { margin: 6px 0 8px 24px; }
.notes-body a  { color: var(--accent); }
.notes-body code {
    background: var(--bg-alt);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: .9em;
}
.notes-body blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 12px;
    margin: 8px 0;
    color: var(--ink-soft);
}

.notes-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    margin-top: 6px;
}
.notes-actions .btn-danger { margin-right: auto; }

.notes-filter-bar {
    background: var(--accent-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.notes-clear { color: var(--muted); text-decoration: none; font-size: 12px; }
.notes-clear:hover { color: var(--accent); }

/* ============ NOTES SHARING ============ */

.notes-share-banner {
    background: var(--accent-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    color: var(--ink-soft);
}
.notes-share-banner strong { color: var(--ink); }
.notes-share-perm {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}

.notes-share-pill {
    font-size: 11px;
    color: var(--accent-ink);
    background: var(--accent-soft);
    padding: 1px 6px;
    border-radius: 4px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notes-share-picker {
    margin-top: 6px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.share-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 8px;
}

.share-row {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    background: var(--card);
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    transition: border-color .12s;
}
.share-row:hover { border-color: var(--accent); }

.share-row-main {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin: 0 !important;
    font-weight: 500 !important;
}
.share-row-main input { margin: 0; accent-color: var(--accent); }
.share-row-main span { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.share-row-main .muted { font-weight: 400 !important; font-size: 12px; }

.share-perm-pills {
    display: flex;
    gap: 4px;
    padding: 2px;
    background: var(--bg-alt);
    border-radius: 6px;
    align-self: flex-start;
}
.share-perm-pills[hidden] { display: none; }

.perm-pill {
    display: inline-block !important;
    cursor: pointer;
    margin: 0 !important;
    position: relative;
    font-weight: 500 !important;
}
.perm-pill input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.perm-pill span {
    display: inline-block;
    padding: 3px 10px;
    font-size: 12px;
    color: var(--muted);
    border-radius: 4px;
    transition: background .12s, color .12s;
}
.perm-pill input:checked + span {
    background: var(--card);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

/* Read-only editor state */
.notes-form.is-readonly .notes-toolbar { opacity: .5; pointer-events: none; }
.notes-form.is-readonly .notes-body    { background: var(--bg-alt); }

/* ============ NOTE ATTACHMENTS ============ */

.notes-attach-section {
    margin-top: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.attach-upload {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 12px;
    background: var(--bg-alt);
    border: 1px dashed var(--border-strong);
    border-radius: 8px;
    margin: 8px 0 12px;
    transition: border-color .12s, background .12s;
}
.attach-upload.is-dropover {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.attach-upload-btn {
    display: inline-flex;
    align-items: center;
    margin: 0 !important;
    cursor: pointer;
    position: relative;
}
.attach-upload-btn input[type=file] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.attach-btn-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent);
    color: #fff;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
}
.attach-upload-btn:hover .attach-btn-text { background: var(--accent-hover); }

.attach-hint { font-size: 12px; }

.attach-status {
    font-size: 12px;
    margin-left: auto;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--border);
    color: var(--ink-soft);
}
.attach-status.is-working { background: var(--accent-soft); color: var(--accent-ink); }
.attach-status.is-ok      { background: var(--success-soft); color: var(--success-ink); }
.attach-status.is-error   { background: var(--danger-soft);  color: var(--danger-ink); }

.attach-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}
.attach-empty { padding: 8px 4px; font-size: 13px; }

.attach-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color .12s, box-shadow .12s;
}
.attach-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.attach-thumb {
    display: block;
    width: 100%;
    height: 120px;
    background: var(--bg-alt);
    overflow: hidden;
}
.attach-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.attach-icon {
    height: 120px;
    display: grid;
    place-items: center;
    background: var(--bg-alt);
    color: var(--muted);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 1px;
}

.attach-meta {
    padding: 8px 10px;
    flex: 1;
    min-width: 0;
}
.attach-name {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.attach-name:hover { color: var(--accent); }
.attach-sub { font-size: 11px; margin-top: 2px; }

.attach-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 50%;
    background: rgba(0,0,0,.55);
    color: #fff;
    font-size: 18px;
    line-height: 22px;
    cursor: pointer;
    padding: 0;
    opacity: 0;
    transition: opacity .12s, background .12s;
}
.attach-card:hover .attach-delete,
.attach-delete:focus { opacity: 1; }
.attach-delete:hover { background: var(--danger); }

/* ============ SHARED DIALOGS (confirm/alert/prompt) ============ */

.md-dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(24, 15, 5, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    animation: md-dlg-fade .15s ease-out;
}
.md-dialog-backdrop[hidden] { display: none; }

@keyframes md-dlg-fade  { from { opacity: 0; } to { opacity: 1; } }
@keyframes md-dlg-pop   { from { transform: translateY(6px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

.md-dialog {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
    width: 100%;
    max-width: 440px;
    animation: md-dlg-pop .18s ease-out;
    overflow: hidden;
}
.md-dialog.is-danger  { border-top: 4px solid var(--danger,  #c0392b); }
.md-dialog.is-success { border-top: 4px solid var(--success, #2e8540); }
.md-dialog.is-error   { border-top: 4px solid var(--danger,  #c0392b); }

.md-dialog-body {
    padding: 22px 22px 16px;
}
.md-dialog-title {
    margin: 0 0 8px;
    font-size: 17px;
    font-weight: 600;
    color: var(--ink);
}
.md-dialog-msg {
    font-size: 14px;
    color: var(--ink-soft);
    line-height: 1.5;
}
.md-dialog-msg strong { color: var(--ink); }

.md-dialog-input {
    margin-top: 12px;
    width: 100%;
    padding: 9px 12px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--ink);
    font-family: inherit;
}
.md-dialog-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.md-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 22px 18px;
    background: var(--card);
}

/* ============ NOTES: PHONE LAYOUT (≤ 720px) ============ */

/* Mobile-only "back to list" link — hidden on desktop */
.notes-back-link { display: none; }

@media (max-width: 720px) {

    /* Stack list over editor instead of side-by-side */
    .notes-layout {
        grid-template-columns: 1fr;
    }

    /* Auto mode: show ONLY the relevant pane on phones.
       Explicit classes set by the PHP page (is-editing/is-browsing) are the
       primary signal; :has() is a progressive fallback for hypothetical cases. */
    .notes-layout.is-editing .notes-sidebar   { display: none; }
    .notes-layout.is-browsing .notes-editor   { display: none; }

    /* Give the sidebar room to breathe when it's the only thing on screen */
    .notes-sidebar {
        min-height: 0;
    }
    .notes-list {
        max-height: none; /* remove the desktop cap */
    }

    /* Page head: keep title + New note button on one tight row */
    .page-head {
        gap: 8px;
        flex-wrap: wrap;
    }

    /* Back-to-list link shown only when editing (injected by PHP) */
    .notes-back-link {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        margin-bottom: 10px;
        padding: 6px 12px 6px 8px;
        background: var(--bg-alt);
        border: 1px solid var(--border);
        border-radius: 999px;
        font-size: 13px;
        color: var(--ink-soft);
        text-decoration: none;
        font-weight: 500;
    }
    .notes-back-link:hover { color: var(--accent); border-color: var(--accent); }
    .notes-back-link::before { content: "‹"; font-size: 18px; line-height: 1; margin-right: 2px; }

    /* Title input bigger on mobile for better tappability */
    .notes-title-input {
        font-size: 19px;
    }

    /* Meta row stacks to single column */
    .notes-meta-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* Tighter form padding so more content fits */
    .notes-form {
        padding: 12px;
        gap: 10px;
    }

    /* Toolbar: horizontally scrollable when buttons would wrap */
    .notes-toolbar {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        /* Hide scrollbar on webkit for cleaner look */
        scrollbar-width: thin;
    }
    .notes-toolbar::-webkit-scrollbar {
        height: 4px;
    }
    .notes-toolbar::-webkit-scrollbar-thumb {
        background: var(--border-strong);
        border-radius: 2px;
    }
    .notes-tb-btn {
        flex-shrink: 0; /* don't let them squeeze */
        padding: 6px 10px;  /* a touch bigger for fingers */
        min-height: 32px;
    }
    .notes-tb-sep { flex-shrink: 0; }

    /* Body: bit more room */
    .notes-body {
        min-height: 220px;
        padding: 12px;
        font-size: 16px; /* prevents iOS auto-zoom on focus */
    }

    /* Meta inputs at readable size */
    .notes-meta-field input,
    .notes-meta-field select {
        font-size: 16px; /* also prevents iOS zoom */
        padding: 9px 10px;
    }

    /* Attachments grid: 2 cols on most phones, 1 col on very narrow */
    .attach-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .attach-thumb, .attach-icon { height: 100px; }

    /* Delete × always visible on touch (can't "hover") */
    .attach-delete {
        opacity: 1;
        width: 28px;
        height: 28px;
        font-size: 20px;
        line-height: 26px;
    }

    /* Upload zone: slightly more spacious for thumbs */
    .attach-upload { padding: 10px; gap: 10px; }
    .attach-btn-text { padding: 9px 16px; }
    .attach-hint { font-size: 11px; }

    /* Share picker: stack to 1 column */
    .share-picker-grid {
        grid-template-columns: 1fr;
    }

    /* Actions row: stack if cramped */
    .notes-actions {
        flex-wrap: wrap;
    }
    .notes-actions .btn {
        flex: 1 1 auto;
        text-align: center;
    }
    /* But keep Delete on its own line on the left */
    .notes-actions .btn-danger {
        flex: 1 1 100%;
        margin-right: 0;
    }

    /* Sidebar list items: tighter padding */
    .notes-list-item { padding: 8px 10px; }

    /* Tag chips wrap tighter */
    .notes-tag-list { gap: 3px; }
    .notes-tag-chip { padding: 2px 8px; font-size: 11px; }

    /* Filter bar: stack on narrow */
    .notes-filter-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    /* Share banner: wrap nicely */
    .notes-share-banner { padding: 9px 12px; }
}

/* Very narrow phones (≤ 380px) — tighten attachment grid to 1 column */
@media (max-width: 380px) {
    .attach-grid { grid-template-columns: 1fr; }
    .attach-thumb, .attach-icon { height: 140px; }
}

/* ============ DASHBOARD ============ */

.dash-header {
    margin-bottom: 6px;
}
.dash-greeting {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--ink);
}
.dash-date {
    font-size: 14px;
}

/* Quick actions (mobile-only — hidden on desktop) */
.dash-quick-actions {
    display: none;
    gap: 8px;
    margin: 14px 0 6px;
    flex-wrap: wrap;
}
.dash-quick-actions .btn { flex: 1 1 auto; justify-content: center; }

/* Main grid */
.dash-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 20px;
    align-items: stretch;   /* top row cards match heights */
}
/* Recent notes spans full width, shared-with-me too */
.dash-recent-notes,
.dash-shared { grid-column: 1 / -1; }

/* Today + Week sit in the top row at equal height, scrolling internally. */
.dash-today,
.dash-week {
    display: flex;
    flex-direction: column;
    max-height: 560px;      /* cap so long lists scroll instead of stretching the page */
    overflow: hidden;       /* the inner list scrolls, not the card itself */
}

/* Card head stays pinned, body scrolls */
.dash-today .dash-card-head,
.dash-week  .dash-card-head {
    flex: 0 0 auto;
}
.dash-today .dash-appt-list,
.dash-week  .dash-week-days,
.dash-today .dash-empty,
.dash-week  .dash-empty {
    overflow-y: auto;
    flex: 1 1 auto;
    /* Thin, subtle scrollbar that matches the theme */
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}
.dash-today .dash-appt-list::-webkit-scrollbar,
.dash-week  .dash-week-days::-webkit-scrollbar {
    width: 6px;
}
.dash-today .dash-appt-list::-webkit-scrollbar-thumb,
.dash-week  .dash-week-days::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 3px;
}

.dash-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    padding: 16px;
}
.dash-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.dash-card-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .75px;
    font-weight: 700;
    color: var(--muted);
    margin: 0;
}
.dash-card-link {
    font-size: 12px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}
.dash-card-link:hover { text-decoration: underline; }
.dash-card-badge {
    background: var(--accent);
    color: #fff;
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 600;
}

/* Empty state */
.dash-empty {
    padding: 24px 10px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}
.dash-empty-icon { font-size: 28px; margin-bottom: 4px; }

/* Appointment list rows */
.dash-appt-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.dash-appt-row { margin: 0; }
.dash-appt-link {
    display: grid;
    grid-template-columns: 56px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--ink);
    transition: background .12s;
}
.dash-appt-link:hover {
    background: var(--accent-soft);
    color: var(--ink);
}
.dash-appt-row.is-past .dash-appt-link {
    opacity: .55;
}
.dash-appt-time {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 13px;
    color: var(--accent-ink);
}
.dash-appt-title {
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dash-appt-loc {
    font-size: 11px;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Week view */
.dash-week-days {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.dash-week-day {
    display: grid;
    grid-template-columns: 70px 1fr;
    gap: 10px;
    align-items: start;
}
.dash-week-dlabel {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-soft);
    padding-top: 10px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.dash-appt-list-compact .dash-appt-link {
    grid-template-columns: 48px 1fr;
    padding: 6px 10px;
}
.dash-appt-list-compact .dash-appt-title { font-size: 13px; }

/* Recent notes rows */
.dash-note-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.dash-note-row { margin: 0; }
.dash-note-link {
    display: block;
    padding: 9px 10px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--ink);
    transition: background .12s;
}
.dash-note-link:hover {
    background: var(--accent-soft);
    color: var(--ink);
}
.dash-note-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.dash-note-title {
    font-weight: 500;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 70%;
}
.dash-note-sub {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 12px;
    flex-wrap: wrap;
    margin-top: 2px;
}

/* Phone layout */
@media (max-width: 720px) {
    .dash-grid { grid-template-columns: 1fr; }
    .dash-quick-actions { display: flex; }
    .dash-greeting { font-size: 20px; }
    .dash-date { font-size: 13px; }

    /* Remove fixed heights on phones — let cards flow naturally */
    .dash-today, .dash-week {
        max-height: none;
        overflow: visible;
    }
    .dash-today .dash-appt-list,
    .dash-week  .dash-week-days,
    .dash-today .dash-empty,
    .dash-week  .dash-empty {
        overflow: visible;
    }

    .dash-week-day {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    .dash-week-dlabel {
        padding-top: 4px;
        padding-bottom: 2px;
    }
    .dash-appt-loc { max-width: 100px; }
}

/* ============ PER-USER COLOURS ============ */
/*
 * Colours set by admin on the Users page.
 * Applied to an .appt's background when the appointment's owner isn't the
 * current user. Own appointments keep the default amber.
 *
 * "other" is a fallback when an owner has no colour picked.
 *
 * Each colour is balanced against white foreground for readability.
 * Dark-mode variants are slightly lighter/more saturated so they pop
 * against the warm dark background.
 */

.appt--colour-teal     { background: #0d8a8a; }
.appt--colour-blue     { background: #1e6fd9; }
.appt--colour-indigo   { background: #4f46e5; }
.appt--colour-purple   { background: #8b3ea8; }
.appt--colour-pink     { background: #c0427f; }
.appt--colour-rose     { background: #be123c; }
.appt--colour-green    { background: #157f3c; }
.appt--colour-olive    { background: #6a7538; }
.appt--colour-slate    { background: #475569; }
.appt--colour-brown    { background: #7a4b28; }
.appt--colour-other    { background: #64748b; }

[data-theme="dark"] .appt--colour-teal   { background: #14b8a6; }
[data-theme="dark"] .appt--colour-blue   { background: #3b82f6; }
[data-theme="dark"] .appt--colour-indigo { background: #6366f1; }
[data-theme="dark"] .appt--colour-purple { background: #a855f7; }
[data-theme="dark"] .appt--colour-pink   { background: #e8568f; }
[data-theme="dark"] .appt--colour-rose   { background: #f43f5e; }
[data-theme="dark"] .appt--colour-green  { background: #22c55e; }
[data-theme="dark"] .appt--colour-olive  { background: #a3a837; }
[data-theme="dark"] .appt--colour-slate  { background: #94a3b8; }
[data-theme="dark"] .appt--colour-brown  { background: #b08760; }
[data-theme="dark"] .appt--colour-other  { background: #94a3b8; }

/* Dashboard rows: tint the left edge rather than the whole row so the
   cards stay readable. */
.dash-appt-row[class*="appt--colour-"]    { position: relative; }
.dash-appt-row[class*="appt--colour-"]::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 4px;
    bottom: 4px;
    width: 3px;
    border-radius: 2px;
    background: currentColor;
    opacity: .9;
}
.dash-appt-row.appt--colour-teal   { color: #0d8a8a; }
.dash-appt-row.appt--colour-blue   { color: #1e6fd9; }
.dash-appt-row.appt--colour-indigo { color: #4f46e5; }
.dash-appt-row.appt--colour-purple { color: #8b3ea8; }
.dash-appt-row.appt--colour-pink   { color: #c0427f; }
.dash-appt-row.appt--colour-rose   { color: #be123c; }
.dash-appt-row.appt--colour-green  { color: #157f3c; }
.dash-appt-row.appt--colour-olive  { color: #6a7538; }
.dash-appt-row.appt--colour-slate  { color: #475569; }
.dash-appt-row.appt--colour-brown  { color: #7a4b28; }
.dash-appt-row.appt--colour-other  { color: #64748b; }

[data-theme="dark"] .dash-appt-row.appt--colour-teal   { color: #14b8a6; }
[data-theme="dark"] .dash-appt-row.appt--colour-blue   { color: #3b82f6; }
[data-theme="dark"] .dash-appt-row.appt--colour-indigo { color: #6366f1; }
[data-theme="dark"] .dash-appt-row.appt--colour-purple { color: #a855f7; }
[data-theme="dark"] .dash-appt-row.appt--colour-pink   { color: #e8568f; }
[data-theme="dark"] .dash-appt-row.appt--colour-rose   { color: #f43f5e; }
[data-theme="dark"] .dash-appt-row.appt--colour-green  { color: #22c55e; }
[data-theme="dark"] .dash-appt-row.appt--colour-olive  { color: #a3a837; }
[data-theme="dark"] .dash-appt-row.appt--colour-slate  { color: #94a3b8; }
[data-theme="dark"] .dash-appt-row.appt--colour-brown  { color: #b08760; }
[data-theme="dark"] .dash-appt-row.appt--colour-other  { color: #94a3b8; }

/* Dash appointment title stays ink-coloured even on a colour row */
.dash-appt-row[class*="appt--colour-"] .dash-appt-title,
.dash-appt-row[class*="appt--colour-"] .dash-appt-time {
    color: var(--ink);
}
.dash-appt-row[class*="appt--colour-"] .dash-appt-time {
    color: currentColor;
    font-weight: 700;
}

/* ============ USER COLOUR PICKER (on user form) ============ */

.user-colour-field {
    margin: 14px 0;
}
.user-colour-field > label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--ink);
    font-size: 14px;
}
.user-colour-field .muted { font-weight: 400; font-size: 12px; }

.user-colour-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.user-colour-swatch {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    min-width: 70px;
    transition: border-color .12s, transform .08s;
}
.user-colour-swatch:hover { transform: translateY(-1px); }
.user-colour-swatch input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
/* Selected state — two paths for broad browser support. */

/* (1) Fallback: style the span when the input is checked (works everywhere) */
.user-colour-swatch input[type="radio"]:checked + span {
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}
/* (2) Progressive enhancement: outer outline with :has() (modern browsers) */
.user-colour-swatch:has(input:checked) {
    border-color: var(--ink);
    box-shadow: 0 0 0 2px var(--bg-alt), 0 0 0 4px var(--ink);
}
.user-colour-swatch:has(input:checked) span {
    text-decoration: none;
}
[data-theme="dark"] .user-colour-swatch:has(input:checked) {
    border-color: #fff;
    box-shadow: 0 0 0 2px var(--bg-alt), 0 0 0 4px #fff;
}

/* "default" swatch shows as plain outline */
.user-colour-swatch--none {
    background: var(--bg-alt);
    color: var(--ink-soft);
    border-color: var(--border-strong);
}

/* ============ USER COLOUR PICKER (on Users form) ============ */

.user-colour-field {
    margin-top: 14px;
}
.user-colour-field > label {
    display: block;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: 6px;
    font-size: 13px;
}
.user-colour-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.user-colour-swatch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    background: var(--card);
    margin: 0 !important;
    transition: border-color .12s, transform .08s;
    user-select: none;
}
.user-colour-swatch:hover {
    transform: translateY(-1px);
}
.user-colour-swatch input[type=radio] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.user-colour-swatch input[type=radio]:checked + span {
    font-weight: 700;
}
.user-colour-swatch:has(input:checked) {
    border-color: var(--ink);
    box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--ink);
}
/* Fallback for browsers without :has() — use an explicit class via JS later if needed */

.user-colour-swatch span {
    display: inline-block;
    position: relative;
    z-index: 1;
}

.user-colour-swatch--none {
    background: var(--bg-alt);
    color: var(--muted);
}

/* ============ PALETTE: Per-user colour classes ============
   Each class sets --appt-accent and --appt-bg which the existing
   .appt, .appt-compact, .appt-pill, .appt-allday, .dash-appt-link
   rules consume. Using CSS custom properties keeps it DRY.
*/

.appt--colour-teal    { --appt-accent: #0d9488; --appt-bg: #ccfbf1; --appt-ink: #134e4a; }
.appt--colour-blue    { --appt-accent: #2563eb; --appt-bg: #dbeafe; --appt-ink: #1e3a8a; }
.appt--colour-indigo  { --appt-accent: #4f46e5; --appt-bg: #e0e7ff; --appt-ink: #312e81; }
.appt--colour-purple  { --appt-accent: #9333ea; --appt-bg: #f3e8ff; --appt-ink: #581c87; }
.appt--colour-pink    { --appt-accent: #db2777; --appt-bg: #fce7f3; --appt-ink: #831843; }
.appt--colour-rose    { --appt-accent: #e11d48; --appt-bg: #ffe4e6; --appt-ink: #881337; }
.appt--colour-green   { --appt-accent: #16a34a; --appt-bg: #dcfce7; --appt-ink: #14532d; }
.appt--colour-olive   { --appt-accent: #65a30d; --appt-bg: #ecfccb; --appt-ink: #365314; }
.appt--colour-slate   { --appt-accent: #475569; --appt-bg: #e2e8f0; --appt-ink: #1e293b; }
.appt--colour-brown   { --appt-accent: #78350f; --appt-bg: #fed7aa; --appt-ink: #7c2d12; }
.appt--colour-other   { --appt-accent: #6b7280; --appt-bg: #e5e7eb; --appt-ink: #374151; }

/* Dark mode variants: brighter accents, darker tints */
:root.theme-dark .appt--colour-teal,
@media (prefers-color-scheme: dark) {
    :root:not(.theme-light) .appt--colour-teal    { --appt-accent: #2dd4bf; --appt-bg: #134e4a; --appt-ink: #ccfbf1; }
    :root:not(.theme-light) .appt--colour-blue    { --appt-accent: #60a5fa; --appt-bg: #1e3a8a; --appt-ink: #dbeafe; }
    :root:not(.theme-light) .appt--colour-indigo  { --appt-accent: #818cf8; --appt-bg: #312e81; --appt-ink: #e0e7ff; }
    :root:not(.theme-light) .appt--colour-purple  { --appt-accent: #c084fc; --appt-bg: #581c87; --appt-ink: #f3e8ff; }
    :root:not(.theme-light) .appt--colour-pink    { --appt-accent: #f472b6; --appt-bg: #831843; --appt-ink: #fce7f3; }
    :root:not(.theme-light) .appt--colour-rose    { --appt-accent: #fb7185; --appt-bg: #881337; --appt-ink: #ffe4e6; }
    :root:not(.theme-light) .appt--colour-green   { --appt-accent: #4ade80; --appt-bg: #14532d; --appt-ink: #dcfce7; }
    :root:not(.theme-light) .appt--colour-olive   { --appt-accent: #a3e635; --appt-bg: #365314; --appt-ink: #ecfccb; }
    :root:not(.theme-light) .appt--colour-slate   { --appt-accent: #94a3b8; --appt-bg: #1e293b; --appt-ink: #e2e8f0; }
    :root:not(.theme-light) .appt--colour-brown   { --appt-accent: #d97706; --appt-bg: #7c2d12; --appt-ink: #fed7aa; }
    :root:not(.theme-light) .appt--colour-other   { --appt-accent: #9ca3af; --appt-bg: #374151; --appt-ink: #e5e7eb; }
}
/* Explicit dark mode class override (for when user picks Dark in the UI) */
:root.theme-dark .appt--colour-teal    { --appt-accent: #2dd4bf; --appt-bg: #134e4a; --appt-ink: #ccfbf1; }
:root.theme-dark .appt--colour-blue    { --appt-accent: #60a5fa; --appt-bg: #1e3a8a; --appt-ink: #dbeafe; }
:root.theme-dark .appt--colour-indigo  { --appt-accent: #818cf8; --appt-bg: #312e81; --appt-ink: #e0e7ff; }
:root.theme-dark .appt--colour-purple  { --appt-accent: #c084fc; --appt-bg: #581c87; --appt-ink: #f3e8ff; }
:root.theme-dark .appt--colour-pink    { --appt-accent: #f472b6; --appt-bg: #831843; --appt-ink: #fce7f3; }
:root.theme-dark .appt--colour-rose    { --appt-accent: #fb7185; --appt-bg: #881337; --appt-ink: #ffe4e6; }
:root.theme-dark .appt--colour-green   { --appt-accent: #4ade80; --appt-bg: #14532d; --appt-ink: #dcfce7; }
:root.theme-dark .appt--colour-olive   { --appt-accent: #a3e635; --appt-bg: #365314; --appt-ink: #ecfccb; }
:root.theme-dark .appt--colour-slate   { --appt-accent: #94a3b8; --appt-bg: #1e293b; --appt-ink: #e2e8f0; }
:root.theme-dark .appt--colour-brown   { --appt-accent: #d97706; --appt-bg: #7c2d12; --appt-ink: #fed7aa; }
:root.theme-dark .appt--colour-other   { --appt-accent: #9ca3af; --appt-bg: #374151; --appt-ink: #e5e7eb; }

/* Apply the custom properties to the actual appointment visuals */
.appt[class*="appt--colour-"] {
    background: var(--appt-bg) !important;
    border-left-color: var(--appt-accent) !important;
    color: var(--appt-ink) !important;
}
.appt[class*="appt--colour-"] .appt-time,
.appt[class*="appt--colour-"] .appt-title,
.appt[class*="appt--colour-"] .appt-loc {
    color: var(--appt-ink) !important;
}
.appt-pill[class*="appt--colour-"] {
    background: var(--appt-bg) !important;
    color: var(--appt-ink) !important;
    border-left: 2px solid var(--appt-accent);
}
.appt-compact[class*="appt--colour-"] {
    background: var(--appt-bg) !important;
    color: var(--appt-ink) !important;
    border-left: 3px solid var(--appt-accent);
}
.appt-allday[class*="appt--colour-"] {
    background: var(--appt-bg) !important;
    color: var(--appt-ink) !important;
    border-left: 3px solid var(--appt-accent);
}

/* Dashboard appointment rows: left-border colour stripe */
.dash-appt-row[class*="appt--colour-"] {
    border-left: 3px solid var(--appt-accent);
    border-radius: 4px;
    padding-left: 6px;
    background: linear-gradient(to right, var(--appt-bg) 0%, transparent 60%);
}
.dash-appt-row[class*="appt--colour-"] .dash-appt-time {
    color: var(--appt-accent);
    font-weight: 600;
}

/* ============ SHARED-OUT appointments (mine, but with invitees) ============
   Solid green block with white text, clearly distinct from the amber accent
   used for private self-appointments.
*/
.appt--shared-out { --appt-accent: #4d7c0f; --appt-bg: #65a30d; --appt-ink: #ffffff; }
:root.theme-dark .appt--shared-out { --appt-accent: #4d7c0f; --appt-bg: #65a30d; --appt-ink: #ffffff; }
@media (prefers-color-scheme: dark) {
    :root:not(.theme-light) .appt--shared-out { --appt-accent: #4d7c0f; --appt-bg: #65a30d; --appt-ink: #ffffff; }
}

/* Apply the CSS custom properties to shared-out appointments too */
.appt.appt--shared-out {
    background: var(--appt-bg) !important;
    border-left-color: var(--appt-accent) !important;
    color: var(--appt-ink) !important;
}
.appt.appt--shared-out .appt-time,
.appt.appt--shared-out .appt-title,
.appt.appt--shared-out .appt-loc {
    color: var(--appt-ink) !important;
}
.appt-pill.appt--shared-out {
    background: var(--appt-bg) !important;
    color: var(--appt-ink) !important;
    border-left: 2px solid var(--appt-accent);
}
.appt-compact.appt--shared-out {
    background: var(--appt-bg) !important;
    color: var(--appt-ink) !important;
    border-left: 3px solid var(--appt-accent);
}
.appt-allday.appt--shared-out {
    background: var(--appt-bg) !important;
    color: var(--appt-ink) !important;
    border-left: 3px solid var(--appt-accent);
}
.dash-appt-row.appt--shared-out {
    border-left: 3px solid var(--appt-accent);
    border-radius: 4px;
    padding-left: 6px;
    background: linear-gradient(to right, var(--appt-bg) 0%, transparent 60%);
}
.dash-appt-row.appt--shared-out .dash-appt-time {
    color: var(--appt-accent);
    font-weight: 600;
}

/* Shared-in appointment pill on the dashboard */
.dash-appt-shared {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 500;
    background: var(--appt-bg, var(--accent-soft));
    color: var(--appt-ink, var(--accent-ink));
    border-radius: 999px;
    vertical-align: middle;
    white-space: nowrap;
}
