/* ═══════════════════════════════════════════════════════
   RescueKeeper — Sanctuary Design System
   ═══════════════════════════════════════════════════════ */

/* ─── Fonts ────────────────────────────────────────────── */
@font-face {
    font-family: 'Lora';
    font-style: normal; font-weight: 600; font-display: swap;
    src: url('/fonts/lora-600.woff2') format('woff2');
}
@font-face {
    font-family: 'Lora';
    font-style: normal; font-weight: 700; font-display: swap;
    src: url('/fonts/lora-700.woff2') format('woff2');
}
@font-face {
    font-family: 'DM Sans';
    font-style: normal; font-weight: 400; font-display: swap;
    src: url('/fonts/dm-sans-400.woff2') format('woff2');
}
@font-face {
    font-family: 'DM Sans';
    font-style: normal; font-weight: 500; font-display: swap;
    src: url('/fonts/dm-sans-500.woff2') format('woff2');
}
@font-face {
    font-family: 'DM Sans';
    font-style: normal; font-weight: 600; font-display: swap;
    src: url('/fonts/dm-sans-600.woff2') format('woff2');
}
@font-face {
    font-family: 'DM Mono';
    font-style: normal; font-weight: 400; font-display: swap;
    src: url('/fonts/dm-mono-400.woff2') format('woff2');
}

/* ─── Design Tokens ─────────────────────────────────────── */
:root {
    --bg:              #f5f7fa;
    --surface:         #ffffff;
    --surface-2:       #f1f4f8;
    --border:          #e2e8f0;
    --text-primary:    #1e293b;
    --text-muted:      #64748b;
    --accent:          #c1440e;
    --accent-hover:    #a33a0c;
    --accent-subtle:   rgba(193,68,14,0.08);
    --accent-2:        #5a7a4a;
    --accent-gold:     #b8860b;
    --nav-bg:          #2d1f0f;
    --nav-text:        #f0e8dc;
    --nav-active:      #e8622a;
    --danger:          #dc2626;
    --danger-light:    #fca5a5;
    --success:         #22c55e;
    --warning:         #d97706;
    --info:            #0891b2;
}

html.dark {
    --bg:              #0f172a;
    --surface:         #1e293b;
    --surface-2:       #334155;
    --border:          #475569;
    --text-primary:    #f1f5f9;
    --text-muted:      #94a3b8;
    --accent:          #e8622a;
    --accent-hover:    #d45520;
    --accent-subtle:   rgba(232,98,42,0.12);
    --accent-2:        #7aaa5a;
    --accent-gold:     #d4a017;
    --nav-bg:          #110d06;
    --nav-text:        #f0e8dc;
    --nav-active:      #e8622a;
    --danger:          #f87171;
    --danger-light:    #fca5a5;
    --success:         #4ade80;
    --warning:         #fbbf24;
    --info:            #38bdf8;
}

