* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --text: #18212f;
  --muted: #667085;
  --line: #d8dee7;
  --primary: #2563eb;
  --primary-strong: #174ea6;
  --success: #12805c;
  --warning: #a15c12;
  --danger: #b93815;
  --shadow: 0 14px 40px rgba(24, 33, 47, .08);
}

html {
  scroll-behavior: smooth;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-width: 320px;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  letter-spacing: 0;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  font-size: 16px;
  letter-spacing: 0;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 750;
  cursor: pointer;
}

button:hover {
  border-color: #9db7ef;
}

button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

button.danger {
  color: var(--danger);
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.mobile-topbar,
.bottom-nav {
  display: none;
}

.settings-links {
  display: grid;
  gap: 8px;
}

.settings-links button {
  justify-content: flex-start;
  width: 100%;
  padding: 12px;
  text-align: left;
}

body.auth-required {
  padding-bottom: 0;
}

body.auth-required .mobile-topbar,
body.auth-required .sidebar,
body.auth-required .page-head,
body.auth-required .bottom-nav {
  display: none !important;
}

body.auth-required .app-shell {
  display: block;
}

body.auth-required .main {
  min-height: 100vh;
  padding: 0;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #f5f7fa 0%, #eef4ff 100%);
}

.auth-panel {
  width: min(460px, 100%);
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-brand {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: center;
}

.auth-brand h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.auth-brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.auth-tabs button.active {
  background: #172033;
  border-color: #172033;
  color: #fff;
}

.auth-section {
  display: grid;
  gap: 12px;
}

.auth-section[hidden] {
  display: none;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 334px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #172033;
  color: #fff;
  font-weight: 900;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.trip-switch {
  width: 100%;
  min-height: 62px;
  padding: 12px;
  text-align: left;
  background: var(--surface-soft);
}

.trip-switch span,
.trip-switch small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trip-switch small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.search-box {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search-box input,
.trip-name-title,
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.search-box input {
  padding: 12px 13px;
  font-size: 16px;
}

.search-box input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}

.filter-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.filter {
  min-height: 34px;
  padding: 6px 10px;
  color: #3f4a5c;
  font-size: 13px;
}

.filter.active {
  background: #172033;
  border-color: #172033;
  color: #fff;
}

.day-list {
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.day-card {
  width: 100%;
  margin: 0 0 10px;
  padding: 12px;
  text-align: left;
  background: #fff;
}

.day-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.day-card-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.day-card strong {
  display: block;
  margin-top: 6px;
  font-size: 15px;
  line-height: 1.4;
}

.day-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

.main {
  min-width: 0;
  max-width: 100%;
  padding: 26px;
}

.page-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 18px;
  margin-bottom: 18px;
}

.title-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.trip-name-title {
  max-width: 720px;
  margin: 0;
  font-size: 30px;
  font-weight: 850;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.edit-title-btn {
  flex: 0 0 auto;
}

.trip-meta {
  margin: 2px 0 0;
  color: var(--muted);
}

.head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.head-actions button {
  padding: 8px 12px;
}

.content {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.itinerary-stream {
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.day-detail {
  overflow: hidden;
  scroll-margin-top: 74px;
}

.day-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 850;
}

.day-hero h2,
.view-title {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
}

.route-pill {
  display: inline-flex;
  max-width: 100%;
  margin-top: 12px;
  padding: 7px 10px;
  border-radius: 8px;
  background: #e8f0ff;
  color: var(--primary-strong);
  font-size: 14px;
  font-weight: 800;
}

.hero-actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(280px, .82fr);
  gap: 16px;
  padding: 16px;
}

.block {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.block h3 {
  margin: 0 0 12px;
  font-size: 17px;
}

.insight-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(220px, .9fr) minmax(220px, .9fr);
  gap: 12px;
}

.insight-card {
  position: relative;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .05);
}

.insight-card.primary {
  background: #f7fbff;
  border-color: #cfe2ff;
}

.insight-card h3 {
  margin: 0;
  font-size: 20px;
}

.insight-card p {
  margin: 10px 0 14px;
  color: var(--muted);
}

.mini-kpi {
  display: inline-grid;
  min-width: 72px;
  padding: 8px 10px;
  margin: 0 0 12px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.mini-kpi span {
  font-size: 22px;
  font-weight: 850;
}

.mini-kpi small {
  color: var(--muted);
  font-weight: 750;
}

.summary {
  margin: 0 0 16px;
  font-size: 16px;
}

.timeline {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #edf0f4;
}

.timeline li:last-child {
  border-bottom: 0;
}

.timeline time {
  color: var(--primary);
  font-weight: 850;
}

.plain-list {
  margin: 0;
  padding-left: 19px;
}

.plain-list li {
  margin-bottom: 8px;
}

.fact-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.fact {
  padding: 11px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.fact span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.fact strong {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.place-grid,
.doc-grid,
.trip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.place-link,
.doc-card,
.trip-card {
  display: block;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
}

.place-link:hover,
.doc-card:hover {
  border-color: var(--primary);
}

.place-link p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.place-actions,
.route-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.place-actions a,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  font-size: 14px;
}

.place-actions a:hover,
.button-link:hover {
  border-color: var(--primary);
  color: var(--primary-strong);
}

.route-check,
.inbox-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.route-check p,
.inbox-panel p {
  margin: 0;
  color: var(--muted);
}

.inbox-code {
  display: grid;
  gap: 4px;
  min-width: min(280px, 100%);
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.inbox-code span,
.inbox-code small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.inbox-code strong {
  overflow-wrap: anywhere;
}

.doc-card strong,
.trip-card strong {
  display: block;
  overflow-wrap: anywhere;
}

.doc-card p,
.trip-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.doc-card-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.doc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.doc-actions button {
  flex: 1 1 112px;
  min-height: 36px;
  padding: 7px 10px;
  font-size: 13px;
}

.doc-card.needs-review {
  border-color: #f2c36b;
  background: #fffaf0;
}

.doc-timeline {
  display: grid;
  gap: 12px;
}

.doc-timeline-item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.doc-timeline-item time {
  position: sticky;
  top: 72px;
  padding-top: 13px;
  color: var(--primary);
  font-weight: 850;
}

.doc-filter-panel {
  padding: 14px;
}

.doc-past {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.doc-past summary {
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 850;
}

.doc-past .doc-timeline {
  padding: 0 16px 16px;
}

.muted-line,
.inbox-inline {
  margin: 8px 0 0;
  color: var(--muted);
}

.badge-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.trip-card-title,
.section-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.trip-card-actions button {
  flex: 1 1 88px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #eef3f8;
  color: #415064;
  font-size: 12px;
  font-weight: 800;
}

.badge.confirmed {
  background: #e4f7ed;
  color: var(--success);
}

.badge.review {
  background: #fff3d8;
  color: var(--warning);
}

.notice {
  padding: 14px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #174ea6;
}

.empty {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.view-head {
  padding: 22px;
}

.view-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.stat {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.stat strong {
  display: block;
  font-size: 24px;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

details.day-docs {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

details.day-docs summary {
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 800;
}

details.day-docs .doc-grid {
  padding: 0 14px 14px;
}

dialog {
  position: fixed;
  width: min(720px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: min(88dvh, 820px);
  overflow-x: hidden;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
}

dialog::backdrop {
  background: rgba(15, 23, 42, .38);
}

.dialog-card {
  width: 100%;
  max-height: min(88dvh, 820px);
  max-width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 22px;
}

.dialog-head p {
  margin: 5px 0 0;
  color: var(--muted);
}

.close-btn {
  width: 40px;
  padding: 0;
  flex: 0 0 auto;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

fieldset.field {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

fieldset.field legend {
  padding: 0 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field input,
.field select,
.field textarea {
  padding: 11px 12px;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.route-stops {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.timeline-inputs {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.timeline-input-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 38px;
  gap: 8px;
  align-items: center;
}

.timeline-input-row input,
.route-stop input {
  min-width: 0;
}

.icon-btn.small {
  width: 38px;
  min-height: 38px;
}

.suggestion-text,
.copy-status {
  margin: 8px 0 0;
  color: var(--primary-strong);
  font-weight: 750;
}

.picker-list {
  display: grid;
  max-height: 56vh;
  overflow: auto;
}

.search-card input {
  font-size: 16px;
}

.login-methods {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.email-login-box {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.email-login-actions {
  display: grid;
  grid-template-columns: auto minmax(120px, 180px) auto;
  gap: 8px;
  align-items: end;
}

.email-login-actions.single {
  grid-template-columns: max-content;
}

.email-login-actions .muted-line {
  align-self: center;
  margin: 0;
}

.email-login-actions .field {
  margin: 0;
}

.secondary-auth-box {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.secondary-auth-box h4 {
  margin: 0;
  font-size: 16px;
}

.account-card {
  max-width: min(680px, calc(100vw - 24px));
}

.account-hero {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px;
  margin: 4px 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.account-avatar {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--text);
  color: white;
  font-weight: 850;
}

.account-hero strong,
.account-hero span {
  display: block;
}

.account-hero strong {
  font-size: 18px;
}

.account-hero span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 14px;
}

.account-list {
  display: grid;
  gap: 10px;
}

.account-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 64px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.account-row strong,
.account-row small {
  display: block;
}

.account-row small {
  margin-top: 3px;
  color: var(--muted);
  font-weight: 650;
}

.account-row b {
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}

.danger-row strong {
  color: var(--danger);
}

.account-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 84%, white);
}

.account-section[hidden] {
  display: none;
}

.social-auth-grid,
.account-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.social-auth-grid button {
  min-height: 44px;
  font-weight: 850;
}

.account-space-list {
  display: grid;
  gap: 8px;
}

.account-space {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.account-space:last-child {
  border-bottom: 0;
}

.account-space strong,
.account-space small,
.inbox-inline span,
.inbox-inline small {
  display: block;
}

.account-space small,
.inbox-inline small {
  color: var(--muted);
}

.email-login-actions.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.code-field input {
  text-align: center;
  letter-spacing: 0;
}

.block.flat {
  box-shadow: none;
}

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

.error-text {
  display: none;
  margin-top: 12px;
  color: var(--danger);
  font-weight: 800;
}

.error-text.show {
  display: block;
}

.share-box {
  width: 100%;
  min-height: 220px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  line-height: 1.5;
  resize: vertical;
}

.share-box.short {
  min-height: 52px;
  max-height: 120px;
  resize: none;
}

.load-more-days {
  width: 100%;
  min-height: 50px;
  background: #172033;
  color: #fff;
}

.app-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 90;
  transform: translate(-50%, 12px);
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  border-radius: 8px;
  background: #172033;
  color: #fff;
  font-weight: 850;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}

.app-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1080px) {
  body {
    padding-bottom: 72px;
  }

  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: 58px;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    gap: 8px;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(12px);
  }

  .icon-btn {
    width: 44px;
    padding: 0;
  }

  .search-trigger {
    font-size: 28px;
    line-height: 1;
  }

  .mobile-trip {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: var(--surface-soft);
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 50;
    top: 58px;
    left: 0;
    width: min(320px, 84vw);
    height: calc(100vh - 58px);
    transform: translateX(-105%);
    transition: transform .18s ease;
    box-shadow: var(--shadow);
  }

  .sidebar .search-box,
  .sidebar .filter-row,
  .sidebar .day-list {
    display: none;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    padding: 16px;
    min-width: 0;
  }

  .page-head {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .head-actions {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .head-actions button {
    white-space: nowrap;
  }

  .trip-name-title {
    max-width: 100%;
    font-size: 25px;
  }

  .page-head {
    margin-bottom: 12px;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .insight-grid {
    grid-template-columns: 1fr;
  }

  .bottom-nav {
    position: fixed;
    z-index: 45;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(12px);
  }

  .bottom-nav button {
    min-width: 0;
    min-height: 48px;
    padding: 6px 4px;
    font-size: 14px;
  }

  .bottom-nav button {
    min-height: 44px;
    padding: 8px 4px;
    background: var(--surface-soft);
    font-size: 13px;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  .main {
    padding: 12px;
  }

  .day-hero {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .hero-actions {
    width: 100%;
  }

  .hero-actions button {
    flex: 1;
  }

  .day-hero h2,
  .view-title {
    font-size: 24px;
  }

  .detail-grid {
    padding: 12px;
  }

  .block {
    padding: 15px;
  }

  .timeline li {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 9px;
  }

  .doc-timeline-item {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .doc-timeline-item time {
    position: static;
    padding-top: 0;
  }

  .place-grid,
  .doc-grid,
  .trip-grid,
  .stats-row,
  .form-grid,
  .route-stops,
  .route-check,
  .inbox-panel {
    grid-template-columns: 1fr;
  }

  .route-actions,
  .place-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .timeline-input-row {
    grid-template-columns: 92px minmax(0, 1fr) 38px;
  }

  .email-login-actions {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  input,
  select,
  textarea,
  .field input,
  .field select,
  .field textarea,
  .share-box {
    font-size: 16px !important;
    touch-action: manipulation;
  }

  dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 24px);
  }

  .dialog-card {
    max-height: calc(100dvh - 24px);
  }

  .dialog-card {
    padding: 16px;
  }

  .dialog-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .dialog-actions button {
    width: 100%;
  }

  .social-auth-grid,
  .account-action-grid,
  .email-login-actions.compact {
    grid-template-columns: 1fr;
  }
}
