:root {
  --paper: #f6f1e7;
  --paper-2: #ece4d3;
  --card: #fffdf8;
  --ink: #1f2a37;
  --ink-2: #5b6472;
  --line: #d9cfbb;
  --teal: #0f766e;
  --teal-2: #0b5e58;
  --coral: #e0603a;
  --danger: #b42318;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(31 42 55 / 6%), 0 6px 20px rgb(31 42 55 / 8%);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--teal-2); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); }
h2 { font-size: 1.35rem; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

/* top bar */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-left)) 12px max(16px, env(safe-area-inset-right));
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-weight: 600; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 5px; border: 2.5px solid var(--ink); position: relative; }
.brand-mark::after { content: ""; position: absolute; right: 3px; top: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--coral); }
.who { display: flex; align-items: center; gap: 10px; font-size: .9rem; color: var(--ink-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--paper-2); display: inline-grid; place-items: center; font-weight: 600; color: var(--ink-2); flex: none; }

main { max-width: 980px; margin: 0 auto; padding: 24px 16px 64px; }
.loading { color: var(--ink-2); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent;
  background: var(--teal); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--teal-2); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--paper-2); }
.btn.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: .9rem; }
.btn:disabled { opacity: .55; cursor: default; }
.linkbtn { background: none; border: 0; padding: 4px; color: var(--ink-2); cursor: pointer; text-decoration: underline; font-size: .9rem; }

/* signed out */
.hero { min-height: 70dvh; display: grid; place-content: center; text-align: center; gap: 18px; }
.hero p { color: var(--ink-2); max-width: 30rem; margin: 0 auto; }
.postcard-art { width: min(320px, 80vw); margin: 0 auto 8px; aspect-ratio: 3 / 2; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); border: 1px solid var(--line); position: relative; overflow: hidden; transform: rotate(-2deg); }
.postcard-art::before { content: ""; position: absolute; inset: 14px 46% 14px 14px; border-radius: 8px; background: linear-gradient(160deg, #9fd3c7 0 40%, #f4c98a 40% 62%, #e9a37a 62%); }
.postcard-art::after { content: ""; position: absolute; right: 16px; top: 16px; width: 44px; height: 52px; border: 2px dashed var(--coral); border-radius: 4px; }
.postcard-art span { position: absolute; left: 58%; right: 16px; height: 2px; background: var(--line); }
.google-btn { background: #fff; color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow); }
.google-btn:hover { background: #fff; border-color: var(--ink-2); }
.google-btn svg { width: 18px; height: 18px; }

/* notices */
.notice { border-radius: var(--radius); padding: 12px 16px; background: #fff4e5; border: 1px solid #f3d3a5; margin-bottom: 18px; }
.notice.ok { background: #e7f5f2; border-color: #b6e0d8; }

/* trip list */
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; color: var(--ink-2); }
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card {
  display: flex; flex-direction: column; gap: 10px; text-align: left;
  padding: 18px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow); color: inherit; text-decoration: none; position: relative; min-height: 150px;
  transition: transform .15s ease;
}
a.card:hover { transform: translateY(-2px) rotate(-.4deg); }
.card .stamp { position: absolute; right: 14px; top: 14px; width: 40px; height: 46px; border: 2px dashed var(--coral); border-radius: 4px; display: grid; place-items: center; font-size: .7rem; font-weight: 700; color: var(--coral); text-transform: uppercase; letter-spacing: .04em; transform: rotate(6deg); }
.card h3 { font-size: 1.25rem; padding-right: 52px; }
.card .meta { color: var(--ink-2); font-size: .9rem; margin-top: auto; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.card.new { border-style: dashed; background: transparent; box-shadow: none; align-items: center; justify-content: center; cursor: pointer; color: var(--teal-2); font-weight: 600; }
.card.new:hover { background: var(--paper-2); }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--paper-2); color: var(--ink-2); text-transform: capitalize; }
.badge.owner { background: #e7f5f2; color: var(--teal-2); }
.badge.contributor { background: #fdebe4; color: #a3401f; }
.empty { text-align: center; color: var(--ink-2); padding: 48px 16px; border: 1px dashed var(--line); border-radius: var(--radius); }

/* trip page */
.back { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-2); text-decoration: none; margin-bottom: 14px; font-size: .95rem; }
.trip-head { display: flex; justify-content: space-between; align-items: start; gap: 16px; flex-wrap: wrap; margin-bottom: 26px; }
.trip-head .sub { color: var(--ink-2); margin: 8px 0 0; }
.trip-head .dates { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .85rem; color: var(--ink-2); margin-top: 6px; letter-spacing: .02em; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.section-head p { margin: 4px 0 0; color: var(--ink-2); font-size: .9rem; }
.placeholder { color: var(--ink-2); padding: 28px 12px; text-align: center; border: 1px dashed var(--line); border-radius: 10px; }
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--paper-2); }
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .small { color: var(--ink-2); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row select { min-height: 34px; border-radius: 8px; border: 1px solid var(--line); background: #fff; padding: 0 8px; }
.row .row-actions { display: flex; gap: 6px; align-items: center; }

/* dialog */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(460px, calc(100vw - 24px)); background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgb(31 42 55 / 30%); }
dialog::backdrop { background: rgb(31 42 55 / 40%); }
.dlg { padding: 22px; display: grid; gap: 16px; }
.dlg p { margin: 0; color: var(--ink-2); }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: .9rem; }
.field input { min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: #fff; padding: 0 12px; width: 100%; }
.field .hint { font-size: .82rem; color: var(--ink-2); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg label { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; display: grid; gap: 2px; background: #fff; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); background: #f1faf8; }
.seg label:has(input:focus-visible) { outline: 3px solid var(--teal); outline-offset: 2px; }
.seg b { font-size: .95rem; }
.seg small { color: var(--ink-2); font-size: .8rem; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.linkbox { display: flex; gap: 8px; }
.linkbox input { flex: 1; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); padding: 0 12px; background: var(--paper); font-size: .85rem; min-width: 0; }
.err { color: var(--danger); font-size: .9rem; min-height: 1.2em; margin: 0; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: .92rem; box-shadow: var(--shadow); z-index: 20; max-width: calc(100vw - 32px); }

@media (max-width: 520px) {
  .who .who-name { display: none; }
  .two { grid-template-columns: 1fr; }
  .row { flex-wrap: wrap; }
  .row .row-actions { width: 100%; justify-content: flex-end; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