/* ─── Base ───────────────────────────────────────────────── */
html {
    background: var(--bg);
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
body {
    font-family: 'DM Sans', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
.rk-scroll-x::-webkit-scrollbar { display: none; }
.rk-scroll-x { -ms-overflow-style: none; scrollbar-width: none; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ─── Accent Themes ──────────────────────────────────────── */
/* All themes share the default orange accent/highlights — only nav-bg,
   surface colours and text colours vary per theme.                     */
html[data-theme="ocean"] {
    --nav-bg: #0c1845;
    --bg: #f0f7ff; --surface: #ffffff; --surface-2: #ddeeff; --border: #bae0fd;
    --text-primary: #0c2340; --text-muted: #3a6a9a;
}
html.dark[data-theme="ocean"] {
    --nav-bg: #060e2b;
    --bg: #0a1628; --surface: #0d1f38; --surface-2: #162d4f; --border: #1e4a78;
    --text-primary: #e0f0ff; --text-muted: #6aaed6;
}
html[data-theme="forest"] {
    --nav-bg: #0f2318;
    --bg: #f0fdf5; --surface: #ffffff; --surface-2: #d8f9e6; --border: #bbf7ce;
    --text-primary: #0d2b14; --text-muted: #3a7a52;
}
html.dark[data-theme="forest"] {
    --nav-bg: #060f0c;
    --bg: #071812; --surface: #0c2419; --surface-2: #143322; --border: #1c5230;
    --text-primary: #dcfce7; --text-muted: #5aaa72;
}
html[data-theme="sunset"] {
    --nav-bg: #1a100a;
    --bg: #fff7f0; --surface: #ffffff; --surface-2: #ffeedd; --border: #fcc89a;
    --text-primary: #3a1a08; --text-muted: #8a4a20;
}
html.dark[data-theme="sunset"] {
    --nav-bg: #0d0805;
    --bg: #1a0e05; --surface: #251508; --surface-2: #32200f; --border: #50331a;
    --text-primary: #fff0e4; --text-muted: #b07040;
}
html[data-theme="plum"] {
    --nav-bg: #150d24;
    --bg: #faf5ff; --surface: #ffffff; --surface-2: #f0e4ff; --border: #e0c8ff;
    --text-primary: #2a0d4a; --text-muted: #7a40aa;
}
html.dark[data-theme="plum"] {
    --nav-bg: #0b0813;
    --bg: #130920; --surface: #1c0f30; --surface-2: #2a1545; --border: #451d6b;
    --text-primary: #f3e8ff; --text-muted: #aa70dd;
}
html[data-theme="slate"] {
    --nav-bg: #1e293b;
    --bg: #f4f6f8; --surface: #ffffff; --surface-2: #e8ecf0; --border: #cbd5e1;
    --text-primary: #0f172a; --text-muted: #64748b;
}
html.dark[data-theme="slate"] {
    --nav-bg: #0f172a;
    --bg: #0d1117; --surface: #161b22; --surface-2: #21262d; --border: #30363d;
    --text-primary: #e6edf3; --text-muted: #8b949e;
}

/* ─── UI Scale ───────────────────────────────────────────── */
/* zoom is applied directly to <html> via JS so the browser treats it like
   native zoom — content stays within the viewport and scrolls naturally */

/* ─── Colourblind Mode ───────────────────────────────────── */
html[data-rk-a11y="colorblind"] {
    --accent:       #0066cc;
    --accent-hover: #0052a3;
    --accent-2:     #0088aa;
    --nav-active:   #4da6ff;
}
html.dark[data-rk-a11y="colorblind"] {
    --accent:       #4da6ff;
    --accent-hover: #3399ff;
    --nav-active:   #66b3ff;
}
html[data-rk-a11y="colorblind"] .rk-badge-available {
    background: #dde8ff; color: #003399;
    outline: 2px solid #003399; outline-offset: -1px;
}
html[data-rk-a11y="colorblind"] .rk-badge-unavailable {
    background: #fff0d4; color: #7a4400;
    outline: 2px solid #7a4400; outline-offset: -1px;
}
html[data-rk-a11y="colorblind"] .rk-badge-foster {
    background: #d4eeff; color: #004d7a;
    outline: 2px solid #004d7a; outline-offset: -1px;
}
html[data-rk-a11y="colorblind"] .bg-red-600,
html[data-rk-a11y="colorblind"] .bg-danger { background-color: #0066cc; }
html[data-rk-a11y="colorblind"] .text-red-600,
html[data-rk-a11y="colorblind"] .text-red-500,
html[data-rk-a11y="colorblind"] .text-red-400 { color: #cc6600; }
html[data-rk-a11y="colorblind"] .rk-nav-badge { background: #0066cc; }

/* ─── Shell Layout ─────────────────────────────────────── */
.rk-root {
    background: var(--bg);
    color: var(--text-primary);
    font-family: 'DM Sans', system-ui, sans-serif;
}

.rk-shell {
    display: flex;
    flex-direction: row;
    height: calc(100vh / var(--ui-scale, 1));
    overflow: hidden;
}

.rk-main {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* ─── Sidebar ────────────────────────────────────────────── */
.rk-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--nav-bg);
    color: var(--nav-text);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.2s ease;
    z-index: 40;
}
.rk-sidebar--collapsed { width: 64px; }

.rk-sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 16px 14px;
    cursor: pointer;
    opacity: 0.9;
    flex-shrink: 0;
}
.rk-sidebar-brand:hover { opacity: 1; }
.rk-sidebar--collapsed .rk-sidebar-brand { align-items: center; }

.rk-sidebar-logo {
    width: 36px; height: 36px;
    object-fit: contain; border-radius: 8px; flex-shrink: 0;
}

.rk-sidebar-brand-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.rk-sidebar-brand-name {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
    color: var(--nav-text);
    white-space: normal;
    word-break: break-word;
    line-height: 1.25;
    text-align: center;
}

.rk-sidebar-brand-powered {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.6rem;
    font-weight: 400;
    color: var(--nav-text);
    opacity: 0.45;
    white-space: nowrap;
    overflow: hidden;
    letter-spacing: 0.02em;
    text-transform: lowercase;
}

.rk-sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 4px 8px;
    gap: 2px;
    overflow-y: auto;
}

.rk-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--nav-text);
    opacity: 0.7;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: 'DM Sans', sans-serif;
    transition: background 0.12s, opacity 0.12s;
    text-align: left;
    width: 100%;
    position: relative;
    border-left: 3px solid transparent;
}
.rk-nav-item:hover { background: rgba(255,255,255,0.08); opacity: 1; }
.rk-nav-item--active {
    background: rgba(255,255,255,0.12);
    opacity: 1;
    border-left-color: var(--nav-active);
}
.rk-nav-item--spotlight { /* same look as regular items — position in section provides the separation */ }
.rk-nav-item--collapsed { justify-content: center; padding-left: 10px; }

.rk-nav-label { white-space: nowrap; overflow: hidden; flex: 1; }

.rk-nav-badge {
    position: absolute;
    top: 4px; right: 6px;
    min-width: 18px; height: 18px;
    background: var(--danger);
    color: white;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    pointer-events: none;
}

.rk-sidebar-section-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 6px 10px;
}

