/* Road Trip Planner — calm map/signage theme (no cream/serif/terracotta) */

:root {
    --paper:      #eef1f0;   /* cool paper background */
    --card:       #ffffff;
    --ink:        #1e2a30;   /* near-black slate */
    --ink-soft:   #52626c;
    --ink-faint:  #8794a0;
    --line:       #dde3e5;
    --line-soft:  #eaeeef;

    --green:      #2f7d5a;   /* national-park green (primary) */
    --green-dim:  #e6f0ea;
    --amber:      #cc8a1a;   /* signage amber (secondary) */
    --amber-dim:  #f7edd8;

    /* per-section accents */
    --c-stay:     #4f5bd5;   /* lodging / stays  */
    --c-stay-dim: #e9eafb;
    --c-act:      #2f7d5a;   /* activities        */
    --c-act-dim:  #e6f0ea;
    --c-meal:     #cc7a1a;   /* meals             */
    --c-meal-dim: #f7ecd9;
    --c-travel:   #3a6ea5;   /* travel leg        */
    --c-travel-dim:#e6eef6;
    --c-note:     #6b7783;   /* notes             */

    --radius:     12px;
    --radius-sm:  8px;
    --shadow:     0 1px 2px rgba(30,42,48,.06), 0 4px 14px rgba(30,42,48,.05);
    --focus:      #1c6cff;

    --maxw:       1040px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
}

button { font-family: inherit; }

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: 4px;
}

