/* ============================================================
   BASE — design tokens, reset, typography, shared components
   TravelPad design language: "field guide, not dashboard".
   Warm paper, deep forest, campfire amber. Everything springs.
   ============================================================ */

/* Fonts load via <link> + preconnect in each page's <head> (no CSS @import chain). */

/* --- Design tokens --- */
:root {
    /* Greens — deep forest, richer + moodier than before */
    --green-950: #0e2015;
    --green-900: #1a3425;
    --green-850: #21422e;
    --green-800: #2a5339;
    --green-700: #3e7a54;   /* primary */
    --green-600: #529068;
    --green-300: #8cc7a1;
    --green-200: #b5ddc4;
    --green-100: #d8efe1;
    --green-50:  #eef8f2;

    /* Warm neutrals — sun-bleached paper */
    --brown-900: #26200f;
    --brown-700: #4c3e29;
    --brown-500: #786751;
    --brown-300: #bda887;
    --cream-300: #dbcfb7;
    --cream-200: #efe7d5;
    --cream-100: #f8f3e8;
    --cream-50:  #fefcf7;

    /* Campfire amber — the reward / delight accent */
    --sun-600: #c26a25;
    --sun-500: #e0862f;
    --sun-400: #f2a854;
    --sun-100: #fcefdc;
    --sun-50:  #fef8ee;

    /* Semantic aliases */
    --color-primary:        var(--green-700);
    --color-primary-dark:   var(--green-800);
    --color-primary-light:  var(--green-100);
    --color-accent:         var(--sun-500);
    --color-accent-deep:    var(--sun-600);
    --color-accent-soft:    var(--sun-100);
    --color-bg:             var(--cream-100);
    --color-surface:        var(--cream-50);
    --color-text:           var(--brown-900);
    --color-text-muted:     var(--brown-500);
    --color-border:         var(--cream-300);
    --color-border-soft:    var(--cream-200);
    --color-border-focus:   var(--green-700);
    --color-error:          #93312d;
    --color-error-bg:       #fdf1ef;
    --color-success:        var(--green-700);
    --color-success-bg:     #edf7f0;
    --color-success-border: #b8dfc4;

    /* Shape */
    --radius-sm:  9px;
    --radius-md:  13px;
    --radius-lg:  18px;
    --radius-xl:  26px;

    /* Elevation — layered, warm-tinted, never gray */
    --shadow-xs:  0 1px 2px rgba(38, 32, 15, 0.06);
    --shadow-sm:  0 1px 2px rgba(38, 32, 15, 0.05), 0 2px 6px rgba(38, 32, 15, 0.05);
    --shadow-md:  0 2px 4px rgba(38, 32, 15, 0.05), 0 6px 16px rgba(38, 32, 15, 0.07), 0 12px 32px rgba(38, 32, 15, 0.05);
    --shadow-lg:  0 4px 10px rgba(38, 32, 15, 0.06), 0 16px 40px rgba(38, 32, 15, 0.12), 0 30px 80px rgba(38, 32, 15, 0.10);
    --shadow-primary: 0 3px 8px rgba(42, 83, 57, 0.22), 0 8px 24px rgba(42, 83, 57, 0.26);
    --shadow-accent:  0 3px 8px rgba(194, 106, 37, 0.20), 0 8px 24px rgba(194, 106, 37, 0.24);
    --ring-primary: 0 0 0 3.5px rgba(62, 122, 84, 0.18);
    --ring-accent:  0 0 0 3.5px rgba(224, 134, 47, 0.22);

    /* Motion — springs first, fades last */
    --ease-out:         cubic-bezier(0.22, 1, 0.36, 1);
    --ease-spring:      cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-spring-soft: cubic-bezier(0.3, 1.25, 0.5, 1);
    --ease-swift:       cubic-bezier(0.55, 0, 0.1, 1);
    --duration-fast:    0.16s;
    --duration-base:    0.26s;
    --duration-slow:    0.45s;
    --duration-slower:  0.7s;

    /* Typography */
    --font-display: 'Fraunces', 'Playfair Display', Georgia, serif;
    --font-body:    'Figtree', 'Lato', 'Segoe UI', system-ui, sans-serif;

    /* Pro brand — deep teal, kept from the original identity */
    --pro-brand:        #0f8f82;
    --pro-brand-mid:    #087896;
    --pro-brand-dark:   #066860;
    --pro-brand-glow:   rgba(15, 143, 130, 0.35);
}

