:root {
  --bg: #f6f1e8;
  --bg-2: #efe7da;
  --card: #fffdf9;
  --ink: #1e1a16;
  --ink-2: #4a4238;
  --muted: #7a7064;
  --line: #e4dacb;
  --accent: #c0392b;       /* torii vermilion */
  --accent-ink: #fff;
  --accent-soft: #f7e3dc;
  --amber: #c9791f;        /* autumn leaves */
  --amber-soft: #f8ead5;
  --moss: #4f6e45;
  --moss-soft: #e3ecdc;
  --indigo: #2f3e63;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 20px rgba(60, 40, 20, .07);
  --radius: 18px;
  --tabbar-h: 64px;
  --font: 'Heebo', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --display: 'Frank Ruhl Libre', 'Heebo', serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15120f; --bg-2: #1d1915; --card: #221e19; --ink: #f2ece2; --ink-2: #d6cdbf; --muted: #a0968a;
    --line: #372f27; --accent: #e0584a; --accent-soft: #3a211d; --amber: #e39a45; --amber-soft: #36291a;
    --moss: #8db07e; --moss-soft: #22301e; --indigo: #9fb2e0;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.55; }
body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px); overflow-x: hidden; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap-x { flex-wrap: wrap; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.en { direction: ltr; unicode-bidi: isolate; }

/* ---------- buttons & chips ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--card);
  padding: 10px 14px; border-radius: 12px; font-weight: 600; font-size: .93rem; cursor: pointer; min-height: 44px; transition: transform .08s, background .15s; color: var(--ink); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: .86rem; border-radius: 10px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; border: 0; display: grid; place-items: center; background: rgba(255,255,255,.9); color: #1e1a16; cursor: pointer; font-size: 1.1rem; box-shadow: var(--shadow); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--bg-2); color: var(--ink-2); white-space: nowrap; }
.chip.city { background: var(--accent-soft); color: var(--accent); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.moss { background: var(--moss-soft); color: var(--moss); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip-btn { border: 1px solid var(--line); background: var(--card); padding: 8px 14px; border-radius: 999px; font-size: .88rem; font-weight: 600; cursor: pointer; white-space: nowrap; color: var(--ink); }
.chip-btn.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.section { margin: 22px 0 10px; }
.section-title { font-family: var(--display); font-size: 1.3rem; font-weight: 700; margin: 26px 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title .jp { font-family: 'Noto Serif JP', serif; font-size: .8rem; color: var(--muted); font-weight: 600; }
.stack > * + * { margin-top: 12px; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg); }
.login .card { width: 100%; max-width: 380px; padding: 28px 22px; text-align: center; }
.login .logo { font-size: 3rem; line-height: 1; }
.login h1 { font-family: var(--display); font-size: 1.7rem; margin: 10px 0 2px; }
.login form { margin-top: 20px; text-align: right; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input, textarea, select { width: 100%; font: inherit; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); outline: none; min-height: 46px; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 90px; }
.error { color: var(--accent); font-size: .9rem; margin: 8px 0 0; min-height: 1.2em; }

/* ---------- home hero ---------- */
.hero { position: relative; padding: 26px 0 18px; }
.hero .kanji { position: absolute; left: 12px; top: 8px; font-family: 'Noto Serif JP', serif; font-size: 4.6rem; line-height: 1; color: var(--accent); opacity: .12; pointer-events: none; }
.hero h1 { font-family: var(--display); font-size: 1.9rem; font-weight: 700; }
.hero .dates { font-weight: 600; color: var(--accent); margin-top: 2px; }
.hero p { margin: 4px 0 0; color: var(--muted); }
.status-pill { display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; padding: 8px 14px; border-radius: 999px; background: var(--ink); color: var(--bg); font-weight: 600; font-size: .92rem; }

.now-card { position: relative; overflow: hidden; }
.now-card .label { font-size: .78rem; font-weight: 700; letter-spacing: .02em; color: var(--accent); }
.now-card h3 { font-size: 1.15rem; margin: 2px 0 4px; }
.now-card .next { border-top: 1px dashed var(--line); margin-top: 12px; padding-top: 12px; }
.now-card .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); display: inline-block; box-shadow: 0 0 0 0 var(--accent); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(192,57,43,.5) } 80% { box-shadow: 0 0 0 10px rgba(192,57,43,0) } }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--card); border-radius: 14px; padding: 12px; text-align: center; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.35rem; font-family: var(--display); }
.stat span { font-size: .78rem; color: var(--muted); }

