:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0efe9;
  --text: #1d2321;
  --muted: #6b746f;
  --line: #dfdfd6;
  --accent: #0f766e;
  --accent-soft: #d9efec;
  --warn: #b45309;
  --warn-soft: #fdf0dc;
  --danger: #b42318;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(29, 35, 33, .06), 0 8px 24px rgba(29, 35, 33, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- login ---------- */

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 15% -10%, #d9efec 0%, transparent 60%),
    radial-gradient(900px 400px at 110% 110%, #fdf0dc 0%, transparent 55%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
  display: grid;
  gap: 14px;
  text-align: center;
}

.login-logo { font-size: 40px; line-height: 1; }
.login-card h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.login-card p { margin: 0; font-size: 13.5px; }
.login-card input { margin-top: 6px; }
.form-error { color: var(--danger); font-size: 13.5px; margin: 0; }

/* ---------- topbar ---------- */

.app { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(246, 245, 241, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -.01em;
  background: none;
  border: 0;
  padding: 6px 8px;
  border-radius: 10px;
  cursor: pointer;
}
.brand:hover { background: var(--surface-2); }

.topbar-actions { margin-left: auto; display: flex; gap: 8px; }

/* ---------- buttons ---------- */

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 550;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #0b5f59; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: transparent; border-color: #efd3cf; color: var(--danger); }
.btn.danger:hover { background: #fbeeec; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }

/* ---------- layout ---------- */

.content { max-width: 1080px; margin: 0 auto; padding: 24px 20px 64px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.trip-card {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  cursor: pointer;
  display: grid;
  gap: 8px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
  color: inherit;
}
.trip-card:hover { border-color: #c9c8bd; box-shadow: var(--shadow); transform: translateY(-1px); }

.trip-card-top { display: flex; align-items: start; gap: 10px; }
.trip-card h3 { margin: 0; font-size: 16.5px; line-height: 1.3; letter-spacing: -.01em; }
.trip-place { color: var(--muted); font-size: 13.5px; }
.trip-dates { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.trip-excerpt {
  margin: 2px 0 0;
  font-size: 13.5px;
  color: #414b46;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.badge {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge.ready { background: var(--accent-soft); color: #0b5f59; }
.badge.generating { background: var(--warn-soft); color: var(--warn); }
.badge.error { background: #fbeeec; color: var(--danger); }

.empty { text-align: center; padding: 72px 20px; display: grid; justify-items: center; gap: 10px; }
.empty-icon { font-size: 44px; }
.empty h2 { margin: 0; font-size: 20px; }
.empty p { max-width: 420px; margin: 0 0 8px; }

/* ---------- detail ---------- */

.detail-head { display: flex; flex-wrap: wrap; gap: 14px; align-items: start; margin-bottom: 22px; }
.detail-title { display: grid; gap: 6px; }
.detail-title h1 { margin: 0; font-size: 26px; line-height: 1.2; letter-spacing: -.02em; }
.detail-meta { color: var(--muted); font-size: 14px; }
.detail-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }

.back { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; margin-bottom: 14px; font-size: 14px; }
.back:hover { color: var(--text); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.panel h2 { margin: 0 0 10px; font-size: 16px; letter-spacing: -.01em; }
.summary { margin: 0; white-space: pre-line; }

.state-box { display: grid; gap: 10px; justify-items: start; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid var(--warn-soft);
  border-top-color: var(--warn);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.day { margin-bottom: 14px; }
.day-head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 0 4px 10px;
  border-bottom: 1px dashed var(--line);
  margin-bottom: 12px;
}
.day-num {
  font-size: 12px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); border-radius: 8px; padding: 2px 8px;
}
.day-date { font-weight: 650; }
.day-title { color: var(--muted); font-size: 14px; }

.timeline { display: grid; gap: 0; }

.item {
  display: grid;
  grid-template-columns: 62px 18px 1fr;
  gap: 12px;
  padding: 10px 4px 14px;
  position: relative;
}
.item + .item { border-top: 1px solid #f1f0ea; }

.item-time {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: 14px;
  color: var(--accent);
  padding-top: 1px;
}

.item-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #cfe3e0; border: 2px solid var(--accent);
  margin-top: 6px; justify-self: center;
}
.item.kind-food .item-dot { border-color: #b45309; background: #fdf0dc; }
.item.kind-transfer .item-dot { border-color: #6b746f; background: #f0efe9; }
.item.kind-rest .item-dot { border-color: #7c6f9c; background: #efecf7; }

.item-body { display: grid; gap: 4px; }
.item-title { font-weight: 600; }
.item-kind { font-size: 11.5px; color: var(--muted); font-weight: 500; margin-left: 8px; }
.item-place { font-size: 13.5px; color: var(--muted); }
.item-desc { font-size: 14px; color: #3a423e; }
.item-tip {
  font-size: 13px; color: var(--warn);
  background: var(--warn-soft); border-radius: 8px;
  padding: 6px 10px; margin-top: 2px;
}

.poi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.poi {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px;
  background: #fcfcf9; display: grid; gap: 3px;
}
.poi-name { font-weight: 600; font-size: 14.5px; }
.poi-cat { font-size: 11.5px; color: var(--accent); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.poi-why { font-size: 13.5px; color: #414b46; }
.poi-area { font-size: 12.5px; color: var(--muted); }

.tips { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 14px; }

/* ---------- dialog ---------- */

.dialog {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0;
  width: min(620px, calc(100vw - 32px));
  box-shadow: 0 24px 64px rgba(20, 25, 23, .22);
  background: var(--surface);
}
.dialog::backdrop { background: rgba(24, 30, 27, .38); backdrop-filter: blur(2px); }
.dialog form { padding: 24px; display: grid; gap: 14px; }
.dialog h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }

.field { display: grid; gap: 6px; font-size: 13.5px; }
.field > span { color: var(--muted); font-weight: 550; }
.field em { font-style: normal; font-weight: 400; opacity: .75; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

input, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 90px; }

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

@media (max-width: 640px) {
  .content { padding: 16px 14px 48px; }
  .detail-head { flex-direction: column; }
  .detail-actions { margin-left: 0; width: 100%; }
  .detail-actions .btn { flex: 1; }
  .item { grid-template-columns: 52px 14px 1fr; gap: 8px; }
  .field-row { grid-template-columns: 1fr; }
  .brand span { display: none; }
}
