@font-face { font-family: system; src: local("Inter"), local("Arial"); }

/* Shared theme and control geometry. Layout-specific dimensions stay with their components. */
:root {
  font-family: system, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --route: #3b6fb6;
  --map-background: #e8ece7;
  --spinner-track: #d4e5df;
  --backdrop: #24353250;
  --credit-surface: #ffffffde;
  --working-sweep: #e3eee86b;
  --working-text: #bacac1;
  --background: #f6f5f0;
  --surface: #fffefa;
  --surface-hover: #f3f6f3;
  --surface-selected: #e7f0e9;
  --foreground: #263235;
  --text: #44554b;
  --muted: #68786f;
  --line: #dfe5df;
  --green: #166a58;
  --green-hover: #125a4b;
  --focus: #58a994;
  --selected-border: #b7d1c5;
  --danger: #a14334;
  --danger-surface: #fff5f3;
  --danger-border: #e6bcb5;
  --draft-surface: #f1f3f2;
  --draft-border: #bfc6c4;
  --warning: #876c31;
  --warning-surface: #fff9e9;
  --warning-border: #e8debd;
  --tooltip-surface: #263c33;
  --on-accent: #fff;
  --shadow-panel: 0 8px 30px #263c3320;
  --shadow-dialog: 0 24px 100px #14272026;
  --radius-panel: 14px;
  --radius-control: 6px;
  --radius-icon: 4px;
  --control-height: 36px;
  --row-height: 34px;
  --motion-fast: 150ms;
  --dialog-enter: 230ms;
  --dialog-exit: 140ms;
  --scroll-enter: 180ms;
  --scroll-exit: 350ms;
  color: var(--foreground);
  background: var(--background);
}
* { box-sizing: border-box; }
/* Shared control geometry; each variant owns its colors, including the border. */
:is(.primary-button,.secondary-button,.route-create,.permit-confirm button) { display:inline-flex; align-items:center; justify-content:center; gap:8px; min-height:var(--control-height); padding:7px 12px; border-width:1px; border-style:solid; border-radius:var(--radius-control); font-size:12px; font-weight:500; line-height:1.4; transition:background var(--motion-fast),color var(--motion-fast),border-color var(--motion-fast); }
.primary-button { border-color:transparent; background:var(--green); color:var(--on-accent); }
:where(.secondary-button,.route-create,.permit-confirm button) { border-color:var(--line); background:var(--surface); color:var(--text); }
.route-create { color:var(--green); }
:where(.secondary-button,.route-create,.permit-confirm button):hover:enabled { background:var(--surface-hover); }
:is(.permit-remove,.icon-button) { display:grid; place-items:center; flex-shrink:0; width:24px; height:24px; padding:0; border:0; border-radius:var(--radius-icon); background:transparent; color:var(--muted); font-size:18px; line-height:1; transition:background var(--motion-fast),color var(--motion-fast); }
:is(.permit-remove,.icon-button):hover:enabled { color:var(--green); background:var(--surface-hover); }
:is(.settings-fields select,#trip-name) { width:100%; min-width:0; min-height:var(--control-height); padding:8px 12px; border:1px solid var(--line); border-radius:var(--radius-control); background:var(--surface); color:var(--foreground); font-size:12px; }
:is(.upload-error,.list-error,#rename-error,#unsaved-error,#route-error,#route-generation-error,#route-remove-error) { color:var(--danger); font-size:12px; line-height:1.5; overflow-wrap:anywhere; }

body { margin: 0; }
button, input, select, textarea { font: inherit; }
button, a, label { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible, .permit-drop-heading:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; border:0; }
html, body { height: 100%; overflow: hidden; }
.app { position: relative; height: 100dvh; }
#map { position: absolute; inset: 0; background: var(--map-background); }
#map[aria-hidden="true"] { visibility: hidden; }
.trip-workspace { position:absolute; z-index:10; top:84px; left:20px; width:550px; height:calc(var(--row-height) * 5.5 + 220px); max-width:calc(100vw - 40px); max-height:calc(100dvh - 134px); display:grid; grid-template-columns:140px minmax(0,1fr); grid-template-rows:minmax(0,1fr); background:var(--surface); border:1px solid var(--line); border-radius:var(--radius-panel); box-shadow:var(--shadow-panel); overflow:hidden; transition:grid-template-columns 420ms cubic-bezier(.22,.7,.2,1); }
.trip-workspace:has(.trip-navigation:hover,.trip-navigation :focus-visible) { grid-template-columns:250px minmax(0,1fr); }
.trip-workspace { --workspace-toggle-size:44px; }
.trip-workspace.is-collapsed { width:calc(var(--workspace-toggle-size) + 2px); height:calc(var(--workspace-toggle-size) + 2px); grid-template-columns:1fr; grid-template-rows:1fr; }
.trip-workspace.is-collapsed .trip-navigation { border:0; }
.trip-workspace.is-collapsed :is(#trips-heading > div,.trip-details,.trip-placeholder) { visibility:hidden; }
#trips-heading { justify-content:flex-start; padding-left:48px; }
.trip-workspace > .panel-collapse { position:absolute; z-index:2; top:0; left:0; width:var(--workspace-toggle-size); height:var(--workspace-toggle-size); border-radius:var(--radius-panel) 0 0 0; }
.trip-navigation { display:flex; flex-direction:column; min-width:0; min-height:0; border-right:1px solid var(--line); }
.trip-placeholder { display:grid; place-items:center; min-width:0; min-height:180px; padding:24px; color:var(--muted); font-size:12px; line-height:1.6; text-align:center; }
.sidebar-heading { min-height:56px; padding:16px; display:flex; flex-shrink:0; align-items:center; justify-content:space-between; gap:8px; min-width:0; }
.sidebar-heading > div { display: flex; align-items: center; gap: 8px; }
h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.4px; }
.count { font-size: 11px; color: var(--muted); background: var(--surface-hover); border-radius: 5px; padding: 3px 6px; }
.trip-navigation h1 { font-size:15px; }
.trips-content { display:flex; flex:1; flex-direction:column; min-height:0; }
.trip-list { min-height:0; padding:0 10px; }
.trip-message { padding:12px 16px; border-top:1px solid var(--line); }
.trip-message p { font-size: 12px; line-height: 1.6; margin: 0 0 5px; }
#state-title { font-weight: 600; }
#state-description { color: var(--muted); }
.map-warning { position: absolute; z-index: 11; bottom: 36px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 40px); margin: 0; padding: 12px 16px; background: var(--warning-surface); border: 1px solid var(--warning-border); border-radius:var(--radius-control); color: var(--warning); font-size: 12px; }
.eyebrow { font-size: 9px; font-weight: 600; letter-spacing: 1.7px; color: var(--muted); }
.primary-button:hover:not(:disabled) { background: var(--green-hover); }
.primary-button span { font-size: 17px; line-height: 1; }
.spinner { width: 21px; height: 21px; border: 2px solid var(--spinner-track); border-top-color: var(--green); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.list-empty { color: var(--muted); font-size: 12px; line-height: 1.7; padding: 12px; }
.list-error { margin: 0 23px 15px; color: var(--danger); font-size: 12px; line-height: 1.5; }
dialog { width: min(480px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius:var(--radius-panel); padding:0; background:var(--surface); color:inherit; box-shadow: var(--shadow-dialog); max-height:calc(100dvh - 40px); overflow:hidden; }
dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); }
.modal-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
dialog h2 { margin: 0; font-weight: 500; letter-spacing: -.7px; font-size: 26px; }
dialog p { font-size: 12px; color: var(--muted); line-height: 1.6; margin: 10px 0 22px; }
.upload-error { color: var(--danger); background: var(--danger-surface); padding: 10px 12px; border-radius: 5px; margin: 15px 0 0; }
.modal-footer { display: flex; justify-content: flex-end; gap: 9px; border-top: 1px solid var(--line); margin-top: 24px; padding-top: 20px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.app-header { position: absolute; inset: 0 0 auto; z-index: 20; height: 64px; padding: 0 24px; display: flex; justify-content: space-between; align-items: center; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { color: var(--green); font-size: 21px; font-weight: 650; letter-spacing: -.6px; }
.brand > span { color: var(--muted); font-weight: 400; }
.account { display: flex; align-items: center; gap: 10px; font-size: 13px; min-width: 0; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-selected); color: var(--green); font-size: 11px; flex-shrink: 0; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.account-toggle { display: flex; align-items: center; gap: 9px; border: 0; border-radius:var(--radius-control); padding: 9px 10px; background: transparent; color: inherit; min-width: 0; font-size: 13px; font-weight: 500; transition: background .15s; }
.account-toggle:hover, .account-toggle[aria-expanded="true"] { background: var(--surface-hover); }
.account-chevron { color: var(--muted); flex-shrink: 0; transition: transform .18s ease, color .15s; }
.account-toggle[aria-expanded="true"] .account-chevron { transform: rotate(180deg); color: var(--green); }
.account-menu { position: fixed; inset: 58px 24px auto auto; margin: 0; width:184px; padding:0; overflow:hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: inherit; box-shadow: var(--shadow-panel); }
.account-scroll-viewport { max-height:calc(100dvh - 82px); padding:6px; }
.account-option { display: flex; align-items: center; gap: 11px; width: 100%; border: 0; border-radius:var(--radius-control); padding: 12px; background: transparent; color: var(--text); font-size: 13px; text-align: left; transition: background .15s, color .15s; }
.account-option svg { flex-shrink: 0; color: var(--muted); }
.account-option:hover:not(:disabled), .account-option:focus-visible { background: var(--surface-hover); color: var(--green); }
.account-option:hover svg { color: var(--green); }
.account-option + .account-option { margin-top: 2px; }
.settings-fields { display: grid; gap: 9px; margin-top: 20px; font-size: 13px; }
.settings-fields > label:not(.settings-switch) { margin-top: 9px; color: var(--muted); }
.settings-switch { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 15px; cursor: pointer; }
.settings-switch input { appearance: none; width: 38px; height: 22px; margin: 0; border-radius: 12px; background: var(--draft-border); position: relative; cursor: pointer; flex-shrink: 0; }
.settings-switch input::before { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; top: 3px; left: 3px; background: var(--on-accent); }
.settings-switch input:checked { background: var(--green); }
.settings-switch input:checked::before { left: 19px; }
@media (max-width: 540px) { .account-menu { right: 12px; } }
.sign-in { position: absolute; z-index: 15; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(400px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius:var(--radius-panel); padding: 28px; box-shadow: var(--shadow-panel); }
.sign-in h1 { font-size: 22px; }
.sign-in p { font-size: 12px; color: var(--muted); line-height: 1.6; }
#google-sign-in { margin-top: 22px; min-height: 44px; }
.session-error { position: absolute; z-index: 25; top: 64px; left: 50%; transform: translateX(-50%); background: var(--danger-surface); color: var(--danger); border-radius:var(--radius-control); padding: 10px 14px; font-size: 12px; max-width: calc(100vw - 24px); }
@media (max-width: 540px) { .app-header { padding: 0 12px; } #account-name { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } }

/* Native modal semantics, with shared reversible entrance/exit styling. */
dialog[open] { animation:dialog-enter var(--dialog-enter) cubic-bezier(.22,.75,.2,1) both; }
dialog::backdrop { animation:dialog-backdrop-in var(--dialog-enter) ease-out both; }
dialog[data-state="closed"] { animation:dialog-exit var(--dialog-exit) ease-in both; }
dialog[data-state="closed"]::backdrop { animation:dialog-backdrop-out var(--dialog-exit) ease-in both; }
@keyframes dialog-enter { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }
@keyframes dialog-exit { from { opacity:1; transform:translateY(0); } to { opacity:0; transform:translateY(8px); } }
@keyframes dialog-backdrop-in { from { opacity:0; } to { opacity:1; } }
@keyframes dialog-backdrop-out { from { opacity:1; } to { opacity:0; } }
@media (prefers-reduced-motion:reduce) { :root { --dialog-enter:0ms; --dialog-exit:0ms; } }

.map-data-credit { position: fixed; bottom: 3px; left: 8px; z-index: 2; font-size: 9px; color: var(--muted); background: var(--credit-surface); padding: 2px 4px; border-radius: 3px; }
.map-data-credit a { color: inherit; }

.edit-guide { position:absolute; z-index:10; bottom:36px; left:50%; transform:translateX(-50%); width:340px; max-width:calc(100vw - 24px); max-height:calc(100dvh - 100px); overflow-y:auto; padding:12px 16px 14px; border:1px solid var(--line); border-radius:var(--radius-panel); background:var(--surface); box-shadow:var(--shadow-panel); animation:edit-guide-enter 180ms ease-out; }
.edit-guide-heading { display:flex; align-items:center; gap:8px; margin-bottom:8px; }
.edit-guide[data-state="closed"] { animation:edit-guide-exit var(--dialog-exit) ease-in both; }
.edit-guide h2 { flex:1; margin:0; color:var(--foreground); font-size:14px; font-weight:600; }
.edit-guide-preference { display:flex; align-items:center; gap:8px; min-height:24px; margin-top:12px; color:var(--muted); font-size:12px; line-height:1.5; cursor:pointer; }
.edit-guide-preference input { flex-shrink:0; width:16px; height:16px; margin:0; accent-color:var(--green); }
.edit-guide-preference-error { margin:8px 0 0; color:var(--danger); font-size:12px; line-height:1.5; }
@media (pointer:coarse) { .edit-guide-preference { min-height:44px; } }
.guide-demo { text-align:center; }
.guide-demo svg { display:block; width:100%; overflow:visible; }
.guide-demo :is(svg *, .guide-action-labels > span) { animation-duration:18s; animation-iteration-count:infinite; animation-fill-mode:both; animation-timing-function:linear; }
.guide-route { fill:none; stroke:var(--route); stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.guide-point circle { fill:var(--surface); stroke:var(--green); stroke-width:1.6; }
.guide-point .guide-insert-highlight { fill:none; opacity:0; animation-name:guide-insert-highlight; }
.guide-point text { fill:var(--green); text-anchor:middle; font:600 13px system,sans-serif; }
.guide-point-a { animation-name:guide-add-one; }
.guide-point-b { opacity:0; animation-name:guide-add-two-delete; }
.guide-point-b circle { animation-name:guide-delete-highlight; }
.guide-point-c { animation-name:guide-add-three; }
.guide-route-ab { opacity:0; animation-name:guide-first-segment; }
.guide-route-bc { opacity:0; animation-name:guide-second-segment; }
.guide-inserted { animation-name:guide-insert; }
.guide-route-db { opacity:0; animation-name:guide-insert-segment; }
.guide-route-dc { animation-name:guide-delete-segment; }
.guide-before-insert { opacity:0; animation-name:guide-before-insert; }
.guide-end-three { animation-name:guide-end-three; }
.guide-end-four { opacity:0; animation-name:guide-end-four; }
.guide-cursor { opacity:0; animation-name:guide-cursor; }
.guide-cursor path { fill:var(--foreground); stroke:var(--surface); stroke-width:1.3; stroke-linejoin:round; }
.guide-mouse > rect { fill:var(--surface); stroke:var(--muted); stroke-width:1.3; }
.guide-mouse-left,.guide-mouse-right { fill:var(--surface); }
.guide-mouse-left { animation-name:guide-left-clicks; }
.guide-mouse-right { animation-name:guide-right-clicks; }
.guide-mouse-divider { fill:none; stroke:var(--muted); stroke-width:1; }
.guide-mouse .guide-wheel { fill:var(--muted); stroke:none; }
.guide-action-labels { display:grid; margin-top:8px; font-size:12px; font-weight:600; color:var(--green); }
.guide-action-labels > span { grid-area:1 / 1; }
.guide-label-add { animation-name:guide-label-add; }
.guide-label-insert { opacity:0; animation-name:guide-label-insert; }
.guide-label-delete { opacity:0; animation-name:guide-label-delete; }
@keyframes edit-guide-enter { from { opacity:0; translate:0 8px; } to { opacity:1; translate:0 0; } }
@keyframes edit-guide-exit { from { opacity:1; translate:0 0; } to { opacity:0; translate:0 8px; } }
@keyframes guide-add-one { 0%,7% {opacity:0} 8%,100% {opacity:1} }
@keyframes guide-add-two-delete { 0%,19% {opacity:0} 20%,78% {opacity:1} 80%,100% {opacity:0} }
@keyframes guide-add-three { 0%,31% {opacity:0} 32%,100% {opacity:1} }
@keyframes guide-first-segment { 0%,19% {opacity:0} 20%,53% {opacity:1} 54%,100% {opacity:0} }
@keyframes guide-second-segment { 0%,31% {opacity:0} 32%,78% {opacity:1} 80%,100% {opacity:0} }
@keyframes guide-insert { 0%,53% {opacity:0} 54%,100% {opacity:1} }
@keyframes guide-insert-highlight { 0%,53.99% {opacity:0;r:12px} 54% {opacity:.65;r:12px} 60%,100% {opacity:0;r:23px} }
@keyframes guide-insert-segment { 0%,53% {opacity:0} 54%,78% {opacity:1} 80%,100% {opacity:0} }
@keyframes guide-delete-segment { 0%,78% {opacity:0} 80%,100% {opacity:1} }
@keyframes guide-before-insert { 0%,53% {opacity:1} 54%,100% {opacity:0} }
@keyframes guide-end-three { 0%,53% {opacity:1} 54%,78% {opacity:0} 80%,100% {opacity:1} }
@keyframes guide-end-four { 0%,53% {opacity:0} 54%,78% {opacity:1} 80%,100% {opacity:0} }
@keyframes guide-delete-highlight { 0%,77% {fill:var(--surface);stroke:var(--green)} 78%,80% {fill:var(--danger-surface);stroke:var(--danger)} 81%,100% {fill:var(--surface);stroke:var(--green)} }
@keyframes guide-cursor { 0% {opacity:0;transform:translate(45px,65px)} 4%,11% {opacity:1;transform:translate(45px,65px)} 17%,23% {opacity:1;transform:translate(165px,33px)} 29%,37% {opacity:1;transform:translate(285px,65px)} 50%,61% {opacity:1;transform:translate(105px,25px)} 74%,86% {opacity:1;transform:translate(165px,33px)} 91%,100% {opacity:0;transform:translate(165px,33px)} }
@keyframes guide-left-clicks { 0%,6%,11%,18%,23%,30%,35%,100% {fill:var(--surface)} 7%,10%,19%,22%,31%,34% {fill:var(--green)} }
@keyframes guide-right-clicks { 0%,52%,57%,77%,82%,100% {fill:var(--surface)} 53%,56% {fill:var(--green)} 78%,81% {fill:var(--danger)} }
@keyframes guide-label-add { 0%,41.99% {opacity:1} 42%,100% {opacity:0} }
@keyframes guide-label-insert { 0%,41.99% {opacity:0} 42%,66.99% {opacity:1} 67%,100% {opacity:0} }
@keyframes guide-label-delete { 0%,66.99% {opacity:0} 67%,100% {opacity:1} }
@media (max-width:540px) { .edit-guide { bottom:30px; padding:10px 12px; } }
@media (prefers-reduced-motion:reduce) {
  .guide-action-labels { display:flex; justify-content:center; gap:16px; }
  .guide-action-labels > span { opacity:1; }
}


/* Keep creation below the trip rows, outside their scrolling viewport. */
.trip-actions { flex-shrink:0; margin:12px 10px 18px; }
.trip-actions:has(> button[hidden]) { display:none; }

/* Draft actions live on their row; feedback scrolls with Routes. */
.draft-feedback { margin-top:10px; }
#edit-status { margin:6px 0 0; color:var(--muted); font-size:12px; line-height:1.5; }
#draft-error { margin:6px 0 0; color:var(--danger); font-size:12px; line-height:1.5; overflow-wrap:anywhere; }
.draft-feedback .secondary-button { margin-top:8px; }
.draft-save:enabled { color:var(--green); }
#unsaved-edits .modal-footer { flex-wrap: wrap; }

.trip-name-field { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; font-size: 12px; color: var(--muted); }
.rename-hint { color: var(--muted); font-size: 12px; }
#rename-error { color: var(--danger); font-size: 12px; }

#route-count { color: var(--muted); font-weight: 400; }
#route-empty { color: var(--muted); font-size: 12px; }
#route-error, #route-generation-error { color: var(--danger); font-size: 12px; overflow-wrap: anywhere; }

#route-status { color: var(--muted); font-size: 12px; line-height: 1.5; }


/* The divider moves inside one fixed-width panel; state and controls stay mounted. */
.trip-details { display:flex; flex-direction:column; min-width:0; min-height:0; }
.trip-details .sidebar-heading { padding:16px 18px 14px; }
.trip-title-row h2 { margin:0; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:17px; font-weight:600; letter-spacing:-.4px; }
.trip-details-content { display:flex; flex:1; flex-direction:column; min-height:0; overflow:hidden; }
.trip-tab-panels { min-height:0; padding:0 18px; }
.trip-details h3 { margin: 0; font-size: 13px; font-weight: 600; }
.trip-primary-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 0; }
.generate-control { display: block; position: relative; border-radius:var(--radius-control); }
.generate-control:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
/* The focusable group explains a disabled button to keyboard and touch users. */
.generate-control > button:disabled { pointer-events: none; }
.trip-details .trip-message { padding: 12px 0; }
@media (max-width:800px) {
  .trip-workspace { top:76px; left:12px; max-width:calc(100vw - 24px); max-height:48dvh; }
}
@media (max-width:540px) {
  .trip-workspace,.trip-workspace:has(.trip-navigation:hover,.trip-navigation :focus-visible) { grid-template-columns:minmax(0,1fr); grid-template-rows:auto minmax(0,1fr); max-height:60dvh; transition:none; }
  .trip-navigation { border-right:0; border-bottom:1px solid var(--line); max-height:20dvh; }
  .trip-details .sidebar-heading { padding:12px 16px; }
  .trip-title-row h2 { font-size:15px; }
}


/* Compact attachments: state belongs to a stable row, including during polling. */
.permit-drop-area { display:flex; flex-direction:column; gap:6px; }
.permit-drop-area.dragover .permit-drop-heading { background:var(--surface-hover); border-color:var(--green); }
.permit-drop-heading { display:flex; align-items:center; justify-content:center; gap:7px; min-height:36px; border:1px dashed var(--line); border-radius:var(--radius-control); color:var(--muted); font-size:12px; }
.permit-drop-heading > svg { flex-shrink:0; }
.permit-browse { padding:0; border:0; background:transparent; color:var(--green); font-size:12px; font-weight:500; }
.permit-browse:hover { text-decoration:underline; text-underline-offset:3px; }
.attachment-list .permit-file { position:relative; display:flex; flex-shrink:0; align-items:center; gap:8px; height:var(--row-height); min-width:0; padding:5px 7px; overflow:clip; border:1px solid transparent; border-radius:var(--radius-control); background:var(--surface); box-sizing:border-box; }
.permit-file:hover { background:var(--surface-hover); }
.permit-file .file-icon { position:relative; display:grid; place-items:center; width:22px; height:22px; padding:0; flex-shrink:0; color:var(--muted); background:var(--surface-hover); border-radius:var(--radius-icon); }
.permit-file-description { flex:1; min-width:0; position:relative; }
.permit-file .row-date { flex-shrink:0; white-space:nowrap; color:var(--muted); font-size:11px; font-variant-numeric:tabular-nums; }
.trip-navigation .row-date { max-width:0; opacity:0; visibility:hidden; overflow:hidden; transition:max-width 420ms cubic-bezier(.22,.7,.2,1),opacity 180ms ease,visibility 0s 420ms; }
.trip-navigation:is(:hover,:has(:focus-visible)) .row-date { max-width:70px; opacity:1; visibility:visible; transition:max-width 420ms cubic-bezier(.22,.7,.2,1),opacity 200ms ease 120ms,visibility 0s; }
@media (max-width:540px) { .trip-navigation .row-date { max-width:70px; opacity:1; visibility:visible; transition:none; } }
.file-name { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--text); font-size:12px; font-weight:500; }
.is-destructive:hover:enabled { color:var(--danger); background:var(--danger-surface); }
.permit-confirm { position:absolute; z-index:2; inset:0; display:flex; align-items:center; gap:5px; padding:3px 5px 3px 10px; background:var(--danger-surface); }
.permit-confirm-label { flex:1; font-size:12px; font-weight:500; }
.permit-confirm button { --control-height:24px; min-width:34px; padding:0 7px; border-radius:var(--radius-icon); font-size:11px; }
.permit-confirm .permit-confirm-yes { color:var(--danger); border-color:var(--danger-border); }
.attachment-list .permit-file.is-confirming { border-color:var(--danger-border); }
.permit-file.is-confirming .permit-confirm { animation:permit-confirm-enter 420ms ease-in-out both; }
.permit-file > .permit-file-description,.permit-file > .file-icon { transition:opacity 280ms ease,transform 420ms ease; }
.permit-file.is-confirming:not(.is-closing) > .permit-file-description,.permit-file.is-confirming:not(.is-closing) > .file-icon { opacity:0; transform:translateX(-12px); }
.permit-file.working { color:var(--muted); background:var(--surface-hover); }
.permit-file.working:before { content:""; position:absolute; inset:0; background:linear-gradient(90deg,transparent 0%,transparent 30%,var(--working-sweep) 50%,transparent 70%,transparent 100%); background-size:240px 100%; background-repeat:repeat-x; animation:permit-upload-sweep 2.4s linear infinite; }
.permit-file.working .file-name { background:linear-gradient(90deg,var(--muted) 0%,var(--muted) 30%,var(--working-text) 50%,var(--muted) 70%,var(--muted) 100%); background-size:240px 100%; background-repeat:repeat-x; background-clip:text; -webkit-background-clip:text; color:transparent; animation:permit-upload-sweep 2.4s linear infinite; }
.permit-empty { padding:0 2px 8px; font-size:12px; line-height:1.6; color:var(--muted); }
.permit-drop-area .upload-error { margin:10px 0 0; font-size:12px; line-height:1.5; overflow-wrap:anywhere; }
.upload-actions { display:flex; justify-content:flex-end; flex-wrap:wrap; gap:8px; margin:10px 0 0; }
@keyframes permit-upload-sweep { from {background-position:0 0;} to {background-position:240px 0;} }
@keyframes permit-confirm-enter { from {transform:translateX(100%);} to {transform:translateX(0);} }
@media(prefers-reduced-motion:reduce) {
  .permit-file.working:before,.permit-file.is-confirming .permit-confirm { animation:none; }
  .permit-file.working .file-name { animation:none; background:none; color:var(--muted); }
  .permit-file > .permit-file-description,.permit-file > .file-icon { transition:none; }
}
@media(forced-colors:active) {
  .permit-file.working .file-name { background:none; color:CanvasText; }
  .permit-file.working { border-style:dashed; }
}
@media(pointer:coarse) {
  .permit-remove,.permit-confirm button { min-width:44px; height:44px; }
  .permit-confirm { padding:1px 2px 1px 10px; }
  .permit-browse { min-height:44px; }
}

/* Lists grow to five complete rows and half of the next; controls stay outside. */
.scroll-area { position:relative; min-height:0; min-width:0; }
.scroll-viewport { overflow-y:auto; overscroll-behavior:contain; scrollbar-width:none; }
.scroll-viewport::-webkit-scrollbar { display:none; }
.scroll-track { position:absolute; right:1px; top:2px; bottom:2px; width:3px; pointer-events:none; opacity:0; transition:opacity var(--scroll-exit) ease; }
.scroll-area.is-scrolling > .scroll-track { opacity:.75; transition-duration:var(--scroll-enter); }
.scroll-thumb { width:100%; border-radius:3px; background:var(--green); }
.attachment-list { display:flex; flex-direction:column; gap:0; list-style:none; padding:0; margin:0; max-height:calc(var(--row-height) * 5.5); }
.trip-scroll-area { display:flex; flex:1; flex-direction:column; }
.trip-list { flex:1; }
.details-scroll-area { display:flex; flex:1; flex-direction:column; }
.dialog-scroll-area { display:flex; flex-direction:column; }
.dialog-content { max-height:calc(100dvh - 42px); padding:28px; }
.ui-tooltip { position:fixed; inset:auto; z-index:100; width:max-content; max-width:min(280px,calc(100vw - 16px)); margin:0; padding:8px 10px; border:0; border-radius:var(--radius-control); background:var(--tooltip-surface); color:var(--on-accent); font:12px/1.5 system, sans-serif; overflow-wrap:anywhere; box-shadow:var(--shadow-panel); pointer-events:none; animation:tooltip-enter var(--motion-fast) ease-out both; }
@keyframes tooltip-enter { from {opacity:0;} to {opacity:1;} }

.route-actions { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:6px; flex-shrink:0; margin:12px 18px 18px; }
.route-actions .route-create,.trip-actions .route-create { width:100%; padding-inline:4px; }
.permit-file .row-option { display:block; width:100%; border:0; padding:0; background:none; text-align:left; color:inherit; font:inherit; font-size:12px; font-weight:500; }
/* Stretch the native selection button over its row; keep independent actions above it. */
.permit-file-description:has(> .row-option) { position:static; }
.permit-file .row-option::after { content:""; position:absolute; inset:0; }
.permit-file:has(.row-option) > .permit-remove { position:relative; z-index:1; }
.permit-file:has(.row-option:focus-visible) { outline:3px solid var(--focus); outline-offset:3px; }
.permit-file .row-option:focus-visible { outline:none; }
.permit-file.is-selected:not(.is-confirming) { border-color:var(--selected-border); background:var(--surface-selected); }
.route-download { text-decoration:none; }
.route-download:hover { color:var(--green); background:var(--surface-hover); }
#route-remove-error { color:var(--danger); font-size:12px; overflow-wrap:anywhere; }
@media(pointer:coarse) {
  .route-download { min-width:44px; height:44px; }
}

.attachment-list .route-draft { border-color:var(--draft-border); background:var(--draft-surface); }
.route-draft .file-name { color:var(--muted); }

.trip-tabs { display:flex; flex-shrink:0; gap:22px; margin:0 18px 17px; border-bottom:1px solid var(--line); }
.trip-tab { position:relative; display:flex; align-items:center; justify-content:flex-start; gap:7px; min-width:0; min-height:38px; padding:2px 0 10px; border:0; border-radius:0; background:transparent; color:var(--muted); font-size:12px; font-weight:500; }
.trip-tab[aria-selected="true"] { color:var(--green); }
.trip-tab[aria-selected="true"]::after { content:""; position:absolute; bottom:-1px; left:0; right:0; height:2px; border-radius:2px; background:var(--green); }
.trip-tab:hover { color:var(--green); }
.trip-tab .count { min-width:0; padding:0; background:transparent; font-size:11px; }
.tab-activity { width:6px; height:6px; border-radius:50%; background:var(--green); animation:tab-activity-pulse 1.6s ease-in-out infinite; }
@keyframes tab-activity-pulse { 50% { opacity:.35; } }
@media (prefers-reduced-motion:reduce) { .tab-activity { animation:none; } }
@media (pointer:coarse) { .trip-tab { min-height:44px; } }

.trip-rows { max-height:none; overflow:visible; }
.trip-title-row { display:flex; flex:1; align-items:center; gap:6px; min-width:0; max-width:100%; }
.trip-title-row h2 { flex:1; min-width:0; }
.panel-collapse svg { transition:transform 360ms cubic-bezier(.22,.7,.2,1); }
.panel-collapse[aria-expanded="false"] svg { transform:rotate(180deg); }


@media (max-width:540px) { .dialog-content { padding:22px; } }
@media (pointer:coarse) {
  :root { --row-height:48px; --control-height:44px; }
  :is(.permit-remove,.icon-button) { min-width:44px; height:44px; }
}
@media (forced-colors:active) { .scroll-thumb { background:Highlight; } }

/* An editing row keeps its label readable while selection is disabled. */
.route-draft .row-option:disabled { opacity:1; }

#open-feedback { width:32px; height:32px; }
#feedback-message { display:block; width:100%; box-sizing:border-box; margin-top:10px; padding:12px; border:1px solid var(--line); border-radius:var(--radius-control); background:var(--surface); color:var(--text); resize:vertical; min-height:140px; max-height:45dvh; line-height:1.6; }
#feedback-form label { display:block; margin-top:18px; }
#feedback-form label, #feedback-status { font-size:13px; }
#feedback-status { color:var(--green); }
@media(pointer:coarse) { #open-feedback { min-width:44px; height:44px; } }

/* Settings is a single dialog with category navigation and local form actions. */
#agent-settings { width:min(800px,calc(100vw - 40px)); height:min(620px,calc(100dvh - 48px)); max-height:calc(100dvh - 48px); }
#agent-settings[open] { display:flex; flex-direction:column; }
#agent-settings [hidden] { display:none !important; }
.settings-header { display:flex; flex-shrink:0; justify-content:space-between; align-items:flex-start; gap:20px; padding:24px 28px 20px; border-bottom:1px solid var(--line); }
.settings-header h2 { font-size:23px; letter-spacing:-.5px; }
.settings-header .icon-button { min-width:44px; min-height:44px; margin:-8px -8px 0 0; }
.settings-layout { display:flex; flex:1; min-height:0; }
.settings-navigation { display:flex; flex-direction:column; gap:5px; flex:0 0 180px; padding:20px 12px; border-right:1px solid var(--line); background:var(--surface-hover); }
.settings-tab { display:flex; min-width:0; align-items:center; gap:10px; min-height:44px; width:100%; padding:10px 12px; border:0; border-radius:var(--radius-control); background:transparent; color:var(--muted); font-size:13px; text-align:left; transition:background var(--motion-fast),color var(--motion-fast); }
.settings-tab svg { flex-shrink:0; }
.settings-tab:hover:not(:disabled) { background:var(--surface); color:var(--foreground); }
.settings-tab[aria-selected="true"] { background:var(--surface-selected); color:var(--green); font-weight:600; }
.settings-scroll-area { display:flex; flex:1; min-width:0; min-height:0; }
.settings-content { flex:1; min-width:0; min-height:0; padding:28px; }
.settings-panel h3 { margin:0; font-size:19px; font-weight:550; letter-spacing:-.3px; }
.settings-profile { display:flex; align-items:center; gap:14px; padding:18px 0 26px; }
.settings-profile .avatar { width:52px; height:52px; font-size:18px; }
.settings-profile > div { display:grid; gap:6px; min-width:0; }
.settings-profile strong { font-size:15px; font-weight:550; overflow-wrap:anywhere; }
.settings-profile > div > span { font-size:13px; color:var(--muted); overflow-wrap:anywhere; }
#agent-settings .settings-fields { display:block; margin:0; }
.settings-row { display:flex; align-items:center; justify-content:space-between; gap:20px; border-bottom:1px solid var(--line); padding:18px 0; min-width:0; }
.settings-row > :first-child { min-width:0; }
.settings-label { display:block; font-size:13px; font-weight:550; color:var(--foreground); }
.settings-hint { display:block; margin-top:5px; color:var(--muted); font-size:12px; line-height:1.5; }
#agent-settings .settings-row p { margin:5px 0 0; font-size:12px; }
#agent-settings .settings-row select { width:180px; flex-shrink:0; min-height:44px; }
#agent-settings .settings-switch { margin:0; }
#agent-settings .modal-footer { border:0; margin-top:20px; padding-top:0; }
#agent-settings .modal-footer button { min-height:44px; }
#agent-settings-status { color:var(--green); }
#agent-settings-status:empty { display:none; }
.settings-panel:focus-visible { outline:3px solid var(--focus); outline-offset:4px; }
.telegram-settings h4 { margin:0; font-size:14px; font-weight:550; }
.settings-connection-copy { flex:1; }
.settings-connection-copy p { overflow-wrap:anywhere; }
.telegram-actions { display:flex; flex-shrink:0; flex-wrap:wrap; justify-content:flex-end; gap:8px; max-width:190px; }
.telegram-actions :is(button,a) { min-height:44px; }
.telegram-actions a { display:inline-flex; align-items:center; text-decoration:none; }
@media(max-width:620px) {
  #agent-settings { width:calc(100vw - 20px); height:calc(100dvh - 24px); max-height:calc(100dvh - 24px); }
  .settings-header { padding:20px; }
  .settings-layout { flex-direction:column; }
  .settings-navigation { flex:0 0 auto; flex-direction:row; gap:2px; padding:8px; border-right:0; border-bottom:1px solid var(--line); }
  .settings-tab { justify-content:center; gap:7px; padding:10px 6px; font-size:12px; }
  .settings-tab svg { width:16px; height:16px; }
  .settings-content { padding:24px 20px; }
  .settings-row { gap:14px; }
  #agent-settings .settings-row select { width:42%; min-width:100px; }
  .telegram-settings .settings-row { align-items:flex-start; flex-direction:column; }
  .telegram-actions { justify-content:flex-start; max-width:none; }
}

@media(max-width:380px) { .settings-tab svg { display:none; } }
