:root {
  color-scheme: light dark;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #202624;
  --muted: #707975;
  --line: #e3e7e4;
  --soft: #f0f3f1;
  --accent: #47775d;
  --accent-strong: #315942;
  --accent-soft: #e6efe9;
  --danger: #ad4949;
  --danger-soft: #faeeee;
  --shadow: 0 18px 55px rgba(20, 32, 25, .15);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151917;
    --surface: #202623;
    --text: #edf2ee;
    --muted: #a1aca5;
    --line: #343d38;
    --soft: #29322d;
    --accent: #8bb99b;
    --accent-strong: #b0d3bb;
    --accent-soft: #2d4034;
    --danger: #e39a9a;
    --danger-soft: #402a2a;
    --shadow: 0 18px 55px rgba(0, 0, 0, .42);
  }
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--bg); }
body { margin: 0; color: var(--text); background: var(--bg); font-size: 15px; line-height: 1.5; }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 42%, transparent); outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: .42; }
[hidden] { display: none !important; }

.page-shell { min-height: 100svh; display: flex; flex-direction: column; }
.site-header { width: min(100%, 820px); padding: 22px 24px 18px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-width: 0; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; color: var(--accent); }
.brand-mark svg { width: 28px; height: 28px; }
.brand-title { font-size: 17px; font-weight: 700; letter-spacing: -.035em; white-space: nowrap; }
.header-tools { display: flex; align-items: center; gap: 14px; }
.save-status { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; }
.save-status::before { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 7px 1px 0; border-radius: 50%; background: #6f9c7e; }
.save-status[data-state="saving"]::before { background: #c6954c; }
.save-status[data-state="error"]::before { background: #c55e5e; }
.menu-wrap { position: relative; }
.icon-button { min-width: 36px; min-height: 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; }
.menu-button { font-size: 24px; letter-spacing: 1px; line-height: 1; padding: 0 0 7px; }
.menu-panel { position: absolute; z-index: 10; top: calc(100% + 8px); right: 0; width: 210px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.menu-item { display: block; width: 100%; text-align: left; padding: 10px 11px; border: 0; border-radius: 7px; background: transparent; font-size: 13px; cursor: pointer; }
.menu-item:hover { background: var(--soft); }
.menu-divider { border-top: 1px solid var(--line); margin: 5px 3px; }

main { width: min(100%, 820px); margin: 0 auto; flex: 1; padding: 0 24px 32px; }
.message-view { min-height: 56vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--muted); gap: 12px; }
.message-view p { margin: 0; }
.message-view h1 { color: var(--text); font-size: 20px; margin: 0; }
.loading-dot { width: 22px; height: 22px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.fatal-view { gap: 16px; }
.fatal-view p { max-width: 380px; }

.login-view { width: min(100%, 360px); margin: 12vh auto 0; padding: 30px 0 48px; }
.login-symbol { width: 52px; height: 52px; display: grid; place-items: center; margin-bottom: 20px; background: var(--accent-soft); border-radius: 15px; color: var(--accent); }
.login-symbol svg { width: 28px; height: 28px; }
.login-view h1 { margin: 0 0 7px; font-size: 23px; letter-spacing: -.045em; }
.login-copy { margin: 0 0 26px; }
.muted { color: var(--muted); }
.login-form { display: grid; gap: 9px; }
.field-label { display: block; font-size: 13px; color: var(--muted); }
.login-form input, .dialog-input { min-width: 0; width: 100%; height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text); }
.form-error { margin: 0; color: var(--danger); font-size: 13px; }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 15px; border: 1px solid transparent; border-radius: 9px; font-size: 13px; font-weight: 650; cursor: pointer; transition: background .12s ease, border-color .12s ease; }
.primary-button { background: var(--accent); color: #fff; }
.primary-button:hover { background: var(--accent-strong); }
.primary-button.danger-action { background: var(--danger); color: #fff; }
.primary-button.danger-action:hover { filter: brightness(.92); }
@media (prefers-color-scheme: dark) { .primary-button { color: #17251b; } }
.secondary-button { background: var(--surface); border-color: var(--line); }
.secondary-button:hover { background: var(--soft); }
.full-width { width: 100%; margin-top: 6px; min-height: 45px; }

.app-view { padding-top: 18px; }
.trip-nav-row { min-width: 0; display: flex; align-items: center; gap: 10px; }
.trip-tabs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; padding: 2px 1px 7px; }
.trip-tabs::-webkit-scrollbar { display: none; }
.trip-tab { display: inline-flex; align-items: center; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface); }
.trip-tab[aria-selected="true"] { border-color: var(--accent); background: var(--accent-soft); }
.trip-tab-select { min-height: 38px; max-width: 185px; padding: 0 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 0; background: transparent; font-size: 13px; cursor: pointer; }
.trip-tab[aria-selected="true"] .trip-tab-select { color: var(--accent-strong); font-weight: 700; }
.trip-tab-menu { width: 29px; min-height: 36px; padding: 0 7px 4px 2px; color: var(--muted); border: 0; background: transparent; font-size: 19px; line-height: 1; cursor: pointer; }
.add-trip-button { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px; min-height: 38px; padding: 0 10px; border: 1px dashed var(--line); border-radius: 9px; background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; }
.add-trip-button span:first-child { font-size: 18px; line-height: 1; }
.add-trip-button:hover { border-color: var(--accent); color: var(--accent); }

.list-heading-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-top: 26px; }
.list-heading-copy { min-width: 0; }
.active-trip-name { overflow-wrap: anywhere; margin: 0; font-size: 23px; font-weight: 740; line-height: 1.25; letter-spacing: -.045em; }
.progress-copy { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.trip-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.quiet-button { border: 0; border-radius: 7px; min-height: 34px; padding: 0 8px; background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; white-space: nowrap; }
.quiet-button:hover { background: var(--soft); color: var(--text); }
.danger-text { color: var(--danger) !important; }
.progress-track { height: 3px; margin-top: 15px; overflow: hidden; border-radius: 5px; background: var(--line); }
.progress-track span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .18s ease; }
.tools-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 20px 0 7px; }
.search-box { flex: 0 1 255px; min-width: 150px; display: flex; align-items: center; gap: 7px; height: 36px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--muted); }
.search-box svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.search-box input { min-width: 0; width: 100%; height: 100%; border: 0; padding: 0; outline: 0; color: var(--text); background: transparent; font-size: 12px; }
.search-box input:focus-visible { outline: 0; }
.search-box input::placeholder { color: var(--muted); }
.clear-search { border: 0; background: transparent; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; }
.bulk-actions { display: flex; align-items: center; gap: 3px; white-space: nowrap; }
.bulk-actions .quiet-button { min-height: 33px; }
.search-note { margin: 0 0 7px; color: var(--muted); font-size: 11px; }

.item-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.item-row { display: flex; align-items: center; gap: 8px; min-height: 55px; border-bottom: 1px solid var(--line); }
.check-area { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 8px 0 8px 2px; cursor: pointer; }
.check-area input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.check-mark { flex: 0 0 auto; width: 21px; height: 21px; display: grid; place-items: center; border: 1.5px solid #c4ccc6; border-radius: 6px; color: transparent; background: var(--surface); transition: background .12s ease, border-color .12s ease; }
.check-mark svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 2.2; fill: none; }
.check-area input:checked + .check-mark { color: white; border-color: var(--accent); background: var(--accent); }
.check-area input:focus-visible + .check-mark { outline: 3px solid color-mix(in srgb, var(--accent) 42%, transparent); outline-offset: 2px; }
.item-title { min-width: 0; overflow-wrap: anywhere; color: var(--text); font-size: 14px; line-height: 1.45; }
.item-row.is-checked .item-title { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.item-actions { display: flex; align-items: center; gap: 1px; flex: 0 0 auto; }
.item-action { display: grid; place-items: center; width: 30px; height: 34px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 15px; cursor: pointer; }
.item-action:hover { background: var(--soft); color: var(--text); }
.item-action svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.item-action.delete:hover { background: var(--danger-soft); color: var(--danger); }
.item-edit-form { display: flex; align-items: center; flex: 1; min-width: 0; gap: 6px; padding: 7px 0; }
.item-edit-form input { flex: 1; min-width: 0; height: 38px; border: 1px solid var(--accent); border-radius: 7px; background: var(--surface); color: var(--text); padding: 0 9px; }
.item-edit-form button { min-height: 34px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); font-size: 12px; cursor: pointer; }
.item-edit-form button.save-edit { background: var(--accent); border-color: var(--accent); color: #fff; }
.empty-list-state { padding: 28px 12px; text-align: center; border-bottom: 1px solid var(--line); }
.empty-list-state p { margin: 0 0 3px; font-size: 14px; }
.empty-list-state span { color: var(--muted); font-size: 12px; }
.add-item-form { display: flex; gap: 8px; margin-top: 20px; padding: 9px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 5px 18px rgba(27, 37, 30, .035); }
.add-item-form input { flex: 1; min-width: 0; height: 38px; padding: 0 7px; color: var(--text); background: transparent; border: 0; outline: 0; font-size: 14px; }
.add-item-form input:focus-visible { outline: 0; }
.add-item-form input::placeholder { color: var(--muted); }
.add-item-form .primary-button { min-width: 64px; }
.input-hint { margin: 7px 0 0 3px; color: var(--muted); font-size: 11px; }
.empty-state { margin: 10vh auto 0; text-align: center; padding: 24px 0; max-width: 360px; }
.empty-mark { display: grid; place-items: center; width: 46px; height: 46px; margin: 0 auto 18px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); font-size: 26px; }
.empty-state h1 { margin: 0 0 7px; font-size: 21px; letter-spacing: -.04em; }
.empty-state p { margin: 0 auto 20px; max-width: 300px; color: var(--muted); font-size: 13px; }
.site-footer { width: min(100%, 820px); display: flex; justify-content: space-between; gap: 12px; margin: 0 auto; padding: 17px 24px max(18px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }

.app-dialog { width: min(calc(100% - 32px), 390px); padding: 0; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.app-dialog::backdrop { background: rgba(16, 22, 18, .42); backdrop-filter: blur(2px); }
.app-dialog form { padding: 21px; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.dialog-header h2 { margin: 0; font-size: 18px; letter-spacing: -.03em; }
.dialog-close { width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 23px; cursor: pointer; }
.dialog-message { margin: 0 0 17px; font-size: 13px; line-height: 1.6; color: var(--muted); white-space: pre-line; }
.dialog-input { margin-top: 7px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 21px; }
.dialog-actions .primary-button { min-width: 75px; }
.toast { position: fixed; z-index: 20; bottom: max(18px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 28px); display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 15px; border: 1px solid var(--line); border-radius: 11px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); font-size: 12px; }
.toast button { border: 0; border-radius: 6px; padding: 5px 7px; background: transparent; color: #b6ddc3; font-weight: 700; font-size: 12px; cursor: pointer; white-space: nowrap; }
.toast .toast-close { color: inherit; font-size: 18px; line-height: 1; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

@media (max-width: 560px) {
  .site-header { padding: 16px 16px 14px; }
  main { padding: 0 16px 24px; }
  .brand-title { font-size: 16px; }
  .header-tools { gap: 9px; }
  .save-status { font-size: 11px; }
  .trip-nav-row { gap: 7px; }
  .trip-tab-select { max-width: 140px; padding: 0 10px; }
  .add-trip-button { width: 38px; justify-content: center; padding: 0; }
  .add-trip-button span:last-child { display: none; }
  .list-heading-row { margin-top: 22px; gap: 6px; }
  .active-trip-name { font-size: 21px; }
  .trip-actions { gap: 0; }
  .trip-actions .quiet-button { font-size: 11px; padding: 0 6px; }
  .tools-row { align-items: flex-start; flex-direction: column; gap: 5px; margin-top: 17px; }
  .search-box { width: 100%; flex-basis: 36px; }
  .bulk-actions { align-self: flex-end; }
  .bulk-actions .quiet-button { min-height: 30px; }
  .item-row { gap: 3px; }
  .check-area { gap: 10px; }
  .item-title { font-size: 14px; }
  .item-actions { gap: 0; }
  .item-action { width: 29px; }
  .site-footer { padding-right: 16px; padding-left: 16px; }
}

@media (max-width: 370px) {
  .save-status { max-width: 85px; overflow: hidden; text-overflow: ellipsis; }
  .trip-actions .quiet-button { padding: 0 4px; }
  .item-action { width: 26px; }
  .item-edit-form { flex-wrap: wrap; }
  .item-edit-form input { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* Checklist groups */
.group-toolbar { display:flex; align-items:center; justify-content:space-between; gap:10px; margin:15px 0 7px; }
.group-toolbar-label { color:var(--muted); font-size:12px; font-weight:600; }
.group-section { list-style:none; margin:0; padding:0; border-top:1px solid var(--line); }
.group-heading { display:flex; align-items:center; gap:8px; min-height:46px; padding:0 3px; border-bottom:1px solid var(--line); background:var(--soft); }
.group-collapse { flex:1; display:flex; align-items:center; gap:8px; min-width:0; padding:10px 0; border:0; background:transparent; color:var(--text); text-align:left; font-weight:650; font-size:13px; cursor:pointer; }
.group-chevron { display:inline-block; width:8px; height:8px; border-right:1.7px solid currentColor; border-bottom:1.7px solid currentColor; transform:rotate(45deg) translateY(-2px); transition:transform .12s ease; }
.group-collapse[aria-expanded="false"] .group-chevron { transform:rotate(-45deg); }
.group-count { color:var(--muted); font-size:11px; font-weight:500; }
.group-mini-action { border:0; background:transparent; color:var(--muted); padding:6px 5px; border-radius:5px; font-size:11px; cursor:pointer; }
.group-mini-action:hover { background:var(--surface); color:var(--text); }
.group-items { list-style:none; padding:0; margin:0; }
.group-items[hidden] { display:none; }
.group-items .item-row { padding-left:8px; }
.group-select { max-width:145px; min-width:92px; height:36px; border:1px solid var(--line); border-radius:7px; background:var(--surface); color:var(--text); padding:0 7px; font-size:12px; }
.add-item-form .group-select { align-self:center; }
@media (max-width:420px) { .group-select { max-width:112px; min-width:82px; } .add-item-form { gap:5px; padding:7px; } .add-item-form input { font-size:13px; } }

.empty-group { padding:13px 12px; color:var(--muted); font-size:12px; border-bottom:1px solid var(--line); }

/* CheckTripst group actions and drag-to-reorder */
.group-mini-action { display:grid; place-items:center; width:30px; height:32px; padding:0; flex:0 0 auto; }
.group-mini-action svg { width:16px; height:16px; stroke:currentColor; stroke-width:1.7; fill:none; stroke-linecap:round; stroke-linejoin:round; }
.group-delete-action:hover { color:var(--danger); background:var(--danger-soft); }
.item-row { transition: background .12s ease, opacity .12s ease; }
.item-row.is-dragging { opacity:.38; }
.item-row.drag-over { background:var(--soft); outline:2px dashed var(--accent); outline-offset:-3px; }
.drag-handle { cursor:grab; touch-action:none; }
.drag-handle:active { cursor:grabbing; }
.drag-handle:disabled { opacity:.35; cursor:default; }
.item-edit-form { flex-wrap:wrap; }
.item-edit-form input { flex:1 1 150px; }
.item-edit-form .edit-group-select { flex:0 1 150px; max-width:150px; }
@media (max-width:420px) {
  .item-edit-form .edit-group-select { flex:1 1 100%; max-width:none; }
  .item-edit-form button { flex:1; }
}

/* Nested checklist items: compact rows with indentation only */
.item-row.has-children { flex-wrap: wrap; min-height: 0; }
.item-row.has-children > .check-area { min-height: 46px; padding-top: 5px; padding-bottom: 5px; }
.nested-item-list {
  list-style: none;
  flex: 0 0 100%;
  width: 100%;
  box-sizing: border-box;
  margin: -9px 0 0;
  padding: 0;
  border: 0;
}
.nested-item-list .item-row {
  min-height: 36px;
  padding: 0;
  border-bottom: 0;
}
.nested-item-list .check-area {
  min-height: 36px;
  padding: 4px 0 4px 30px;
  gap: 9px;
}
.nested-item-list .check-mark { width: 18px; height: 18px; border-radius: 5px; }
.nested-item-list .item-title { font-size: 13px; line-height: 1.35; }
.nested-item-list .item-actions { opacity: .72; }
.nested-item-list .item-action { width: 27px; height: 30px; }
.nested-item-list .item-actions .drag-handle { display: none; }
.nested-item-list .item-title::before { content: none; }
.nested-item-list .nested-item-list { margin: 0; }
@media (max-width: 420px) {
  .nested-item-list .check-area { padding-left: 26px; }
  .nested-item-list .item-row { min-height: 34px; }
  .nested-item-list .check-area { min-height: 34px; }
}
.edit-add-child {
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}
.edit-add-child:hover { color: var(--text); }
@media (max-width: 420px) {
  .nested-item-list { margin-left: 0; padding-left: 0; }
  .nested-item-list .item-row { min-height: 30px; }
  .nested-item-list .item-title { font-size: 12px; }
}