/* --- Reset --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg);
    min-height: 100vh;
    font-optical-sizing: auto;
}

::selection {
    background: rgba(62, 122, 84, 0.22);
    color: var(--brown-900);
}

img, svg { vertical-align: middle; }

/* Thin, warm scrollbars — the browser chrome is part of the design too */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--cream-300) transparent;
}
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb {
    background: var(--cream-300);
    border-radius: 99px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background-color: var(--brown-300); }
*::-webkit-scrollbar-track { background: transparent; }

/* Subtle topographic-grain texture for the rugged, outdoorsy feel.
   Applied per-page via the .textured-bg class on <body>. */
.textured-bg {
    background-color: var(--color-bg);
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -10%, rgba(62, 122, 84, 0.07), transparent),
        radial-gradient(ellipse 60% 42% at 100% 100%, rgba(224, 134, 47, 0.035), transparent),
        repeating-radial-gradient(
            circle at 12% 18%,
            transparent 0,
            transparent 110px,
            rgba(76, 62, 41, 0.024) 110px,
            rgba(76, 62, 41, 0.024) 112px
        ),
        repeating-radial-gradient(
            circle at 88% 82%,
            transparent 0,
            transparent 90px,
            rgba(42, 83, 57, 0.022) 90px,
            rgba(42, 83, 57, 0.022) 92px
        );
    background-attachment: fixed;
}

/* background-attachment: fixed breaks position:fixed descendants (e.g. the
   bottom tab bar) on iOS/Android while scrolling — keep the texture, drop fixed. */
@media (max-width: 900px) {
    .textured-bg {
        background-attachment: scroll;
    }
}

/* --- Typography --- */
h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 640;
    line-height: 1.18;
    letter-spacing: -0.014em;
    color: var(--brown-900);
    font-variation-settings: 'opsz' 40;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
}
a:hover { text-decoration: underline; }

/* Numbers that count (stats, XP, prices) should never jiggle */
.tabular-nums { font-variant-numeric: tabular-nums; }

/* --- Focus — visible, warm, never a default blue outline ---
   A real outline (survives component box-shadows and forced-colors mode) in a burnt amber
   that reads on both warm paper (~3.9:1) and deep forest (~4.8:1). Text fields keep their
   soft ring; the transparent outline still shows in Windows high-contrast. */
:root { --color-focus: #c46a17; }

:focus-visible {
    outline: 2.5px solid var(--color-focus);
    outline-offset: 2px;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid transparent;
    outline-offset: 0;
    box-shadow: var(--ring-primary);
}

/* --- Shared form field --- */
.field {
    margin-bottom: 20px;
}

.field label {
    display: block;
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--brown-700);
    margin-bottom: 7px;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"] {
    width: 100%;
    padding: 12px 15px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--color-text);
    background: var(--color-surface);
    outline: none;
    box-shadow: inset 0 1px 2px rgba(38, 32, 15, 0.03);
    transition: border-color var(--duration-fast) ease,
        box-shadow var(--duration-base) var(--ease-out),
        transform var(--duration-base) var(--ease-out);
}

.field input::placeholder { color: var(--brown-300); }

.field input:focus {
    border-color: var(--color-border-focus);
    box-shadow: var(--ring-primary), 0 2px 10px rgba(62, 122, 84, 0.08);
}

/* Mobile browsers (notably iOS Safari) auto-zoom toward a focused form
   control whose font-size is below 16px — which happens when a modal with an
   input opens — and then leave the page stuck zoomed in. Guaranteeing a 16px
   minimum on small viewports stops the zoom entirely while still letting users
   pinch-to-zoom on their own. !important is needed to win over the more
   specific input rules elsewhere. */
