:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --panel: #f4f2ee;
  --border: #e8e3db;
  --border-strong: #d9d2c6;
  --text: #1c1a17;
  --text-dim: #6b655c;
  --text-faint: #9a948a;
  --accent: #d97706;
  --accent-hover: #f59e0b;
  --accent-soft: #fdf2e2;
  --blue: #2563eb;
  --blue-soft: #e7eefc;
  --green: #15803d;
  --green-soft: #e3f3e9;
  --gray: #78716c;
  --gray-soft: #efece7;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(28,26,23,.04), 0 6px 20px rgba(28,26,23,.05);
  --shadow-hover: 0 2px 4px rgba(28,26,23,.06), 0 12px 32px rgba(28,26,23,.09);
  --mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---------- Layout ---------- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

header.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(250,249,247,.82);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; gap: 28px; height: 60px; }

.logo {
  font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em;
  white-space: nowrap;
}
.logo .ai { color: var(--accent); }
.logo:hover .ai { color: var(--accent-hover); }
.logo .sub { font-size: .7rem; color: var(--text-faint); font-weight: 500; margin-left: 8px; letter-spacing: 0; }

nav.tabs { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
nav.tabs a {
  padding: 7px 14px; border-radius: 999px; font-size: .9rem; font-weight: 500;
  color: var(--text-dim); transition: all .15s;
}
nav.tabs a:hover { background: var(--panel); color: var(--text); }
nav.tabs a.active { background: var(--accent-soft); color: var(--accent); }

main { padding: 40px 0 80px; min-height: 70vh; }
.view { display: none; animation: fade .25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.section-head h2 { font-size: 1.5rem; letter-spacing: -.02em; }
.section-head .count { font-size: .85rem; color: var(--text-faint); font-family: var(--mono); }
.section-head .spacer { margin-left: auto; }

/* ---------- Hero ---------- */
.hero { padding: 28px 0 40px; }
.hero h1 { font-size: 2.6rem; letter-spacing: -.03em; line-height: 1.1; margin-bottom: 14px; }
.hero h1 .ai { color: var(--accent); }
.hero p.lead { font-size: 1.1rem; color: var(--text-dim); max-width: 640px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 14px; margin: 28px 0 8px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.stat .num { font-size: 2rem; font-weight: 700; font-family: var(--mono); letter-spacing: -.03em; }
.stat .num.accent { color: var(--accent); }
.stat .lbl { font-size: .85rem; color: var(--text-dim); margin-top: 2px; }

.home-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 28px; margin-top: 40px; }
@media (max-width: 820px) { .home-grid { grid-template-columns: 1fr; } }

/* ---------- Buttons / filters ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: var(--radius-sm); font-size: .9rem; font-weight: 600;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  cursor: pointer; transition: all .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 22px; }
.filters input.search {
  flex: 1; min-width: 180px; padding: 9px 14px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-size: .92rem; font-family: var(--sans); background: var(--surface);
}
.filters input.search:focus { outline: none; border-color: var(--accent); }
.chip {
  padding: 6px 13px; border-radius: 999px; font-size: .82rem; font-weight: 500;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-dim);
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px,1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); transition: all .18s; position: relative;
}
.card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); border-color: var(--border-strong); }
.card .title-row { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.card h3 { font-size: 1.08rem; letter-spacing: -.01em; line-height: 1.3; flex: 1; }
.card .platform { font-size: .82rem; color: var(--accent); font-weight: 600; }
.card .meta { font-size: .85rem; color: var(--text-dim); display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 0; }
.card .meta .ico { opacity: .6; }
.card .notes { font-size: .9rem; color: var(--text-dim); margin-top: 8px; }
.card .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.tag { font-size: .72rem; padding: 3px 9px; border-radius: 999px; background: var(--panel); color: var(--text-dim); font-family: var(--mono); }

/* status badges */
.badge { font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; letter-spacing: .01em; }
.badge.upcoming { background: var(--blue-soft); color: var(--blue); }
.badge.ongoing { background: var(--green-soft); color: var(--green); }
.badge.ended { background: var(--gray-soft); color: var(--gray); }
.badge.interest { background: var(--accent-soft); color: var(--accent); }
.badge.dot::before { content: "●"; font-size: .6em; margin-right: 4px; vertical-align: middle; }
.badge.ongoing.dot::before { animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* list rows (home, ideas) */
.rows { display: flex; flex-direction: column; gap: 10px; }
.row {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 13px 16px; display: flex; align-items: center; gap: 12px; transition: all .15s;
}
.row:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.row .when { font-family: var(--mono); font-size: .8rem; color: var(--text-faint); white-space: nowrap; }
.row .row-title { font-weight: 600; font-size: .96rem; flex: 1; }
.row .row-sub { font-size: .82rem; color: var(--text-dim); }

.panel-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.panel-block h3.block-title { font-size: 1.05rem; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.cal-head h2 { font-size: 1.4rem; font-family: var(--mono); letter-spacing: -.02em; min-width: 160px; text-align: center; }
.cal-nav { display: flex; gap: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-dow { background: var(--panel); padding: 8px; text-align: center; font-size: .78rem; font-weight: 600; color: var(--text-dim); }
.cal-cell { background: var(--surface); min-height: 96px; padding: 6px 7px; position: relative; }
.cal-cell.other { background: #fbfaf8; }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-cell .daynum { font-size: .8rem; font-family: var(--mono); color: var(--text-dim); }
.cal-cell.today .daynum { color: var(--accent); font-weight: 700; }
.cal-ev {
  display: block; margin-top: 4px; padding: 2px 6px; border-radius: 5px; font-size: .72rem;
  font-weight: 600; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-ev.upcoming { background: var(--blue-soft); color: var(--blue); }
.cal-ev.ongoing { background: var(--green-soft); color: var(--green); }
.cal-ev.ended { background: var(--gray-soft); color: var(--gray); }
.cal-ev:hover { filter: brightness(.95); }
.cal-legend { display: flex; gap: 16px; margin-top: 14px; font-size: .82rem; color: var(--text-dim); flex-wrap: wrap; }
.cal-legend span::before { content: "●"; margin-right: 5px; }
.cal-legend .lg-up::before { color: var(--blue); }
.cal-legend .lg-on::before { color: var(--green); }
.cal-legend .lg-en::before { color: var(--gray); }

@media (max-width: 640px) {
  .cal-cell { min-height: 64px; }
  .cal-cell .daynum { font-size: .72rem; }
  .cal-ev { font-size: .62rem; }
}

/* works gallery */
.work-cover {
  height: 140px; border-radius: var(--radius-sm); margin: -2px -2px 12px; background: var(--panel);
  display: flex; align-items: center; justify-content: center; color: var(--text-faint);
  font-size: 2rem; overflow: hidden;
}
.work-cover img { width: 100%; height: 100%; object-fit: cover; }

/* ideas timeline */
.idea { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); margin-bottom: 14px; }
.idea .idea-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.idea h3 { font-size: 1.15rem; flex: 1; }
.idea .idea-body { color: var(--text-dim); white-space: pre-wrap; font-size: .95rem; }
.idea .idea-date { font-family: var(--mono); font-size: .78rem; color: var(--text-faint); }

/* empty + footer */
.empty { text-align: center; padding: 60px 20px; color: var(--text-faint); }
.empty .big { font-size: 2.4rem; margin-bottom: 10px; }
.links-inline a { color: var(--accent); font-weight: 600; }
.links-inline a:hover { color: var(--accent-hover); text-decoration: underline; }

footer { border-top: 1px solid var(--border); padding: 26px 0; color: var(--text-faint); font-size: .82rem; }
footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
footer a { color: var(--text-dim); }
footer a:hover { color: var(--accent); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(28,26,23,.45); z-index: 100; display: none; align-items: center; justify-content: center; padding: 24px; }
.modal-bg.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius); max-width: 520px; width: 100%; padding: 28px; box-shadow: var(--shadow-hover); max-height: 86vh; overflow: auto; }
.modal h3 { font-size: 1.4rem; margin-bottom: 6px; letter-spacing: -.02em; }
.modal .modal-meta { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; font-size: .92rem; }
.modal .modal-meta .k { color: var(--text-faint); font-size: .8rem; }
.modal .modal-close { float: right; cursor: pointer; color: var(--text-faint); font-size: 1.4rem; line-height: 1; }
.modal .modal-close:hover { color: var(--text); }

/* ---------- modal deep sections ---------- */
.modal-sec { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.modal-sec .sec-k { font-size: .76rem; color: var(--text-faint); font-weight: 700; letter-spacing: .02em; margin-bottom: 9px; }
.link-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.link-btns .btn { font-size: .82rem; padding: 6px 12px; }
.hist { font-size: .88rem; margin-bottom: 11px; line-height: 1.5; }
.hist:last-child { margin-bottom: 0; }
.hist b { color: var(--accent); font-family: var(--mono); margin-right: 4px; }
.hist-sub { color: var(--text-dim); font-size: .82rem; margin-top: 2px; }
.feat { display: block; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 13px; margin-bottom: 8px; transition: all .15s; }
.feat:hover { border-color: var(--accent); background: var(--accent-soft); }
.feat b { font-size: .92rem; }
.feat-y { font-family: var(--mono); font-size: .72rem; color: var(--text-faint); margin-left: 7px; }
.feat-a { font-size: .72rem; color: var(--accent); margin-left: 7px; }
.feat-n { font-size: .83rem; color: var(--text-dim); margin-top: 3px; line-height: 1.45; }
.research { font-size: .88rem; color: var(--text-dim); white-space: pre-wrap; line-height: 1.6; }
.badge.deep { background: var(--accent-soft); color: var(--accent); }

/* ---------- calendar v2: connected per-event bars ---------- */
.cal2 { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.cal2-dow { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--panel); }
.cal2-dow div { padding: 9px 0; text-align: center; font-size: .78rem; font-weight: 600; color: var(--text-dim); }
.cal2-week { position: relative; border-top: 1px solid var(--border); }
.cal2-days { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal2-day { border-left: 1px solid var(--border); padding: 5px 7px; }
.cal2-day:first-child { border-left: 0; }
.cal2-day.other { background: #fbfaf8; }
.cal2-day.other .cal2-daynum { color: var(--text-faint); }
.cal2-day.today { box-shadow: inset 0 2px 0 var(--accent); }
.cal2-day.today .cal2-daynum { color: var(--accent); font-weight: 700; }
.cal2-daynum { font-size: .78rem; font-family: var(--mono); color: var(--text-dim); }
.cal2-lanes { position: absolute; left: 0; right: 0; top: 27px; display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 23px; row-gap: 3px; padding: 0 5px; pointer-events: none; }
.cal2-bar { pointer-events: auto; height: 21px; line-height: 20px; font-size: .75rem; font-weight: 600; padding: 0 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; border: 1px solid transparent; border-left-width: 0; border-right-width: 0; transition: filter .12s; }
.cal2-bar.rl { border-left-width: 1px; border-top-left-radius: 6px; border-bottom-left-radius: 6px; }
.cal2-bar.rr { border-right-width: 1px; border-top-right-radius: 6px; border-bottom-right-radius: 6px; }
.cal2-bar:hover { filter: brightness(.95); }

@media (max-width: 640px) {
  .cal2-bar { font-size: .62rem; padding: 0 4px; }
  .cal2-day { padding: 4px 4px; }
}

/* ---------- home vertical timeline ---------- */
.tl { position: relative; }
.tl-item { position: relative; padding: 7px 0 7px 24px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.tl-item::before { content: ""; position: absolute; left: 5px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.tl-item:first-child::before { top: 14px; }
.tl-item:last-child::before { bottom: calc(100% - 18px); }
.tl-item.ended { opacity: .62; }
.tl-dot { position: absolute; left: 0; top: 11px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); z-index: 1; }
.tl-date { font-family: var(--mono); font-size: .77rem; color: var(--text-faint); min-width: 88px; }
.tl-main { flex: 1; min-width: 160px; }
.tl-name { font-weight: 600; font-size: .95rem; cursor: pointer; }
.tl-name:hover { color: var(--accent); }
.tl-plat { font-size: .8rem; color: var(--text-dim); margin-left: 8px; }
.deep-dot { font-size: .8rem; }
.tl-now { padding: 4px 0 4px 24px; }
.tl-now .tl-dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); top: 7px; }
.tl-now-label { font-family: var(--mono); font-size: .8rem; font-weight: 700; color: var(--accent); }

/* ---------- calendar toolbar + segmented control ---------- */
.cal-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.cal-ctrl { display: flex; align-items: center; gap: 8px; }
.cal-ctrl #cal-label { font-family: var(--mono); font-size: 1.05rem; letter-spacing: -.02em; margin-left: 4px; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--text-dim); font-size: .85rem; font-weight: 600; padding: 6px 14px; border-radius: 999px; cursor: pointer; font-family: var(--sans); transition: all .15s; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }

/* ---------- year view: all months stacked, named bars ---------- */
.year-stack { display: flex; flex-direction: column; gap: 28px; }
.ym-title { font-family: var(--mono); font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 9px; display: flex; align-items: center; gap: 9px; }
.ym-cnt { font-family: var(--sans); font-size: .72rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 2px 9px; border-radius: 999px; }
