/* Final mobile app polish. Kept separate so it remains the last cascade layer. */

/* Activities remain editable from their cards; avoid a second prominent add CTA. */
#addActivity, #addCheck { display: none !important; }

.quick-actions-dialog { width: min(100%, 480px); max-width: 100%; margin: auto 0 0; padding: 0; border: 0; border-radius: 25px 25px 0 0; background: transparent; }
.quick-actions-dialog::backdrop { background: rgba(30, 39, 47, .36); backdrop-filter: blur(2px); }
.quick-actions-sheet { padding: 19px 20px max(24px, env(safe-area-inset-bottom)); background: #fffdfb; border-radius: 25px 25px 0 0; box-shadow: 0 -12px 32px rgba(45, 47, 55, .13); }
.quick-actions-head { display: flex; align-items: center; justify-content: space-between; padding-bottom: 14px; border-bottom: 1px solid #eee9e4; }
.quick-actions-head p { margin: 0 0 2px; color: #84766c; font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.quick-actions-head h2 { margin: 0; color: #332b3c; font-size: 1.18rem; }
.quick-actions-close { display: grid; width: 34px; height: 34px; place-items: center; border: 0; border-radius: 50%; color: #69636b; font-size: 1.5rem; line-height: 1; background: #f4f1ee; }
.quick-actions-list { display: grid; gap: 8px; margin-top: 14px; }
.quick-action { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 66px; padding: 10px; border: 1px solid #eee9e4; border-radius: 16px; color: #332b3c; text-align: left; background: #fff; }
.quick-action:active { transform: scale(.985); background: #faf7f4; }
.quick-action-icon { display: grid; flex: 0 0 42px; width: 42px; height: 42px; place-items: center; border-radius: 13px; font-weight: 800; font-size: 1.1rem; }
.quick-action-icon--teal { color: #176f72; background: #dcefed; }.quick-action-icon--pink { color: #a24d68; background: #f7e0e7; }.quick-action-icon--sand { color: #906a2e; background: #f5ead6; }
.quick-action b, .quick-action small { display: block; }.quick-action b { font-size: .91rem; }.quick-action small { margin-top: 2px; color: #7a7472; font-size: .71rem; }
.guest-access-button { margin-top: 10px; padding: 9px 16px; border: 1px solid #83bdb8; border-radius: 999px; color: #176f72; font: inherit; font-size: .82rem; font-weight: 700; background: #fff; }
.room-access-dialog { width: min(420px, calc(100% - 30px)); border: 0; border-radius: 20px; box-shadow: 0 25px 70px #0004; }.room-access-dialog form { padding: 22px; }.room-access-dialog::backdrop { background: #13211966; }
.room-code-card { margin: 0 0 16px; padding: 13px; border: 1px dashed #b8d9d4; border-radius: 15px; background: #eef8f6; }.room-code-card > span,.room-code-card small { display: block; color: #597570; font-size: .7rem; }.room-code-card code { display: block; margin: 5px 0 3px; color: #176f72; font: 800 1.05rem/1.2 monospace; letter-spacing: .12em; }.room-code-card b { color: #43514f; font-family: monospace; }.room-code-card div { display: flex; gap: 7px; margin-top: 10px; }.room-code-card button { padding: 6px 9px; border: 0; border-radius: 9px; color: #176f72; font: inherit; font-size: .7rem; font-weight: 700; background: #d4ece8; }

.chat-state { min-height: calc(100vh - 72px); padding: 22px 18px 96px; background: #f8f7f4; }
.chat-head { display: flex; align-items: center; gap: 12px; }
.chat-back { display: grid; flex: 0 0 40px; width: 40px; height: 40px; place-items: center; border: 0; border-radius: 14px; color: #176f72; font-size: 2rem; line-height: 1; background: #def0ee; }
.chat-head p { margin: 0 0 1px; color: #69807e; font-size: .65rem; font-weight: 800; letter-spacing: .11em; }
.chat-head h1 { margin: 0; color: #302b40; font-size: 1.45rem; line-height: 1.15; }
.chat-head span { display: block; margin-top: 2px; overflow: hidden; color: #77737c; font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.chat-private-note { margin: 16px 0 12px; padding: 9px 11px; border-radius: 12px; color: #5e7272; font-size: .72rem; background: #eaf4f1; }
.chat-messages { display: grid; align-content: start; gap: 10px; min-height: 350px; max-height: calc(100vh - 285px); padding: 5px 1px 14px; overflow-y: auto; }
.chat-message { max-width: 82%; padding: 10px 12px 8px; border: 1px solid #ece7e2; border-radius: 16px 16px 16px 5px; color: #37313e; background: #fff; box-shadow: 0 3px 9px rgba(59, 49, 45, .04); }
.chat-message.mine { justify-self: end; border-color: #c5e3df; border-radius: 16px 16px 5px 16px; background: #ddf0ed; }
.chat-sender { display: block; margin-bottom: 2px; color: #167276; font-size: .68rem; font-weight: 800; }
.chat-message p { margin: 0; font-size: .89rem; line-height: 1.45; overflow-wrap: anywhere; }
.chat-message time { display: block; margin-top: 4px; color: #827e85; font-size: .63rem; text-align: right; }
.chat-empty { margin: 65px auto; color: #858087; font-size: .83rem; text-align: center; }
.chat-form { position: fixed; z-index: 12; right: 0; bottom: 72px; left: 0; display: flex; gap: 8px; align-items: end; padding: 10px 18px; border-top: 1px solid #eee9e4; background: rgba(255,253,251,.96); backdrop-filter: blur(12px); }
.chat-form textarea { flex: 1; min-height: 43px; max-height: 100px; padding: 11px 13px; resize: none; border: 1px solid #dfd9d2; border-radius: 15px; color: #332b3c; font: inherit; font-size: .84rem; background: #fff; }
.chat-form button { display: grid; flex: 0 0 43px; width: 43px; height: 43px; place-items: center; border: 0; border-radius: 15px; color: #173f42; font-size: 1.28rem; font-weight: 800; background: #ffd33f; box-shadow: 0 3px 0 #dfa916; }
.chat-form button:disabled { opacity: .55; box-shadow: none; }
html[data-theme="dark"] .chat-state { background: #1d2030; }.chat-state .chat-private-note { color: #5e7272; }
html[data-theme="dark"] .chat-head h1 { color: #f4f0f6; } html[data-theme="dark"] .chat-head span { color: #c4bdc8; }
html[data-theme="dark"] .chat-message { border-color: #3c4055; color: #f3eef5; background: #303447; } html[data-theme="dark"] .chat-message.mine { border-color: #397d7c; background: #215b5d; }
html[data-theme="dark"] .chat-form { border-color: #3a3d4c; background: rgba(29,32,48,.96); } html[data-theme="dark"] .chat-form textarea { border-color: #484b60; color: #f3eef5; background: #303447; }

/* Trip chat: roomy, readable message bubbles with a familiar left/right conversation flow. */
.chat-state { padding-bottom: 138px; }
.chat-messages { display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: 10px 2px 18px; }
.chat-row { display: flex; align-items: flex-end; gap: 8px; min-width: 0; }
.chat-row.mine { justify-content: flex-end; }
.chat-avatar { display: grid; flex: 0 0 31px; width: 31px; height: 31px; place-items: center; overflow: hidden; border: 2px solid #fff; border-radius: 50%; color: #176f72; font-size: .76rem; font-weight: 800; background: #dcefed; box-shadow: 0 2px 6px rgba(31,55,59,.12); }
.chat-row .chat-message { min-width: 0; max-width: min(78%, 490px); padding: 9px 12px 7px; border-radius: 18px 18px 18px 5px; box-sizing: border-box; }
.chat-row.mine .chat-message { border-radius: 18px 18px 5px 18px; }
.chat-message .chat-sender { margin-bottom: 3px; color: #167276; font-size: .72rem; line-height: 1.25; }
.chat-row.mine .chat-sender { color: #176f72; text-align: right; }
.chat-message p { min-width: 0; margin: 0; font-size: clamp(.94rem, 3.8vw, 1rem); line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.chat-meta { display: flex; justify-content: flex-end; min-height: 14px; margin-top: 3px; }
.chat-message time { margin: 0; font-size: .66rem; line-height: 1.2; }
.chat-message .chat-loc { width: 100%; min-width: 0; margin: 2px 0; box-sizing: border-box; }
.chat-message .chat-loc > span:last-child { min-width: 0; }
.chat-message .chat-loc small { overflow-wrap: anywhere; }
.chat-message .chat-img { width: min(100%, 310px); min-width: 0; max-width: 100%; margin: 2px 0; }
.chat-message .chat-img img { width: 100%; max-width: 100%; height: auto; max-height: min(380px, 52vh); object-fit: cover; }
.chat-form { align-items: flex-end; padding: 10px max(14px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-right)); }
.chat-form textarea { min-width: 0; min-height: 46px; max-height: 132px; font-size: 16px !important; line-height: 1.45; overflow-wrap: anywhere; }
html[data-theme="dark"] .chat-avatar { border-color: #303447; color: #b7eeea; background: #215b5d; }

@media (max-width: 560px) {
  .chat-state { padding: 16px 14px 142px; }
  .chat-private-note { margin: 12px 0 9px; }
  .chat-messages { min-height: 300px; max-height: calc(100dvh - 246px); gap: 10px; padding-bottom: 12px; }
  .chat-row .chat-message { max-width: calc(100% - 39px); }
  .chat-row.mine .chat-message { max-width: 84%; }
  .chat-form { gap: 7px; }
  .chat-form button, .chat-plus { flex-basis: 42px !important; width: 42px !important; height: 42px !important; }
}

@media (max-width: 900px) {
  .app-shell { width: 100%; }
  .topbar {
    height: 60px;
    padding: 0 18px;
    background: #14838d;
    color: #fff;
  }
  .brand { display: flex; align-items: center; color: #fff; font-size: 1.12rem; }
  .brand img { width: 34px !important; height: 34px !important; margin-right: 7px !important; border-radius: 11px !important; }
  .brand span { color: #ffd33f; }
  .topbar-actions { gap: 9px; }
  .save-status { display: none; }
  .account-menu { padding: 0; border: 0; border-radius: 50%; background: transparent; box-shadow: none; }
  .account-menu img { width: 36px; height: 36px; border: 2px solid #fff; background: #fff; }
  .account-menu span, .account-menu button { display: none; }
  .topbar .google-login { width: 38px; height: 38px; padding: 0; justify-content: center; border: 0; border-radius: 50%; background: #fff; box-shadow: none; }
  .topbar .google-login span:last-child { display: none; }
  .topbar .icon-button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: #ffffff24; color: #fff; }
  .trip-toolbar { height: 54px; margin: 0 !important; padding: 6px 18px !important; gap: 12px; background: #14838d !important; }
  .back-to-list { min-height: 42px; padding: 0; color: #fff; font-size: .93rem; }
  .export-btn { min-height: 42px; padding: 0 15px; border: 0; border-radius: 15px; background: #e3f5f3; color: #117f89; font-size: .88rem; box-shadow: none; }
  /* The trip overview is the mobile dashboard surface, continuous with the header. */
  .trip-hero {
    display: flex;
    flex-direction: column !important;
    justify-content: flex-start !important;
    min-height: 110px !important;
    margin: 0 !important;
    padding: 18px 20px !important;
    border-radius: 0 0 25px 25px !important;
    background: linear-gradient(135deg, #f6e7e5 0%, #f9efdf 54%, #e8f1e8 100%) !important;
    box-shadow: 0 11px 25px rgba(104, 84, 70, .11);
    color: #332b3c;
    overflow: hidden;
  }
  .trip-hero::before { display: none !important; }
  .trip-hero .hero-main { position: relative; z-index: 1; width: 100%; max-width: 100% !important; }
  .trip-hero .eyebrow { display: none; }
  .trip-hero h1 { max-width: 100% !important; margin: 0; color: #332b3c !important; font-size: clamp(1.35rem, 5.2vw, 1.7rem) !important; line-height: 1.1 !important; }
  .trip-hero .trip-detail { max-width: 100%; margin-top: 5px; padding: 0; overflow: hidden; color: #d8f2ef; font-size: .73rem; font-weight: 500; text-align: left; text-overflow: ellipsis; white-space: nowrap; background: transparent; }
  .trip-hero .trip-detail span { color: #89c9c5; }
  .hero-metrics { position: relative; z-index: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 0; width: 100%; margin-top: 8px !important; margin-right: 0 !important; padding: 0 !important; border: 0; border-radius: 0; background: transparent !important; }
  .hero-metrics > div { min-width: 0; }
  .hero-metrics > div + div { padding-left: 12px; border-left: 1px solid rgba(255,255,255,.32); }
  .hero-metrics strong { display: inline; color: #fff; font-size: 1.04rem !important; line-height: 1.1; }
  .hero-metrics span { display: inline; margin-left: 5px; color: #c9eeea; font-size: .64rem; }
  .hero-actions { position: relative; z-index: 1; display: grid; grid-template-columns: 1.24fr 1fr 1fr; gap: 7px; width: 100%; margin-top: auto; }
  .hero-action { display: inline-flex; align-items: center; justify-content: center; gap: 3px; min-width: 0; min-height: 36px; padding: 5px 4px; border: 0; border-radius: 12px; color: #27313b; font: inherit; font-size: clamp(.58rem, 2.2vw, .7rem); font-weight: 700; white-space: nowrap; background: #f8fcfb; box-shadow: none; }
  .hero-action span { font-size: 1.15em; line-height: 1; }
  .hero-action--primary { color: #24242c; background: #ffd33f; }
  .hero-action:active { transform: scale(.97); }
  .day-tabs { gap: 10px; padding: 12px 22px 16px; scroll-padding-inline: 22px; scroll-snap-type: x proximity; scrollbar-width: none; }
  .day-tabs::-webkit-scrollbar { display: none; }
  .day-tabs::after { content: ""; display: block; flex: 0 0 34px; }
  .day-tab { flex: 0 0 112px; min-width: 112px; padding: 10px 13px; border: 1px solid #e0e3e7; border-radius: 16px; background: #fff; scroll-snap-align: start; }
  .day-tab.active { border-color: #23212b; background: #23212b; color: #fff; }
  .day-tab.active strong { color: #fff; }
  .day-tab.active small { color: #ffd33f; }
}

@media (max-width: 650px) {
  body { padding-bottom: 78px; }
  .side-stack { gap: 14px; }
  .budget-panel { background: #f7f4ea; box-shadow: none; }
  .checklist-panel { background: #f3f6fa; box-shadow: none; }
  .share-panel { background: #f7f2f4; box-shadow: none; }
  .budget-panel .section-kicker { color: #796b41; }
  .checklist-panel .section-kicker { color: #55728e; }
  .share-panel .section-kicker { color: #866473; }
  .budget-panel .progress { background: #ebe4d2; }
  .budget-panel .progress span { background: #d7b94c; }
  .share-panel .primary-button { background: #2a2937; border-color: #2a2937; }
  .activity:nth-child(3n + 1) .activity-card { background: #f1f6f5; }
  .activity:nth-child(3n + 2) .activity-card { background: #f5f2f7; }
  .activity:nth-child(3n) .activity-card { background: #faf5ef; }
  .trip-card, .trip-card:nth-child(3n + 1), .trip-card:nth-child(3n + 2), .trip-card:nth-child(3n) { background: #f4f6f8; box-shadow: none; }
  .trip-card-go, .trip-card:nth-child(3n + 1) .trip-card-go, .trip-card:nth-child(3n + 2) .trip-card-go, .trip-card:nth-child(3n) .trip-card-go { background: #e6f0ef; color: #357c78; }
  .trip-card-trash { background: #fff; }
  .mobile-tabbar { height: 72px; padding: 5px 9px max(5px, env(safe-area-inset-bottom)); grid-template-columns: 1fr 1fr 58px 1fr 1fr; border-radius: 24px 24px 0 0; }
  .mobile-tab { height: 59px; gap: 0; }
  .mobile-tab > span:first-child { font-size: 1.42rem; }
  .mobile-tab b { font-size: .61rem; line-height: 1.1; }
  .mobile-add { width: 56px; height: 56px; border-radius: 18px; font-size: 2.55rem; transform: translateY(-18px); box-shadow: 0 -3px 0 #fff, 0 5px 0 #dfa916; }
  .mobile-avatar { width: 26px; height: 26px; }
  .gate-mascot { width: 125px; }
  .trip-hero { min-height: 94px !important; padding: 16px 18px !important; border-radius: 0 0 22px 22px !important; }
  .trip-hero h1 { max-width: 100% !important; }
  .hero-metrics { margin-top: 7px !important; }
  .hero-metrics strong { font-size: .98rem !important; }
  .hero-actions { gap: 6px; }
  .hero-action { min-height: 34px; padding-inline: 3px; border-radius: 11px; font-size: .57rem; }
}

/* Keep overnight stays together at the end of each day's route. */
.timeline { display: flex; flex-direction: column; }
.timeline > .activity { order: 1; }
.timeline > .insert-stop { order: 2; }
.timeline > .activity.is-stay, .timeline > .activity.natgo-stay { order: 3; }