@media (max-width: 768px) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* --- Buttons --- */
.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.005em;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background var(--duration-fast) ease,
        box-shadow var(--duration-base) var(--ease-out),
        transform var(--duration-base) var(--ease-spring),
        color var(--duration-fast) ease,
        border-color var(--duration-fast) ease,
        filter var(--duration-fast) ease;
    text-decoration: none;
}

.btn:hover { text-decoration: none; }

.btn:active { transform: translateY(1px) scale(0.97); transition-duration: 0.06s; }

.btn-primary {
    background: linear-gradient(180deg, var(--green-600) 0%, var(--green-700) 55%, #38724d 100%);
    color: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22),
        0 1px 2px rgba(26, 52, 37, 0.28),
        0 4px 12px rgba(42, 83, 57, 0.24);
}
.btn-primary:hover {
    color: #fff;
    filter: brightness(1.06) saturate(1.05);
    transform: translateY(-1px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), var(--shadow-primary);
}
.btn-primary:active { transform: translateY(1px) scale(0.97); filter: brightness(0.98); }
.btn-primary:disabled {
    background: var(--brown-300);
    cursor: not-allowed;
    transform: none;
    filter: none;
    box-shadow: none;
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
    border: 1.5px solid var(--color-border);
}
.btn-ghost:hover {
    background: var(--cream-200);
    border-color: var(--brown-300);
    color: var(--color-text);
}
.btn-ghost:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-full { width: 100%; }

/* --- Feedback messages --- */
.msg-error {
    background: var(--color-error-bg);
    color: var(--color-error);
    border: 1px solid #efc4bf;
    border-radius: var(--radius-sm);
    padding: 9px 13px;
    font-size: 0.875rem;
    margin-bottom: 16px;
    display: none;
}
.msg-error.visible { display: block; animation: shake-no 0.4s var(--ease-out); }

.msg-success {
    background: var(--color-success-bg);
    color: var(--color-success);
    border: 1px solid var(--color-success-border);
    border-radius: var(--radius-sm);
    padding: 9px 13px;
    font-size: 0.875rem;
    margin-bottom: 16px;
    display: none;
}
.msg-success.visible { display: block; animation: rise-in 0.35s var(--ease-out); }

/* ============================================================
   Skeletons — perceived speed. Use instead of spinners.
   ============================================================ */
.skeleton {
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, var(--cream-200), #e9e0cc);
    border-radius: var(--radius-sm);
    color: transparent !important;
    user-select: none;
    pointer-events: none;
}
.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg,
        transparent 20%,
        rgba(254, 252, 247, 0.75) 50%,
        transparent 80%);
    transform: translateX(-100%);
    animation: skeleton-sweep 1.4s var(--ease-swift) infinite;
}
.skeleton--text  { height: 0.9em; border-radius: 6px; }
.skeleton--title { height: 1.3em; border-radius: 8px; }
.skeleton--circle { border-radius: 50%; }

@keyframes skeleton-sweep {
    to { transform: translateX(100%); }
}

/* ============================================================
   Toasts — created by ui-fx.js (TPFX.toast)
   ============================================================ */
.tpfx-toast-stack {
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 8px;
    z-index: 4000;
    pointer-events: none;
}

@media (max-width: 900px) {
    /* Sit above the floating mobile tab bar */
    .tpfx-toast-stack { bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }
}

.tpfx-toast {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 11px 18px 11px 14px;
    border-radius: 999px;
    background: rgba(26, 52, 37, 0.94);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(254, 252, 247, 0.14);
    color: var(--cream-50);
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.35;
    box-shadow: 0 6px 24px rgba(14, 32, 21, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    pointer-events: auto;
    cursor: pointer;
    animation: toast-in var(--duration-slow) var(--ease-spring-soft);
}

.tpfx-toast.is-leaving {
    animation: toast-out var(--duration-base) var(--ease-swift) forwards;
}

.tpfx-toast-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border-radius: 50%;
    background: rgba(140, 199, 161, 0.22);
    color: var(--green-300);
}