.rk-sidebar-collapse {
    margin: 4px 8px 0;
    padding: 7px;
    border-radius: 6px;
    border: none;
    background: rgba(255,255,255,0.05);
    color: var(--nav-text);
    opacity: 0.45;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.rk-sidebar-collapse:hover { opacity: 1; background: rgba(255,255,255,0.1); }

.rk-sidebar-footer {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px;
    border-top: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}
.rk-sidebar-footer--collapsed {
    flex-direction: column;
    padding: 8px 6px;
    justify-content: center;
}

.rk-sidebar-username {
    flex: 1;
    font-size: 0.78rem;
    opacity: 0.65;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rk-sidebar-footer-btn {
    padding: 6px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--nav-text);
    opacity: 0.55;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.12s, background 0.12s;
}
.rk-sidebar-footer-btn:hover { opacity: 1; background: rgba(255,255,255,0.1); }
.rk-sidebar-footer-btn--danger { color: var(--danger); opacity: 0.75; }
.rk-sidebar-footer-btn--danger:hover { color: var(--danger-light); opacity: 1; background: rgba(220,38,38,0.12); }

/* ─── Mobile bottom bar ──────────────────────────────────── */
:root { --rk-bottom-bar-h: 56px; }

.rk-bottom-bar {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--rk-bottom-bar-h);
    background: var(--nav-bg);
    border-top: 1px solid rgba(255,255,255,0.1);
    z-index: 50;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.rk-bottom-bar::-webkit-scrollbar { display: none; }

.rk-bottom-btn {
    flex: 0 0 auto;
    min-width: 58px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    border: none;
    background: transparent;
    color: var(--nav-text);
    opacity: 0.55;
    cursor: pointer;
    font-size: 0.62rem;
    font-family: 'DM Sans', sans-serif;
    gap: 2px;
    transition: opacity 0.12s;
    white-space: nowrap;
}
.rk-bottom-btn--active { opacity: 1; color: var(--nav-active); }
.rk-bottom-btn--danger { color: #f87171; }
.rk-bottom-btn:hover { opacity: 0.9; }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 1023px) {
    .rk-sidebar { width: 64px; }
    .rk-sidebar--collapsed { width: 64px; }
    .rk-sidebar-brand-name,
    .rk-nav-label,
    .rk-sidebar-username,
    .rk-sidebar-collapse { display: none; }
    .rk-nav-item { justify-content: center; padding: 10px; border-left-color: transparent; }
    .rk-nav-item--active { background: rgba(255,255,255,0.14); }
    .rk-nav-item--active::after {
        content: '';
        position: absolute;
        left: 0; top: 25%; bottom: 25%;
        width: 3px;
        background: var(--nav-active);
        border-radius: 0 3px 3px 0;
    }
    .rk-sidebar-footer { justify-content: center; flex-direction: column; padding: 8px 6px; }
}

@media (max-width: 767px) {
    .rk-sidebar { display: none; }
    .rk-bottom-bar { display: flex; }
    .rk-main { padding-bottom: var(--rk-bottom-bar-h); }
    .rk-alpha-bar { height: calc((100vh - var(--rk-bottom-bar-h)) / var(--ui-scale, 1)); }
}

/* ─── Pulsing border for status banners ─────────────────── */
@keyframes rk-border-pulse {
    0%, 100% { border-color: var(--pulse-colour); }
    50%       { border-color: transparent; }
}
.rk-status-banner {
    border: 2px solid var(--pulse-colour, currentColor);
    animation: rk-border-pulse 2.2s ease-in-out infinite;
}

/* ─── Banners ─────────────────────────────────────────────── */
.rk-banner {
    display: flex; align-items: center; justify-content: center;
    gap: 8px; padding: 8px 16px;
    font-size: 0.85rem; font-weight: 500;
    text-align: center; flex-shrink: 0;
}
.rk-banner-offline { background: var(--warning); color: white; }
.rk-banner-queue   { background: var(--accent); color: white; }
.rk-banner-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    border: none; border-radius: 20px;
    padding: 2px 12px; font-size: 0.78rem; font-weight: 700;
    cursor: pointer;
}
.rk-banner-btn:hover { background: rgba(255,255,255,0.3); }