.visually-hidden {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Login ---------- */

.login-body {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.login-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px 28px;
    width: min(380px, 100%);
    text-align: center;
}
.login-mark { font-size: 40px; }
.login-card h1 { margin: 6px 0 2px; font-size: 22px; }
.login-sub { margin: 0 0 18px; color: var(--ink-soft); font-size: 14px; }
.login-error {
    background: #fdECEC; color: #9b2226;
    border: 1px solid #f3c9c9; border-radius: var(--radius-sm);
    padding: 8px 12px; font-size: 14px; margin: 0 0 14px;
}
.login-card form { display: grid; gap: 10px; }
.login-card input[type=password] {
    padding: 12px 14px; font-size: 16px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: #fbfcfc;
}
.login-card button {
    padding: 12px 14px; font-size: 16px; font-weight: 600;
    color: #fff; background: var(--green);
    border: 0; border-radius: var(--radius-sm); cursor: pointer;
}
.login-card button:hover { background: #276a4c; }

/* ---------- App frame ---------- */

.loading { padding: 80px 20px; text-align: center; color: var(--ink-faint); }

.app-header {
    position: sticky; top: 0; z-index: 20;
    background: color-mix(in srgb, var(--paper) 88%, transparent);
    backdrop-filter: saturate(1.1) blur(8px);
    border-bottom: 1px solid var(--line);
}
.app-header-inner {
    max-width: var(--maxw); margin: 0 auto;
    padding: 12px 18px; display: flex; align-items: center; gap: 12px;
}
.brand { font-size: 20px; }
.trip-title {
    flex: 1; min-width: 0;
    font-size: 19px; font-weight: 650; color: var(--ink);
    border: 1px solid transparent; border-radius: 6px;
    padding: 4px 6px; background: transparent;
}
.trip-title:hover { border-color: var(--line); }
.trip-title:focus { background: #fff; border-color: var(--line); outline: none; }

.header-actions { display: flex; align-items: center; gap: 8px; }
.header-actions .meta { font-size: 12px; color: var(--ink-faint); white-space: nowrap; }

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 12px; font-size: 14px; font-weight: 550;
    color: var(--ink); background: var(--card);
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    cursor: pointer;
}
.btn:hover { border-color: var(--ink-faint); }
.btn-primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn-primary:hover { background: #276a4c; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--line-soft); }
.btn-sm { padding: 4px 9px; font-size: 13px; }
.btn-danger:hover { color: #9b2226; border-color: #e6b8b8; }

main.wrap { max-width: var(--maxw); margin: 0 auto; padding: 18px 18px 120px; }

/* ---------- Trip meta bar ---------- */

.trip-bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
    padding: 10px 4px 16px;
}
.trip-bar label { font-size: 13px; color: var(--ink-soft); display: flex; gap: 6px; align-items: center; }
.trip-bar input[type=date] {
    border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 14px; background: #fff;
}

/* ---------- Overview / route strip ---------- */

.overview {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 12px 14px; margin-bottom: 18px; overflow-x: auto;
}
.overview h2 {
    font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--ink-faint); margin: 0 0 10px;
}
.route {
    display: flex; gap: 6px; min-width: min-content;
}
.route-day {
    flex: 0 0 auto; min-width: 64px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: 6px 8px; font-size: 12px; cursor: pointer; background: #fff;
    position: relative;
}
.route-day:hover { border-color: var(--ink-faint); }
.route-day .rd-num { font-weight: 700; color: var(--ink); }
.route-day .rd-date { color: var(--ink-faint); }
.route-day .rd-loc { color: var(--c-stay); font-weight: 550; margin-top: 3px; }
.route-day .rd-move { color: var(--c-travel); margin-top: 2px; }
.route-day.has-stay { border-bottom: 3px solid var(--c-stay); }

/* ---------- Day cards ---------- */

.day {
    background: var(--card); border: 1px solid var(--line);
    border-left: 4px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    margin-bottom: 14px; overflow: hidden;
}
.day.in-stay { border-left-color: var(--c-stay); }

.day-head {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; cursor: pointer; user-select: none;
}
.day-head:hover { background: var(--line-soft); }
.disclosure {
    border: 0; background: transparent; cursor: pointer;
    font-size: 13px; color: var(--ink-faint); width: 18px; text-align: center;
    transition: transform .15s ease;
}
.day.collapsed .disclosure { transform: rotate(-90deg); }
.day-daynum { font-weight: 700; font-size: 16px; }
.day-date { color: var(--ink-soft); font-size: 13px; }
.day-loc {
    color: var(--c-stay); font-weight: 600; font-size: 14px;
    display: inline-flex; align-items: center; gap: 4px;
}
.day-loc.is-override { color: var(--ink-soft); font-weight: 500; font-style: italic; }
.day-head .spacer { flex: 1; }
.day-head .day-tools { display: flex; gap: 2px; opacity: 0; transition: opacity .1s; }
.day:hover .day-head .day-tools, .day-head:focus-within .day-tools { opacity: 1; }

.day-body { padding: 0 14px 14px; }
.day.collapsed .day-body { display: none; }

/* stay banner inside a day */
.stay-banner {
    display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap;
    background: var(--c-stay-dim); border: 1px solid color-mix(in srgb, var(--c-stay) 22%, transparent);
    border-radius: var(--radius-sm); padding: 9px 12px; margin: 4px 0 14px;
    font-size: 13.5px;
}
.stay-banner .sb-icon { font-size: 16px; }
.stay-banner .sb-main { flex: 1; min-width: 180px; }
.stay-banner .sb-name { font-weight: 650; color: var(--c-stay); }
.stay-banner .sb-times { color: var(--ink-soft); }
.stay-banner .sb-notes { color: var(--ink-soft); margin-top: 2px; white-space: pre-wrap; }
.stay-banner .sb-edit { align-self: center; }

/* travel leg banner */
.leg-banner {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    background: var(--c-travel-dim); border: 1px solid color-mix(in srgb, var(--c-travel) 22%, transparent);
    border-radius: var(--radius-sm); padding: 8px 12px; margin: 0 0 14px; font-size: 13.5px;
}
.leg-banner .lb-route { font-weight: 650; color: var(--c-travel); }
.leg-banner .lb-metrics { color: var(--ink-soft); }
.leg-banner .lb-notes { color: var(--ink-soft); }
.leg-empty { margin: 0 0 12px; }

/* section grids */
.sections { display: grid; gap: 14px; }
.slot-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 620px) { .slot-grid { grid-template-columns: 1fr; } }

.slot {
    border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
    padding: 8px 10px 10px; background: #fcfdfd; min-height: 54px;
}
.slot.drop-hover { border-color: var(--green); background: var(--green-dim); }
.slot.enroute, .slot.checked-out { opacity: .55; }
.slot-title {
    font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--ink-faint); font-weight: 700; margin-bottom: 6px;
    display: flex; align-items: center; gap: 6px;
}
.slot-flag { font-size: 10px; font-weight: 600; color: var(--amber); text-transform: none; letter-spacing: 0; }