.tpfx-toast--success .tpfx-toast-icon { background: rgba(140, 199, 161, 0.25); color: var(--green-300); }
.tpfx-toast--accent  .tpfx-toast-icon { background: rgba(242, 168, 84, 0.25); color: var(--sun-400); }
.tpfx-toast--error {
    background: rgba(90, 30, 26, 0.95);
}
.tpfx-toast--error .tpfx-toast-icon { background: rgba(255, 173, 163, 0.22); color: #ffb3a9; }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(16px) scale(0.92); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
    to { opacity: 0; transform: translateY(10px) scale(0.94); }
}

/* ============================================================
   Scroll reveals — gated on html.tpfx so content is never
   hidden if JS fails. ui-fx.js adds the class + observes.
   ============================================================ */
html.tpfx [data-reveal] {
    opacity: 0;
    transform: translateY(18px);
}
html.tpfx [data-reveal].is-revealed {
    opacity: 1;
    transform: translateY(0);
    transition: opacity var(--duration-slower) var(--ease-out),
        transform var(--duration-slower) var(--ease-out);
    transition-delay: var(--reveal-delay, 0s);
}

/* ============================================================
   Shared animations
   ============================================================ */
@keyframes rise-in {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes scale-in {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Springy entrance for things that should feel alive (badges, chips, pins) */
@keyframes pop-in {
    0%   { opacity: 0; transform: scale(0.5); }
    70%  { opacity: 1; transform: scale(1.06); }
    100% { opacity: 1; transform: scale(1); }
}

/* Reward pulse — hearts, saves, check-ins */
@keyframes heart-pop {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.35); }
    60%  { transform: scale(0.92); }
    100% { transform: scale(1); }
}

/* Gentle error shake — "no" without shouting */
@keyframes shake-no {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(4px); }
    75% { transform: translateX(-2px); }
}

/* Soft attention pulse for glowing CTAs */
@keyframes glow-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(62, 122, 84, 0.35); }
    55%      { box-shadow: 0 0 0 9px rgba(62, 122, 84, 0); }
}

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

/* Screen-reader-only text (announcements, extra labels) */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* --- "Send to…" dialog (tp-send-to.js) --- */
.tp-send-to {
    width: min(440px, calc(100vw - 32px));
    max-height: min(84vh, 680px);
    display: flex;
    flex-direction: column;
}

.tp-send-to-label {
    display: block;
    margin: 12px 0 6px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--color-text);
}

.tp-send-to-label span {
    font-weight: 500;
    color: var(--color-text-muted);
}

.tp-send-to-label[hidden],
.tp-send-to-note[hidden] {
    display: none;
}

.tp-send-to-note,
.tp-send-to-search {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1.5px solid var(--color-border-soft);
    border-radius: var(--radius-md);
    background: var(--cream-50);
    font: inherit;
    font-size: 0.92rem;
    resize: none;
}

.tp-send-to-note:focus,
.tp-send-to-search:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(62, 122, 84, 0.14);
}

.tp-send-to-list {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    overflow-y: auto;
    min-height: 120px;
}

.tp-send-to-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 4px;
    border-bottom: 1px solid var(--color-border-soft);
}

.tp-send-to-row:last-child {
    border-bottom: none;
}

.tp-send-to-avatar {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--green-100);
    color: var(--color-primary-dark);
    font-size: 0.78rem;
    font-weight: 800;
}

