:root {
    --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
    --display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
    --bg: #efeae2;
    --bg-2: #e7e0d5;
    --surface: #fffdf8;
    --surface-2: #f7f1e8;
    --ink: #1b1610;
    --ink-soft: #3d3429;
    --muted: #6f6456;
    --faint: #9a8c7a;
    --line: #e4d8c6;
    --line-strong: #d3c4ae;
    --brand: #c45c26;
    --brand-dark: #9a3f14;
    --brand-soft: #f6e0d2;
    --forest: #1f4a3a;
    --forest-soft: #dceae3;
    --sidebar: #14110e;
    --sidebar-2: #1d1914;
    --sidebar-text: #c9bba8;
    --danger: #b42318;
    --danger-soft: #fde8e6;
    --warn: #9a6700;
    --warn-soft: #fff3c4;
    --ok: #1f7a4d;
    --ok-soft: #d9f3e4;
    --info: #1d4e89;
    --info-soft: #dceafb;
    --shadow: 0 1px 2px rgba(27, 22, 16, 0.05), 0 12px 32px rgba(27, 22, 16, 0.06);
    --shadow-lg: 0 24px 70px rgba(27, 22, 16, 0.2);
    --radius: 20px;
    --radius-sm: 12px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { scroll-behavior: smooth; }
body.app {
    margin: 0;
    font-family: var(--font);
    background:
        radial-gradient(1200px 500px at 100% -10%, rgba(196, 92, 38, 0.08), transparent 50%),
        var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.55;
    letter-spacing: -0.011em;
    -webkit-font-smoothing: antialiased;
}
body.app.is-locked { overflow: hidden; }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: #f3c9ae; color: var(--ink); }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 268px;
    flex: 0 0 268px;
    background:
        radial-gradient(400px 220px at 20% 0%, rgba(196, 92, 38, 0.22), transparent 60%),
        linear-gradient(180deg, var(--sidebar) 0%, #0d0b09 100%);
    color: var(--sidebar-text);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 30;
}
.brand {
    display: block;
    padding: 2px 4px 22px;
    text-decoration: none;
}
.brand:hover { color: inherit; }
.brand-logo {
    display: block;
    width: 100%;
    height: auto;
}

.nav-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #7b6e5f;
    padding: 16px 12px 8px;
}
.nav { display: grid; gap: 4px; }
.nav a, .nav button.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--sidebar-text);
    background: none;
    border: 0;
    text-align: left;
    width: 100%;
    cursor: pointer;
    transition: background 160ms var(--ease), color 160ms var(--ease);
}
.nav a:hover, .nav button.nav-link:hover { background: rgba(255,255,255,0.06); color: #fffdf8; }
.nav a.is-active {
    background: rgba(226, 122, 58, 0.16);
    color: #fffdf8;
    box-shadow: inset 0 0 0 1px rgba(226, 122, 58, 0.18);
}
.nav svg { width: 18px; height: 18px; opacity: 0.9; flex: 0 0 auto; }

.sidebar-foot { margin-top: auto; padding: 16px 8px 6px; border-top: 1px solid rgba(255,255,255,0.07); }
.who {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: #3d3429;
    flex: 0 0 auto;
}
.who-meta { min-width: 0; }
.who-meta strong { display: block; color: #fffdf8; font-size: 13px; }
.who-meta span { display: block; color: #9a8c7a; font-size: 12px; }
.sidebar-foot form { margin: 0; }
.sidebar-foot button, .ghost-link {
    background: none;
    border: 0;
    color: #9a8c7a;
    padding: 0;
    cursor: pointer;
    font: inherit;
}
.sidebar-foot button:hover, .ghost-link:hover { color: #fffdf8; }

.workspace { flex: 1; min-width: 0; }
.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 28px;
    background: rgba(255, 253, 248, 0.78);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}
.menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 12px;
    cursor: pointer;
}
.search {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 560px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 9px 16px;
    box-shadow: 0 1px 0 rgba(255,255,255,0.7) inset;
}
.search:focus-within { border-color: #e0a47a; box-shadow: 0 0 0 4px var(--brand-soft); }
.search input {
    border: 0;
    background: transparent;
    width: 100%;
    outline: none;
}
.search kbd {
    font-size: 11px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 2px 6px;
    color: var(--faint);
    background: var(--surface-2);
}
.topbar-actions { display: flex; gap: 8px; margin-left: auto; align-items: center; }

.page { padding: 32px 28px 72px; max-width: 1280px; }

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 28px;
}
.kicker {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--brand);
}
.page-head h1, .builder-hero h1, .display {
    margin: 0;
    font-family: var(--display);
    font-size: clamp(34px, 4vw, 48px);
    letter-spacing: -0.03em;
    font-weight: 400;
    line-height: 1.05;
}
.lede { margin: 8px 0 0; color: var(--muted); max-width: 640px; font-size: 15.5px; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }
.metric {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 18px 16px;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform 180ms var(--ease), border-color 180ms var(--ease);
}
.metric:hover { transform: translateY(-2px); border-color: #e0a47a; color: inherit; }
.metric span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.metric strong { display: block; margin-top: 10px; font-family: var(--display); font-size: 36px; letter-spacing: -0.04em; font-weight: 400; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-pad { padding: 22px 24px; }
.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 22px;
    border-bottom: 1px solid var(--line);
}
.card-head h2 { margin: 0; font-size: 15px; letter-spacing: -0.02em; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 999px;
    padding: 10px 16px;
    background: var(--ink);
    color: #fffdf8;
    font-weight: 650;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
    transition: transform 160ms var(--ease), background 160ms var(--ease);
}
.btn:hover { background: #2c241c; color: #fffdf8; transform: translateY(-1px); }
.btn-brand { background: var(--brand); }
.btn-brand:hover { background: var(--brand-dark); color: #fff; }
.btn-secondary { background: var(--forest); }
.btn-secondary:hover { background: #163628; color: #fff; }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line-strong); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    color: var(--muted);
}
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }

.input, select, textarea,
input[type="text"], input[type="search"], input[type="email"], input[type="url"],
input[type="number"], input[type="date"], input[type="file"], input[type="password"] {
    width: 100%;
    border: 1px solid var(--line-strong);
    background: #fff;
    border-radius: 12px;
    padding: 11px 13px;
    outline: none;
    color: var(--ink);
    transition: box-shadow 160ms var(--ease), border-color 160ms var(--ease);
}
.input:focus, textarea:focus, select:focus { border-color: #e0a47a; box-shadow: 0 0 0 4px var(--brand-soft); }
label { display: block; font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; letter-spacing: 0.02em; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.form-grid .full, .form-grid p:has(textarea) { grid-column: 1 / -1; }
form p { margin: 0 0 14px; }
form p label { margin-bottom: 6px; }
.helptext, .hint { color: var(--muted); font-size: 13px; }
.errorlist { color: var(--danger); padding-left: 16px; }
.checkbox { width: auto; margin-right: 8px; }

.table-wrap { overflow: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    padding: 12px 22px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
}
table.data td { padding: 15px 22px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background 120ms var(--ease); }
table.data tbody tr:hover { background: #fbf6ee; }
.row-title { font-weight: 700; color: var(--ink); letter-spacing: -0.02em; }
.row-title:hover { color: var(--brand); }

.pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 750;
    letter-spacing: 0.02em;
    background: var(--bg-2);
    color: #3d3429;
}
.pill-draft { background: #efeae2; }
.pill-sent { background: var(--info-soft); color: var(--info); }
.pill-option { background: var(--warn-soft); color: var(--warn); }
.pill-booked, .pill-travelled { background: var(--ok-soft); color: var(--ok); }
.pill-published { background: var(--brand-soft); color: var(--brand-dark); }
.pill-cancelled, .pill-archived { background: var(--danger-soft); color: var(--danger); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.toolbar .grow { flex: 1; min-width: 220px; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink-soft);
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 650;
    text-decoration: none;
}
.chip:hover, .chip.is-on { background: var(--ink); color: #fffdf8; border-color: var(--ink); }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.media-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 22px;
    overflow: hidden;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform 200ms var(--ease), box-shadow 200ms var(--ease);
}
.media-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); color: inherit; }
.thumb { height: 168px; background: #d8cbb8 center/cover no-repeat; }
.thumb.empty { background: linear-gradient(135deg, #3d3429, #c45c26); }
.media-card .body { padding: 16px 16px 18px; }
.media-card h3 { margin: 0 0 4px; font-size: 17px; letter-spacing: -0.03em; }
.checks { display: flex; gap: 6px; margin-top: 12px; }
.checks span {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: var(--faint);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 3px 7px;
}
.checks .on { color: var(--ok); border-color: #b7e0c8; background: var(--ok-soft); }

.toast-list { list-style: none; padding: 16px 28px 0; margin: 0; display: grid; gap: 8px; }
.toast-list li {
    background: var(--ok-soft);
    border: 1px solid #b7e0c8;
    color: #145536;
    padding: 12px 14px;
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.tabs {
    display: flex;
    gap: 4px;
    padding: 5px;
    background: rgba(255,253,248,0.7);
    border: 1px solid var(--line);
    border-radius: 16px;
    width: max-content;
    margin-bottom: 22px;
    backdrop-filter: blur(8px);
}
.tab-btn {
    border: 0;
    background: transparent;
    padding: 9px 14px;
    border-radius: 12px;
    color: var(--muted);
    font-weight: 700;
    cursor: pointer;
}
.tab-btn.is-active { background: var(--ink); color: #fffdf8; }

.tab-panel { display: none; animation: rise 280ms var(--ease); }
.tab-panel.is-active { display: block; }

.builder-hero {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 22px;
}
.meta-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 13px; margin-top: 10px; }
.crumb { color: var(--muted); font-size: 13px; }
.crumb a { color: var(--muted); }

.timeline { position: relative; display: grid; gap: 0; }
.timeline::before {
    content: "";
    position: absolute;
    left: 23px;
    top: 18px;
    bottom: 18px;
    width: 2px;
    background: linear-gradient(#d3c4ae, #e4d8c6);
}
.stay-card {
    position: relative;
    display: grid;
    grid-template-columns: 48px 108px 1fr auto;
    gap: 16px;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 14px;
    transition: transform 160ms var(--ease), box-shadow 160ms var(--ease);
}
.stay-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.stay-card.is-dragging { opacity: 0.55; }
.day-dot {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: var(--ink);
    color: #fffdf8;
    display: grid;
    place-items: center;
    font-family: var(--display);
    font-size: 18px;
    position: relative;
    z-index: 1;
}
.handle {
    cursor: grab;
    color: #b5a48d;
    width: 22px;
    display: grid;
    place-items: center;
    user-select: none;
    letter-spacing: 1px;
}
.stay-photo { width: 108px; height: 86px; border-radius: 14px; object-fit: cover; background: #d8cbb8; }
.stay-card h3 { margin: 0 0 4px; font-size: 19px; letter-spacing: -0.03em; }
.stay-actions { display: flex; gap: 8px; padding-right: 6px; }
.insert-row {
    display: flex;
    justify-content: center;
    margin: -4px 0 10px;
    position: relative;
    z-index: 2;
}
.insert-row button {
    border: 1px dashed var(--line-strong);
    background: var(--surface);
    color: var(--muted);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
.insert-row button:hover { color: var(--ink); border-color: var(--brand); }

.route-item {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    gap: 14px;
    align-items: start;
    padding: 16px 0;
    border-bottom: 1px solid var(--line);
}
.route-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--forest-soft);
    color: var(--forest);
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 800;
}

.split { display: grid; grid-template-columns: 1.25fr 0.75fr; gap: 16px; }
.muted { color: var(--muted); }
.empty {
    padding: 48px 28px;
    text-align: center;
    color: var(--muted);
}
.empty h2 { font-family: var(--display); font-size: 32px; color: var(--ink); margin: 0 0 8px; font-weight: 400; }
.empty-art {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    border-radius: 22px;
    background: linear-gradient(145deg, #e27a3a, #1f4a3a);
}

.person {
    display: flex;
    align-items: center;
    gap: 12px;
}
.mono {
    width: 40px;
    height: 40px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    font-weight: 800;
    color: #fffdf8;
    background: #3d3429;
    flex: 0 0 auto;
}
.mono.a { background: #c45c26; }
.mono.b { background: #1f4a3a; }
.mono.c { background: #1d4e89; }
.mono.d { background: #7a3e6c; }
.mono.e { background: #8a5a12; }

.trip-list { display: grid; gap: 10px; }
.trip-row {
    display: grid;
    grid-template-columns: 1fr 160px 140px 160px;
    gap: 16px;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 14px 16px;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow);
    transition: transform 160ms var(--ease);
}
.trip-row:hover { transform: translateY(-2px); color: inherit; }

.modal {
    position: fixed;
    inset: 0;
    background: rgba(20, 17, 14, 0.52);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 180ms var(--ease), visibility 180ms;
}
.modal.is-open { opacity: 1; visibility: visible; }
.modal-card {
    width: min(720px, 100%);
    background: var(--surface);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transform: translateY(16px) scale(0.98);
    transition: transform 220ms var(--ease);
}
.modal.is-open .modal-card { transform: none; }
.modal-card header, .modal-card .modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 22px 16px;
}
.modal-card h2 { margin: 0; font-family: var(--display); font-size: 30px; font-weight: 400; }
.modal-lead { margin: 4px 0 0; color: var(--muted); }
.modal-body { padding: 0 22px 8px; }
.modal-foot { padding: 16px 22px 22px; display: flex; justify-content: flex-end; gap: 8px; }
.lookup { display: grid; gap: 8px; margin-top: 12px; max-height: 320px; overflow: auto; padding-right: 4px; }
.lookup button {
    text-align: left;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 14px;
    padding: 10px;
    cursor: pointer;
    display: grid;
    grid-template-columns: 56px 1fr auto;
    gap: 12px;
    align-items: center;
}
.lookup button:hover, .lookup button.is-selected { border-color: #e0a47a; background: #fff7f1; }
.lookup img, .lookup-ph {
    width: 56px;
    height: 48px;
    border-radius: 10px;
    object-fit: cover;
    background: #d8cbb8;
}
.palette .modal-card { width: min(640px, 100%); }
.palette-list { display: grid; gap: 6px; padding: 8px 16px 18px; }
.palette-list a, .palette-list button {
    display: flex;
    justify-content: space-between;
    padding: 12px 12px;
    border-radius: 12px;
    border: 0;
    background: transparent;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}
.palette-list a:hover, .palette-list button:hover { background: var(--surface-2); }

.scrim {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 17, 14, 0.4);
    z-index: 25;
}
body.nav-open .scrim { display: block; }

@keyframes rise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

@media (max-width: 1080px) {
    .metrics, .form-grid, .split, .trip-row { grid-template-columns: 1fr 1fr; }
    .trip-row { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-105%);
        transition: transform 220ms var(--ease);
    }
    body.nav-open .sidebar { transform: none; }
    .menu-btn { display: grid; place-items: center; }
    .metrics, .form-grid, .split { grid-template-columns: 1fr; }
    .stay-card { grid-template-columns: 40px 1fr; }
    .stay-photo, .day-dot { display: none; }
    .page, .topbar { padding-left: 16px; padding-right: 16px; }
    .timeline::before { display: none; }
    .search kbd { display: none; }
}