/* ─── Animal Cards ─────────────────────────────────────────── */
.rk-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
    padding: 16px;
}

.rk-alpha-header {
    grid-column: 1 / -1;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    padding: 10px 4px 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: -4px;
}
.rk-alpha-header:first-child { padding-top: 4px; }

.rk-alpha-bar {
    flex-shrink: 0;
    width: 22px;
    position: sticky;
    top: 0;
    height: calc(100vh / var(--ui-scale, 1));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
    z-index: 5;
    user-select: none;
    touch-action: none;
}

.rk-alpha-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    min-height: 14px;
    flex-shrink: 0;
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    font-family: 'DM Sans', sans-serif;
    transition: color 0.1s, background 0.1s;
    padding: 0;
    line-height: 1;
}
.rk-alpha-btn:hover {
    color: var(--accent);
    background: var(--accent-subtle);
}

.rk-animal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    flex-direction: column;
}
.rk-animal-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.10);
}
html.dark .rk-animal-card:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.rk-card-photo {
    position: relative;
    height: 176px;
    background: var(--surface-2);
    overflow: hidden;
    flex-shrink: 0;
}

.rk-card-img {
    width: 100%; height: 100%;
    object-fit: cover;
    transform: scale(var(--focal-zoom, 1));
    transform-origin: 50% 50%;
    transition: transform 0.4s ease;
}
.rk-animal-card:hover .rk-card-img { transform: scale(var(--focal-zoom, 1)) scale(1.04); }