.tp-send-to-who {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.tp-send-to-who strong {
    font-size: 0.92rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tp-send-to-who span {
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

.tp-send-to-btn {
    flex-shrink: 0;
    padding: 7px 14px;
    font-size: 0.82rem;
}

.tp-send-to-empty {
    padding: 18px 4px;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    text-align: center;
}

/* The hidden attribute always wins over component display rules (buttons, flex rows…). */
[hidden] {
    display: none !important;
}


/* ============================================================
   SHARED MODAL SYSTEM
   Contract (do not break): .modal-overlay.open { display:flex },
   .modal, .modal-close, .modal-sub, .modal-actions,
   .modal--confirm, .modal--list. Used by home.html (Convoy),
   the global Plan-a-Drive modal, and every page in the shell.
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(14, 32, 21, 0.52);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 16px;
    -webkit-backdrop-filter: blur(7px);
    backdrop-filter: blur(7px);
}
.modal-overlay.open {
    display: flex;
    animation: fade-in 0.22s ease both;
}

.modal {
    background: var(--color-surface);
    border: 1px solid var(--color-border-soft);
    border-radius: var(--radius-xl);
    padding: 36px 36px 32px;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.7);
    position: relative;
}

/* Springy entrance — confirmation should feel alive, not clinical */
.modal-overlay.open .modal {
    animation: modal-pop-in 0.42s var(--ease-spring-soft) both;
}

@keyframes modal-pop-in {
    from { opacity: 0; transform: translateY(22px) scale(0.93); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid transparent;
    border-radius: 50%;
    background: transparent;
    font-size: 1.4rem;
    color: var(--brown-300);
    cursor: pointer;
    line-height: 1;
    z-index: 2;
    transition: color var(--duration-fast) ease,
        background var(--duration-fast) ease,
        border-color var(--duration-fast) ease,
        transform var(--duration-base) var(--ease-spring);
}
.modal-close:hover {
    color: var(--brown-700);
    background: var(--cream-200);
    border-color: var(--cream-300);
    transform: rotate(90deg);
}
.modal-close:active { transform: rotate(90deg) scale(0.9); }

.modal h2 {
    font-family: var(--font-display);
    font-size: 1.34rem;
    font-weight: 680;
    margin-bottom: 5px;
    color: var(--brown-900);
    padding-right: 30px;
}

.modal-sub {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    line-height: 1.55;
    margin-bottom: 26px;
}

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

/* Confirm dialogs: tighter, decisive */
.modal--confirm {
    max-width: 440px;
}

.modal--confirm .modal-sub {
    margin-bottom: 22px;
}

.btn-danger {
    background: linear-gradient(180deg, #c2493c 0%, #a93327 100%);
    color: #fff;
    border: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18),
        0 2px 8px rgba(147, 49, 45, 0.28);
}

.btn-danger:hover {
    filter: brightness(1.07);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18),
        0 4px 14px rgba(147, 49, 45, 0.34);
}

.btn-danger:active { transform: translateY(1px) scale(0.97); }

.btn-danger:disabled {
    background: #e0a49d;
    cursor: not-allowed;
    transform: none;
    filter: none;
    box-shadow: none;
}

/* --- Legacy modal form submit button --- */
.modal .submit-btn {
    width: 100%;
    background: var(--color-primary);
    color: #fff;
    border: none;
    padding: 13px;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 8px;
    transition: background var(--duration-fast) ease, transform var(--duration-fast) ease;
}
.modal .submit-btn:hover { background: var(--color-primary-dark); }
.modal .submit-btn:active { transform: translateY(1px) scale(0.98); }
.modal .submit-btn:disabled {
    background: var(--brown-300);
    cursor: not-allowed;
    transform: none;
}

/* Feedback inside legacy modals */
#form-error {
    color: var(--color-error);
    background: var(--color-error-bg);
    border: 1px solid #f0c0c0;
    border-radius: var(--radius-sm);
    padding: 9px 13px;
    font-size: 0.875rem;
    margin-top: 12px;
    display: none;
}

#form-success {
    color: var(--color-success);
    font-size: 0.875rem;
    font-weight: 600;
    margin-top: 12px;
    display: none;
}

/* --- Autocomplete dropdown --- */
.ac-wrapper { position: relative; }

.ac-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border-soft);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 200;
    overflow: hidden;
    display: none;
    padding: 4px;
}
.ac-dropdown.open {
    display: block;
    animation: ac-drop-in 0.18s var(--ease-out) both;
}

@keyframes ac-drop-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ac-item {
    padding: 9px 11px;
    font-size: 0.9rem;
    color: var(--color-text);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: var(--radius-sm);
    transition: background 0.12s, color 0.12s;
}
.ac-item:hover,
.ac-item.highlighted {
    background: var(--green-50);
    color: var(--color-primary-dark);
}

.ac-item--muted {
    color: var(--color-text-muted);
    cursor: default;
    font-size: 0.85rem;
}