.section-label {
    font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
    font-weight: 700; margin: 2px 0 8px; display: flex; align-items: center; gap: 7px;
}
.section-label.activities { color: var(--c-act); }
.section-label.meals { color: var(--c-meal); }
.section-label .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* items */
.item {
    display: flex; align-items: flex-start; gap: 8px;
    padding: 5px 6px; border-radius: 6px; background: #fff;
    border: 1px solid transparent; margin-bottom: 4px;
}
.item:hover { border-color: var(--line); }
.item.dragging { opacity: .4; }
.item .grip { cursor: grab; color: var(--ink-faint); font-size: 13px; padding-top: 2px; touch-action: none; }
.item .item-fields { flex: 1; min-width: 0; }
.item .item-detail { font-size: 12.5px; color: var(--ink-soft); }
.item .item-del {
    border: 0; background: transparent; color: var(--ink-faint);
    cursor: pointer; font-size: 14px; opacity: 0; padding: 0 2px;
}
.item:hover .item-del { opacity: 1; }
.item-del:hover { color: #9b2226; }

.add-item {
    border: 0; background: transparent; color: var(--ink-faint);
    cursor: pointer; font-size: 13px; padding: 3px 6px; border-radius: 6px;
    display: inline-flex; align-items: center; gap: 5px;
}
.add-item:hover { background: var(--line-soft); color: var(--ink); }

/* editable free-text fields */
.edit {
    display: block; width: 100%;
    border: 1px solid transparent; border-radius: 6px;
    padding: 3px 6px; font: inherit; color: var(--ink);
    background: transparent; resize: none; overflow: hidden;
    min-height: 1.5em; white-space: pre-wrap; word-break: break-word;
}
.edit:hover { background: var(--line-soft); }
.edit:focus { background: #fff; border-color: var(--line); outline: none; box-shadow: 0 0 0 2px rgba(28,108,255,.12); }
.edit.placeholder-shown:empty::before {
    content: attr(data-placeholder); color: var(--ink-faint);
}
.edit-detail { font-size: 12.5px; color: var(--ink-soft); }

.notes-field { margin-top: 4px; }
.notes-field .edit { min-height: 2.4em; }

/* empty-state affordances */
.empty-hint { color: var(--ink-faint); font-size: 13px; font-style: italic; }

/* add-day controls */
.day-insert {
    display: flex; justify-content: center; margin: -4px 0 10px;
}
.day-insert button {
    opacity: 0; font-size: 12px; color: var(--ink-faint);
    border: 1px dashed var(--line); background: var(--paper);
    border-radius: 20px; padding: 2px 12px; cursor: pointer;
}
.day-insert:hover button { opacity: 1; }
.day-insert button:hover { color: var(--green); border-color: var(--green); }

.add-day-row { text-align: center; margin-top: 6px; }

/* toast */
.toast {
    position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
    background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 20px;
    font-size: 13px; box-shadow: var(--shadow); z-index: 60;
    opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: .95; }

/* modal (stay editor) */
.modal-back {
    position: fixed; inset: 0; background: rgba(20,28,32,.42);
    display: grid; place-items: center; z-index: 50; padding: 18px;
}
.modal {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
    width: min(460px, 100%); max-height: 90dvh; overflow: auto; padding: 20px 22px;
}
.modal h3 { margin: 0 0 14px; font-size: 18px; }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.field input, .field textarea, .field select {
    font: inherit; padding: 8px 10px; border: 1px solid var(--line);
    border-radius: var(--radius-sm); background: #fbfcfc; width: 100%;
}
.field textarea { min-height: 64px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 110px; gap: 10px; }
.modal-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; }
.modal-actions .right { display: flex; gap: 8px; }

/* ---------- motion / print ---------- */

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

@media print {
    .app-header, .day-insert, .add-day-row, .add-item, .item-del,
    .day-tools, .btn, .toast, .stay-banner .sb-edit { display: none !important; }
    body { background: #fff; }
    main.wrap { max-width: none; padding: 0; }
    .day, .overview { break-inside: avoid; box-shadow: none; border-color: #ccc; }
    .day.collapsed .day-body { display: block !important; }
    .slot.enroute, .slot.checked-out { opacity: 1; }
    .edit:empty { display: none; }
    a[href]::after { content: ""; }
}