/* day list */
.day-list { display: grid; gap: 12px; }
.day-card { display: grid; grid-template-columns: 92px 1fr; gap: 12px; align-items: stretch; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; color: var(--ink); position: relative; }
.day-card .thumb { background: var(--bg-2) center/cover no-repeat; min-height: 96px; position: relative; }
.day-card .thumb .dnum { position: absolute; inset: auto 6px 6px auto; background: rgba(0,0,0,.55); color: #fff; font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.day-card .body { padding: 10px 4px 10px 12px; min-width: 0; }
.day-card .date { font-size: .8rem; color: var(--muted); font-weight: 600; }
.day-card h3 { font-size: 1rem; font-weight: 700; margin: 2px 0 6px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.day-card.today { outline: 2px solid var(--accent); }
.day-card.past { opacity: .72; }
.progress { height: 4px; background: var(--bg-2); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.progress i { display: block; height: 100%; background: var(--moss); border-radius: 4px; }
.city-divider { font-family: var(--display); font-weight: 700; color: var(--muted); font-size: .95rem; margin: 16px 4px 2px; display: flex; align-items: center; gap: 8px; }
.city-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ---------- day page ---------- */
.day-hero { position: relative; min-height: 270px; background: var(--bg-2) center/cover no-repeat; color: #fff; display: flex; flex-direction: column; justify-content: flex-end; padding: calc(72px + env(safe-area-inset-top)) 16px 44px; }
.day-hero::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, rgba(12,8,4,.82) 0%, rgba(12,8,4,.25) 55%, rgba(12,8,4,.35) 100%); }
.day-hero.noimg { background: linear-gradient(135deg, #7c2d22, #c9791f); }
.day-hero .top { position: absolute; top: calc(12px + env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; justify-content: space-between; z-index: 2; }
.day-hero .info { position: relative; z-index: 2; max-width: 728px; margin: 0 auto; width: 100%; }
.day-hero .info .d { font-size: .9rem; opacity: .9; font-weight: 500; }
.day-hero h1 { font-family: var(--display); font-size: 1.65rem; font-weight: 700; margin-top: 2px; text-shadow: 0 2px 12px rgba(0,0,0,.4); }
.day-hero .sub { font-size: .9rem; opacity: .9; white-space: pre-line; margin-top: 2px; }
.info-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: -26px; position: relative; z-index: 3; }
.info-tile { background: var(--card); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow); min-width: 0; }
.info-tile .k { font-size: .75rem; color: var(--muted); font-weight: 600; }
.info-tile .v { font-weight: 600; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info-tile .big { font-size: 1.4rem; }

.brief { border: 1px solid var(--amber-soft); background: linear-gradient(180deg, var(--amber-soft), var(--card) 70%); }
.brief-head { display: flex; align-items: center; gap: 8px; }
.brief-head h3 { font-size: 1.02rem; }

.slot-head { display: flex; align-items: center; gap: 10px; margin: 24px 0 8px; font-family: var(--display); font-weight: 700; font-size: 1.15rem; }
.slot-head .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 1.1rem; background: var(--bg-2); }
.timeline { position: relative; padding-right: 58px; }
.timeline::before { content: ''; position: absolute; right: 45px; top: 8px; bottom: 8px; width: 2px; background: var(--line); border-radius: 2px; }
.tl-item { position: relative; margin-bottom: 12px; }
.tl-time { position: absolute; right: -58px; top: 12px; width: 44px; text-align: center; font-size: .78rem; font-weight: 700; color: var(--ink-2); line-height: 1.2; direction: ltr; }
.tl-time small { display: block; font-weight: 500; color: var(--muted); }
.tl-item::before { content: ''; position: absolute; right: -17px; top: 16px; width: 12px; height: 12px; border-radius: 50%; background: var(--card); border: 3px solid var(--amber); z-index: 1; }
.tl-item.done::before { background: var(--moss); border-color: var(--moss); }
.tl-item.now::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }
.act-card { display: block; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 12px 14px; color: var(--ink); cursor: pointer; }
.tl-item.now .act-card { outline: 2px solid var(--accent); }
.tl-item.done .act-card { opacity: .7; }
.act-card h4 { margin: 0; font-size: 1rem; font-weight: 700; line-height: 1.35; }
.act-card p { margin: 4px 0 0; font-size: .88rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.thumbs { display: flex; gap: 6px; margin-top: 10px; }
.thumbs img { width: 76px; height: 58px; object-fit: cover; border-radius: 10px; background: var(--bg-2); }
.thumbs .more { width: 58px; height: 58px; border-radius: 10px; background: var(--bg-2); display: grid; place-items: center; font-weight: 700; color: var(--muted); font-size: .85rem; }
.check { width: 30px; height: 30px; flex: none; border-radius: 50%; border: 2px solid var(--line); background: var(--card); display: grid; place-items: center; cursor: pointer; font-size: .9rem; color: transparent; }
.check.on { background: var(--moss); border-color: var(--moss); color: #fff; }

.notes { white-space: pre-line; }
.day-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 26px; }

/* ---------- activity page ---------- */
.gallery { position: relative; background: var(--bg-2); }
.gallery .track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; height: 300px; }
.gallery .track::-webkit-scrollbar { display: none; }
.gallery .track img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: cover; scroll-snap-align: center; cursor: zoom-in; }
.gallery .noimg { height: 190px; display: grid; place-items: center; font-size: 4rem; background: linear-gradient(135deg, var(--accent-soft), var(--amber-soft)); }
.gallery .top { position: absolute; top: calc(12px + env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; justify-content: space-between; z-index: 2; }
.gallery .count { position: absolute; bottom: 12px; left: 12px; background: rgba(0,0,0,.55); color: #fff; font-size: .78rem; padding: 2px 10px; border-radius: 999px; }
.act-head { padding-top: 16px; }
.act-head h1 { font-family: var(--display); font-size: 1.5rem; font-weight: 700; }
.act-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 8px; margin-top: 14px; }
.ai-box { min-height: 80px; }
.ai-box .placeholder { text-align: center; padding: 18px 8px; color: var(--muted); }
.sources { margin-top: 10px; font-size: .8rem; }
.body-text { font-size: .97rem; color: var(--ink-2); }
.body-text p { margin: 0 0 10px; }
.body-text b { color: var(--ink); }
.clamp { max-height: 320px; overflow: hidden; position: relative; }
.clamp::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 90px; background: linear-gradient(transparent, var(--card)); }
.wiki-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.wiki-grid button { padding: 0; border: 0; border-radius: 10px; overflow: hidden; aspect-ratio: 1; cursor: pointer; background: var(--bg-2); }
.wiki-grid img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- markdown ---------- */
.md h3, .md h4 { font-size: 1rem; margin: 14px 0 6px; font-weight: 700; }
.md p { margin: 0 0 8px; }
.md ul, .md ol { margin: 4px 0 10px; padding-right: 20px; padding-left: 0; }
.md li { margin-bottom: 4px; }

/* ---------- chat ---------- */
.chat-page { display: flex; flex-direction: column; min-height: calc(100dvh - var(--tabbar-h) - 12px); }
.chat-head { padding: 16px 0 8px; display: flex; align-items: center; gap: 10px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--amber)); display: grid; place-items: center; font-size: 1.3rem; color: #fff; flex: none; }
.msgs { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 8px 0 12px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 18px; box-shadow: var(--shadow); font-size: .95rem; word-wrap: break-word; }
.msg.user { align-self: flex-start; background: var(--ink); color: var(--bg); border-bottom-right-radius: 6px; }
.msg.user a { color: inherit; text-decoration: underline; }
.msg.model { align-self: flex-end; background: var(--card); border-bottom-left-radius: 6px; }
.msg img { border-radius: 12px; margin-bottom: 6px; max-height: 220px; }
.typing span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); margin: 0 2px; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s } .typing span:nth-child(3) { animation-delay: .4s }
@keyframes blink { 0%, 80%, 100% { opacity: .25 } 40% { opacity: 1 } }
.composer { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); background: var(--bg); padding: 8px 0 10px; }
.composer form { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 46px; max-height: 140px; resize: none; border-radius: 22px; padding: 11px 16px; }
.composer .round { width: 46px; height: 46px; border-radius: 50%; flex: none; padding: 0; }
.attach-preview { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.attach-preview img { width: 54px; height: 54px; object-fit: cover; border-radius: 10px; }
.welcome { text-align: center; padding: 20px 10px; }
.welcome .avatar { width: 64px; height: 64px; font-size: 2rem; margin: 0 auto 10px; }

/* ---------- photos ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; border-radius: 14px; overflow: hidden; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; cursor: zoom-in; background: var(--bg-2); }

/* ---------- more ---------- */
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-bottom: 1px solid var(--line); color: var(--ink); }
.list-item:last-child { border-bottom: 0; }
.list-item .t { font-weight: 600; }
.list-item .s { font-size: .82rem; color: var(--muted); }
.list-item .grow { flex: 1; min-width: 0; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.menu-tile { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 16px 14px; color: var(--ink); display: flex; flex-direction: column; gap: 4px; }
.menu-tile .e { font-size: 1.6rem; }
.menu-tile b { font-size: 1rem; }
.menu-tile span { font-size: .8rem; color: var(--muted); }
.conv { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.conv .swap { font-size: 1.2rem; color: var(--muted); }
.quick-yen { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.hotel-card h3 { font-size: 1.02rem; }
.status-done { color: var(--moss); font-weight: 700; }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; bottom: 0; right: 0; left: 0; z-index: 50; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--muted); font-size: .72rem; font-weight: 600; }
.tabbar a .ti { font-size: 1.3rem; filter: grayscale(1); opacity: .7; transition: .15s; }
.tabbar a.on { color: var(--accent); }
.tabbar a.on .ti { filter: none; opacity: 1; transform: translateY(-1px); }

/* ---------- misc ---------- */
.toast { position: fixed; bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom)); left: 50%; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: .9rem; opacity: 0; transition: .25s; z-index: 200; pointer-events: none; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto; }
.spinner.sm { width: 18px; height: 18px; border-width: 2px; margin: 0; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg) } }
.skel { background: linear-gradient(90deg, var(--bg-2), var(--line), var(--bg-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 10px; height: 14px; margin: 8px 0; }
@keyframes sk { to { background-position: -200% 0 } }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.empty .e { font-size: 2.4rem; }

.modal-back { position: fixed; inset: 0; background: rgba(10, 8, 6, .55); z-index: 100; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.modal { background: var(--card); width: 100%; max-width: 560px; max-height: 90dvh; overflow: auto; border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); animation: up .2s; }
@media (min-width: 640px) { .modal-back { align-items: center; } .modal { border-radius: 22px; } }
.modal h2 { font-size: 1.15rem; margin-bottom: 12px; }
@keyframes fade { from { opacity: 0 } }
@keyframes up { from { transform: translateY(40px) } }

.lightbox { position: fixed; inset: 0; background: #000; z-index: 150; display: flex; flex-direction: column; }
.lightbox .track { flex: 1; display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.lightbox .track::-webkit-scrollbar { display: none; }
.lightbox .slide { flex: 0 0 100%; display: grid; place-items: center; scroll-snap-align: center; padding: 10px; }
.lightbox .slide img { max-height: 82dvh; object-fit: contain; }
.lightbox .bar { display: flex; justify-content: space-between; align-items: center; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; color: #fff; }
.lightbox .cap { color: #ddd; text-align: center; padding: 8px 16px calc(14px + env(safe-area-inset-bottom)); font-size: .88rem; }

@media (min-width: 720px) {
  .day-hero { min-height: 320px; border-radius: 0 0 24px 24px; }
  .gallery .track { height: 400px; }
}
.composer .btn.primary.round { transform: scaleX(-1); } /* send arrow points left in RTL */