.ac-item--muted:hover {
    background: transparent;
    color: var(--color-text-muted);
}

@media (max-width: 600px) {
    .modal { padding: 32px 22px 26px; border-radius: 22px; }
}

/* --- Custom date trigger button --- */
.date-trigger {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text);
    background: var(--color-surface);
    cursor: pointer;
    text-align: left;
    transition: border-color var(--duration-fast) ease,
        box-shadow var(--duration-fast) ease,
        background var(--duration-fast) ease;
}
.date-trigger svg { color: var(--color-primary); flex-shrink: 0; }
.date-trigger:hover { border-color: var(--green-300); box-shadow: var(--shadow-xs); }
.date-trigger.is-open {
    border-color: var(--color-border-focus);
    box-shadow: var(--ring-primary);
}
.date-trigger.is-empty .date-trigger-label { color: var(--brown-300); font-weight: 500; }
.date-trigger-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Floating popover (calendar + menus) --- */
.tp-pop {
    position: fixed;
    z-index: 300;
    display: none;
    opacity: 0;
    transform: translateY(-6px) scale(0.96);
    transform-origin: top left;
    transition: opacity 0.16s ease, transform 0.24s var(--ease-spring-soft);
}
.tp-pop.open { display: block; }
.tp-pop.shown { opacity: 1; transform: translateY(0) scale(1); }

/* --- Calendar: satisfying date picking --- */
.cal {
    width: 278px;
    padding: 13px;
    background: var(--color-surface);
    border: 1px solid var(--color-border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.cal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.cal-title {
    font-family: var(--font-display);
    font-weight: 660;
    font-size: 1rem;
    color: var(--brown-900);
}
.cal-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    border: 1px solid var(--color-border);
    border-radius: 9px;
    background: var(--cream-50);
    color: var(--brown-700);
    cursor: pointer;
    transition: background var(--duration-fast) ease,
        color var(--duration-fast) ease,
        border-color var(--duration-fast) ease,
        transform var(--duration-base) var(--ease-spring);
}
.cal-nav:hover { background: var(--green-50); color: var(--color-primary); border-color: var(--green-200); }
.cal-nav:active { transform: scale(0.88); }
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.cal-weekdays {
    margin-bottom: 4px;
}
.cal-weekdays span {
    text-align: center;
    font-size: 0.66rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--brown-300);
    padding: 4px 0;
}
.cal-day {
    aspect-ratio: 1 / 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--brown-900);
    font-family: var(--font-body);
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--duration-fast) ease,
        color var(--duration-fast) ease,
        transform var(--duration-base) var(--ease-spring),
        box-shadow var(--duration-fast) ease;
}
.cal-day:hover:not(:disabled):not(.is-selected) {
    background: var(--green-50);
    color: var(--color-primary-dark);
    transform: scale(1.12);
}
.cal-day:active:not(:disabled) { transform: scale(0.9); }
.cal-day.is-muted { color: var(--brown-300); opacity: 0.5; }
.cal-day.is-today { box-shadow: inset 0 0 0 1.5px var(--green-200); }
.cal-day.is-selected {
    background: var(--color-primary);
    color: #fff;
    box-shadow: var(--shadow-primary);
    animation: pop-in 0.32s var(--ease-spring-soft);
}
.cal-day.is-selected:hover { background: var(--color-primary-dark); color: #fff; }
.cal-day:disabled { color: var(--brown-300); opacity: 0.3; cursor: not-allowed; }
.cal-foot {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--color-border-soft);
}
.cal-foot-btn {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--cream-50);
    color: var(--brown-700);
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--duration-fast) ease,
        color var(--duration-fast) ease,
        border-color var(--duration-fast) ease,
        transform var(--duration-base) var(--ease-spring);
}
.cal-foot-btn:hover { background: var(--green-50); color: var(--color-primary); border-color: var(--green-200); }
.cal-foot-btn:active { transform: scale(0.96); }
.cal-foot-btn--clear:hover { background: #fdf1ef; color: var(--color-error); border-color: #efc4bf; }