.rk-card-no-photo {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(145deg, var(--surface-2) 0%, var(--bg) 100%);
}
.rk-card-emoji { font-size: 3.5rem; opacity: 0.55; user-select: none; }

.rk-badge {
    position: absolute;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    font-family: 'DM Sans', sans-serif;
    letter-spacing: 0.01em;
    white-space: nowrap;
}
.rk-badge-status-pos    { top: 10px; right: 10px; text-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.rk-badge-available     { background: var(--success); color: white; }
.rk-badge-unavailable   { background: var(--accent); color: white; }
.rk-badge-foster        { background: var(--info); color: white; }
.rk-badge-medical       { background: var(--warning); color: white; }
.rk-badge-deceased      { background: rgba(71,85,105,0.85); color: white; }
.rk-badge-adopted       { background: #7c3aed; color: white; }
.rk-badge-released      { background: #0d9488; color: white; }
.rk-badge-transferred   { background: #b45309; color: white; }
.rk-badge-med           { bottom: 10px; left: 10px; background: var(--accent); color: white; opacity: 0.92; }
.rk-badge-pipeline      { bottom: 10px; right: 10px; background: rgba(15,23,42,0.80); color: var(--nav-text); }
.rk-badge-notlisted     { bottom: 10px; right: 10px; background: var(--accent-gold); color: white; }

.rk-card-body {
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.rk-card-name {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-weight: 600;
    font-size: 1.0rem;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rk-card-meta {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}

.rk-species-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 8px; border-radius: 12px;
    font-size: 0.72rem; font-weight: 500;
    white-space: nowrap;
}
.rk-species-dot {
    width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}

.rk-days-in {
    font-family: 'DM Mono', monospace;
    font-size: 0.7rem; color: var(--text-muted);
}

.rk-location-tag {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(90,122,74,0.14);
    color: var(--accent-2);
    border-radius: 10px;
    font-size: 0.7rem; font-weight: 500;
}
html.dark .rk-location-tag { background: rgba(122,170,90,0.15); }

/* ─── Filter Bar ──────────────────────────────────────────── */
.rk-filter-bar {
    padding: 16px 16px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rk-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.rk-search-wrap {
    position: relative;
    flex: 1;
    min-width: 180px;
}
.rk-search-icon {
    position: absolute; left: 10px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.rk-search-input {
    width: 100%;
    padding: 8px 32px 8px 34px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s;
}
.rk-search-input::placeholder { color: var(--text-muted); font-family: 'DM Mono', monospace; font-size: 0.8rem; }
.rk-search-input:focus { border-color: var(--accent); }
.rk-search-clear {
    position: absolute; right: 8px; top: 50%;
    transform: translateY(-50%);
    background: none; border: none;
    color: var(--text-muted); cursor: pointer; padding: 2px;
    border-radius: 4px;
}
.rk-search-clear:hover { color: var(--text-primary); }

.rk-filter-select {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s;
}
.rk-filter-select:focus { border-color: var(--accent); }

.rk-filter-more-btn {
    display: flex; align-items: center; gap: 5px;
    padding: 7px 11px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-muted);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8rem; font-weight: 500;
    cursor: pointer; transition: all 0.15s;
    white-space: nowrap;
}
.rk-filter-more-btn:hover { border-color: var(--accent); color: var(--accent); }
.rk-filter-more-btn--active { border-color: var(--accent); color: var(--accent); background: var(--accent-subtle); }

.rk-filter-actions {
    display: flex; align-items: center; gap: 6px; margin-left: auto;
}

.rk-btn-primary {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    background: var(--accent);
    color: white;
    border: none; border-radius: 10px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem; font-weight: 600;
    cursor: pointer; transition: background 0.15s;
    white-space: nowrap;
}
.rk-btn-primary:hover { background: var(--accent-hover); }

.rk-btn-secondary {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 13px;
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem; font-weight: 500;
    cursor: pointer; transition: all 0.15s;
    white-space: nowrap;
}
.rk-btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.rk-clear-filters {
    background: none; border: none;
    color: var(--text-muted); font-size: 0.8rem;
    cursor: pointer; padding: 4px 6px; border-radius: 6px;
    font-family: 'DM Sans', sans-serif;
    white-space: nowrap;
}
.rk-clear-filters:hover { color: var(--accent); }

.rk-filter-expanded {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.rk-filter-toggles {
    display: flex; flex-wrap: wrap; gap: 6px; width: 100%;
}

.rk-filter-toggle {
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    color: var(--text-muted);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.78rem; font-weight: 500;
    cursor: pointer; transition: all 0.12s;
}
.rk-filter-toggle:hover { border-color: var(--accent); color: var(--accent); }
.rk-filter-toggle.active {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}
.rk-filter-toggle--danger.active {
    background: rgba(220,38,38,0.08);
    border-color: var(--danger);
    color: var(--danger);
}

/* ─── Modals — stronger backdrop and panel contrast ─────── */
html .bg-black\/50 { background-color: rgba(0,0,0,0.68); }
html .backdrop-blur-sm { backdrop-filter: none; }
html .shadow-2xl {
    box-shadow: 0 24px 72px rgba(0,0,0,0.45), 0 0 0 1px rgba(255,255,255,0.06);
}

/* ─── Loading Screen ─────────────────────────────────────── */
#app-loading {
    position: fixed; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: var(--bg, #f5f7fa);
    z-index: 9999;
    transition: opacity 0.3s ease;
}
html.dark #app-loading { background: var(--bg, #0f172a); }

.ld-logo {
    font-family: 'Lora', Georgia, serif;
    font-size: 1.8rem; font-weight: 700;
    color: var(--accent, #c1440e);
    letter-spacing: -0.01em;
    margin-bottom: 2.5rem;
}

.ld-scene {
    position: relative; width: 300px; height: 100px;
    margin-bottom: 1.5rem; overflow: hidden;
}
.ld-wrap { position: absolute; bottom: 20px; left: -3rem; }
.ld-emoji { display: block; font-size: 2.2rem; line-height: 1; user-select: none; }
.ld-msg { font-size: 0.875rem; color: var(--text-muted, #8a6f5a); letter-spacing: 0.01em; }

/* Paw prints */
.ld-trail {
    position: absolute; bottom: 16px; left: 0; right: 0;
    display: flex; gap: 6px; justify-content: center; align-items: flex-end;
}
.ld-trail span {
    font-size: 1.35rem; opacity: 0;
    animation: ld-pawprint 1.4s ease-in-out infinite both;
}
@keyframes ld-pawprint {
    0%, 100%  { opacity: 0; transform: scale(0.4) translateY(6px); }
    18%, 60%  { opacity: 1; transform: scale(1) translateY(0); }
    85%       { opacity: 0; transform: scale(0.7) translateY(-2px); }
}

/* Water ripples */
.ld-water {
    display: none; position: absolute; bottom: 14px; left: 0; right: 0;
    justify-content: center; gap: 5px; align-items: center;
}
.ld-water span {
    display: block; width: 26px; height: 9px;
    border: 2px solid var(--accent, #c1440e); border-top: none;
    border-radius: 0 0 26px 26px; opacity: 0;
    animation: ld-ripple 1.4s ease-in-out infinite both;
}
@keyframes ld-ripple {
    0%, 100% { opacity: 0; transform: scaleX(0.3); }
    35%, 65% { opacity: 0.9; transform: scaleX(1); }
}

/* Run */
@keyframes ld-run-x { from { left: -3rem; } to { left: calc(100% + 1rem); } }
@keyframes ld-run-y {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-11px); }
}
.ld-run .ld-wrap  { animation: ld-run-x 1.1s linear infinite; }
.ld-run .ld-emoji { animation: ld-run-y 0.22s ease-in-out infinite; }

/* Swim */
@keyframes ld-drift { from { left: -3rem; } to { left: calc(100% + 1rem); } }
@keyframes ld-sway {
    from { transform: rotate(-9deg) translateY(0); }
    to   { transform: rotate(9deg) translateY(-5px); }
}
.ld-swim .ld-wrap  { animation: ld-drift 2.0s ease-in-out infinite; bottom: 34px; }
.ld-swim .ld-emoji { animation: ld-sway 0.6s ease-in-out infinite alternate; }
.ld-swim .ld-water { display: flex; }

/* Saunter */
@keyframes ld-saunter {
    0%       { left: -3rem;  animation-timing-function: ease-out; }
    38%, 55% { left: 38%;   animation-timing-function: ease-in; }
    100%     { left: calc(100% + 1rem); }
}
@keyframes ld-tailflick {
    0%, 100% { transform: rotate(0deg) translateY(0); }
    30%      { transform: rotate(-5deg) translateY(-1px); }
    70%      { transform: rotate(5deg) translateY(-1px); }
}
.ld-saunter .ld-wrap  { animation: ld-saunter 2.6s linear infinite; }
.ld-saunter .ld-emoji { animation: ld-tailflick 0.8s ease-in-out infinite; }

/* Zoom */
.ld-zoom .ld-wrap  { animation: ld-run-x 0.4s linear infinite; }
.ld-zoom .ld-emoji { animation: ld-run-y 0.09s ease-in-out infinite; }

/* Spin */
@keyframes ld-spin-around { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.ld-spin .ld-wrap  { left: 50%; bottom: 18px; transform: translateX(-50%); }
.ld-spin .ld-emoji { animation: ld-spin-around 0.5s linear infinite; }

/* Slither */
@keyframes ld-slither-x { from { left: -3rem; } to { left: calc(100% + 1rem); } }
@keyframes ld-slither-y {
    0%   { transform: translateY(0); }   25% { transform: translateY(-13px); }
    50%  { transform: translateY(0); }   75% { transform: translateY(13px); }
    100% { transform: translateY(0); }
}
.ld-slither .ld-wrap  { animation: ld-slither-x 1.8s linear infinite; }
.ld-slither .ld-emoji { animation: ld-slither-y 0.38s ease-in-out infinite; }

/* Swoop */
@keyframes ld-swoop-x {
    0%       { left: calc(100% + 2rem); animation-timing-function: ease-out; }
    35%, 65% { left: 43%;              animation-timing-function: ease-in; }
    100%     { left: -3rem; }
}
@keyframes ld-owl-look {
    0%, 100% { transform: rotate(0deg)   translateY(0); }
    20%      { transform: rotate(-14deg) translateY(-4px); }
    45%      { transform: rotate(14deg)  translateY(-4px); }
    70%      { transform: rotate(-10deg) translateY(-2px); }
    85%      { transform: rotate(6deg)   translateY(0); }
}
.ld-swoop .ld-wrap  { animation: ld-swoop-x 2.8s linear infinite; }
.ld-swoop .ld-emoji { animation: ld-owl-look 1.5s ease-in-out infinite; }

/* Hop */
@keyframes ld-hop-x { from { left: -3rem; } to { left: calc(100% + 1rem); } }
@keyframes ld-hop-y {
    0%        { transform: translateY(0);     animation-timing-function: ease-out; }
    9%        { transform: translateY(-36px); animation-timing-function: ease-in; }
    18%       { transform: translateY(0);     animation-timing-function: ease-out; }
    27%       { transform: translateY(-22px); animation-timing-function: ease-in; }
    36%       { transform: translateY(0);     animation-timing-function: ease-out; }
    43%       { transform: translateY(-10px); animation-timing-function: ease-in; }
    50%, 100% { transform: translateY(0); }
}
.ld-hop .ld-wrap  { animation: ld-hop-x 1.4s linear infinite; }
.ld-hop .ld-emoji { animation: ld-hop-y 1.4s linear infinite; }

/* ─── Token utilities for view files ────────────────────── */
/* Panels / cards */
.rk-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.rk-panel-header {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

/* Form elements */
.rk-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s;
}
.rk-input:focus { border-color: var(--accent); }
.rk-input::placeholder { color: var(--text-muted); }
.rk-input:disabled { opacity: 0.5; cursor: not-allowed; }
.rk-input-sm {
    padding: 5px 10px;
    font-size: 0.8rem;
    border-radius: 7px;
}

.rk-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

/* Table / list rows */
.rk-row {
    border-bottom: 1px solid var(--border);
}
.rk-row:hover { background: var(--surface-2); }
.rk-row:last-child { border-bottom: none; }

/* Spinner */
.rk-spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: rk-spin 0.7s linear infinite;
    flex-shrink: 0;
}
.rk-spinner-sm {
    width: 20px; height: 20px;
    border-width: 2px;
}
@keyframes rk-spin { to { transform: rotate(360deg); } }

/* Tag / chip */
.rk-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 10px;
    background: var(--surface-2);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.75rem; font-weight: 500;
}

/* Danger / success / warning inline text helpers */
.rk-text-danger  { color: var(--danger); }
.rk-text-success { color: var(--success); }
.rk-text-warn    { color: var(--warning); }
.rk-text-info    { color: var(--info); }
.rk-text-accent  { color: var(--accent); }
.rk-text-muted   { color: var(--text-muted); }

/* Subtle info / warning / danger boxes */
.rk-callout {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
}
.rk-callout-warn    { background: rgba(217,119,6,0.1);  border: 1px solid rgba(217,119,6,0.25);  color: var(--text-primary); }
.rk-callout-danger  { background: rgba(220,38,38,0.08); border: 1px solid rgba(220,38,38,0.2);   color: var(--text-primary); }
.rk-callout-info    { background: rgba(8,145,178,0.08); border: 1px solid rgba(8,145,178,0.2);   color: var(--text-primary); }
.rk-callout-success { background: rgba(34,197,94,0.1);  border: 1px solid rgba(34,197,94,0.25);  color: var(--text-primary); }
.rk-callout-accent  { background: var(--accent-subtle); border: 1px solid var(--accent);         color: var(--text-primary); }

/* Danger button */
.rk-btn-danger {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    background: var(--danger);
    color: white;
    border: none; border-radius: 10px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem; font-weight: 600;
    cursor: pointer; transition: opacity 0.15s;
    white-space: nowrap;
}
.rk-btn-danger:hover { opacity: 0.85; }

/* Ghost / text button */
.rk-btn-ghost {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 10px;
    background: none;
    color: var(--text-muted);
    border: none; border-radius: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    cursor: pointer; transition: color 0.12s, background 0.12s;
}
.rk-btn-ghost:hover { color: var(--text-primary); background: var(--surface-2); }

/* ─── Print: Medication Sheet ────────────────────────────── */
@media print {
    body * { visibility: hidden !important; }
    body { background: white !important; }
    .rk-print-sheet, .rk-print-sheet * { visibility: visible !important; }
    .rk-no-print { display: none !important; }
    .rk-print-sheet {
        position: absolute !important; inset: 0 !important;
        background: white !important; color: black !important;
        padding: 24px !important; border: none !important;
        border-radius: 0 !important; overflow: visible !important;
    }
    /* Override dark-mode theme colours within any print area */
    .rk-print-sheet .bg-surface,
    .rk-print-sheet .bg-surface2 { background-color: #f8fafc !important; }
    .rk-print-sheet .text-ink   { color: #0f172a !important; }
    .rk-print-sheet .text-faded { color: #64748b !important; }
    .rk-print-sheet .border-rim { border-color: #e2e8f0 !important; }
    .rk-print-sheet .divide-rim > * + * { border-color: #e2e8f0 !important; }
}
