/* ════════════════════════════════════════════════════════════════════════
   site.css — the chat-style home page and the projects page.

   Home is three columns: sidebar | chat | detail panel. The panel is
   closed until something is opened (body.has-panel). Below 1180px the
   panel slides over the chat; below 820px the sidebar becomes a drawer
   too and the panel covers the screen.
   ════════════════════════════════════════════════════════════════════════ */

:root {
  --bg: #f7f5f0;
  --panel: #fffdf8;
  --side: #efebe3;
  --ink: #26231f;
  --soft: #6b655c;
  --mute: #8f887d;
  --line: #e2ddd2;
  --acc: #b4492f;
  --acc-bg: #f6e7e1;
  --ok: #6f9d5a;
  --shadow: 0 2px 10px rgba(40, 30, 20, .06);
  --serif: "Instrument Serif", "Songti SC", Georgia, serif;
  --sans: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --left-w: 272px;
  --right-w: 440px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a17;
    --panel: #23211d;
    --side: #201e1b;
    --ink: #ece7dd;
    --soft: #b5ad9f;
    --mute: #8a8377;
    --line: #36332d;
    --acc: #e07a5c;
    --acc-bg: #3a2620;
    --shadow: 0 2px 10px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
ul, ol { list-style: none; }
body { background: var(--bg); color: var(--ink); font: 14.5px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: 6px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 50; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; }
.skip-link:focus { top: 12px; }
.muted { color: var(--mute); }
.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; color: var(--soft); }
.icon-btn:hover { background: var(--side); color: var(--ink); }

/* ── App grid ─────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--left-w) minmax(0, 1fr); height: 100vh; height: 100dvh; overflow: hidden; }
.app.has-panel { grid-template-columns: var(--left-w) minmax(0, 1fr) var(--right-w); }

/* ── Left sidebar ─────────────────────────────────────────────────────── */
.left { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; padding: 20px 16px 16px; min-height: 0; }
.left-scroll { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; margin: 0 -8px; padding: 0 8px; scrollbar-width: thin; }
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 6px; }
.brand b { display: block; font-weight: 600; }
.brand small { display: block; color: var(--mute); font-size: 12px; }
.mark { width: 34px; height: 34px; flex: none; border-radius: 9px; background: var(--ink); color: var(--bg); display: grid; place-items: center; font: 22px/1 var(--serif); }
.newchat { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 9px 12px; font-size: 13.5px; text-align: left; }
.newchat:hover { border-color: var(--mute); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--soft); font-weight: 500; cursor: pointer; }
.nav-item:hover { color: var(--ink); background: color-mix(in srgb, var(--panel) 60%, transparent); }
.nav-item.is-on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .05); }
.nav-item.is-soon { cursor: default; opacity: .75; }
.nav-item.is-soon:hover { background: none; color: var(--soft); }
.count { margin-left: auto; font-size: 11.5px; color: var(--mute); }
.soon { margin-left: auto; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--mute); border: 1px solid var(--line); border-radius: 99px; padding: 0 7px; font-weight: 500; }
.nav-group summary { list-style: none; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary svg:last-child { color: var(--mute); transition: transform .15s; }
.nav-group[open] summary svg:last-child { transform: rotate(90deg); }
.sub { margin: 2px 0 6px 28px; border-left: 1px solid var(--line); }
.sub a { display: block; padding: 5px 12px; font-size: 13.5px; color: var(--soft); border-radius: 0 8px 8px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub a:hover { color: var(--ink); }
.sub a.is-on { color: var(--acc); background: var(--acc-bg); font-weight: 500; box-shadow: inset 2px 0 0 var(--acc); }
.more { margin: 0 0 4px 28px; }
.more summary { list-style: none; display: flex; align-items: center; padding: 5px 12px; font-size: 12.5px; color: var(--mute); cursor: pointer; }
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: "+"; margin-left: 8px; }
.more[open] summary::after { content: "−"; }
.more summary .count { margin-left: 6px; }
.more .sub { margin-left: 0; }

.try { padding: 0 10px; display: flex; flex-direction: column; }
.label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--mute); font-weight: 500; margin-bottom: 4px; }
.try-q { text-align: left; font-size: 13px; color: var(--soft); padding: 5px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.try-q:hover { color: var(--ink); }

.me { flex: none; display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); background: var(--panel); border-radius: 12px; }
.me:hover { border-color: var(--mute); }
.me b { display: block; font-size: 13.5px; }
.me small { display: block; font-size: 12px; color: var(--mute); }
.me-avatar { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: #fff; flex: none; }
.online { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }

/* ── Center chat ──────────────────────────────────────────────────────── */
.center { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.mobile-bar { display: none; }
.scroll { flex: 1; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; }
.hello { margin: auto; width: 100%; max-width: 760px; padding: 40px 64px; }
.app.is-chatting .hello { display: none; }
.hello-avatar { width: 64px; height: 64px; border-radius: 50%; background: #fff; border: 1px solid var(--line); margin-bottom: 22px; }
.hello h1 { font: 400 clamp(40px, 4.4vw, 56px)/1.05 var(--serif); letter-spacing: -.01em; }
.hello h1 span { display: block; }
.hello p { color: var(--soft); font-size: 16px; line-height: 1.7; margin-top: 16px; max-width: 560px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 7px 14px; font-size: 13.5px; color: var(--soft); }
.chip:hover { border-color: var(--mute); color: var(--ink); }

.thread { width: 100%; max-width: 780px; margin: 0 auto; padding: 36px 64px 12px; display: flex; flex-direction: column; gap: 22px; }
.thread:empty { display: none; }
.msg-user { align-self: flex-end; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 16px 16px 4px 16px; max-width: 75%; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-bot { display: flex; gap: 12px; align-items: flex-start; }
.msg-bot > img { width: 32px; height: 32px; border-radius: 50%; background: #fff; border: 1px solid var(--line); flex: none; }
.msg-bot .text { min-width: 0; line-height: 1.7; overflow-wrap: anywhere; }
.msg-bot .text p + p, .msg-bot .text p + ul, .msg-bot .text ul + p { margin-top: 10px; }
.msg-bot .text ul { list-style: disc; padding-left: 20px; }
.msg-bot .text .via { margin-top: 8px; font-size: 11.5px; color: var(--mute); }
.msg-bot .text a { color: var(--acc); text-decoration: underline; text-underline-offset: 2px; }
.typing span { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: var(--mute); 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; } }
.open-card { display: flex; gap: 12px; align-items: center; margin-top: 12px; border: 1px solid var(--acc); background: var(--acc-bg); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; text-align: left; width: 100%; max-width: 440px; }
.open-card b { display: block; }
.open-card small { color: var(--soft); font-size: 12.5px; }
.open-card .go { margin-left: auto; color: var(--acc); font-weight: 500; white-space: nowrap; }

.composer { width: 100%; max-width: 780px; margin: 0 auto; padding: 12px 64px 18px; }
.box { display: flex; align-items: flex-end; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 10px 10px 10px 18px; box-shadow: var(--shadow); }
.box:focus-within { border-color: var(--mute); }
.box textarea { flex: 1; border: 0; background: none; resize: none; outline: none; line-height: 1.5; padding: 8px 0; max-height: 160px; }
.box textarea::placeholder { color: var(--mute); }
.send { width: 38px; height: 38px; flex: none; border-radius: 11px; background: var(--ink); color: var(--bg); display: grid; place-items: center; }
.send:disabled { opacity: .4; cursor: default; }
.fine { text-align: center; font-size: 11.5px; color: var(--mute); margin-top: 8px; }

/* ── Right panel ──────────────────────────────────────────────────────── */
.right { display: none; background: var(--panel); border-left: 1px solid var(--line); min-height: 0; overflow: hidden; }
.app.has-panel .right { display: flex; flex-direction: column; }
.panel { display: none; flex-direction: column; min-height: 0; height: 100%; }
.panel.is-open { display: flex; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px 14px 24px; border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--mute); }
.crumb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.close { border: 1px solid var(--line); width: 30px; height: 30px; }
.panel-body { padding: 22px 24px 40px; overflow-y: auto; }
.panel-body h2 { font: 400 34px/1.1 var(--serif); margin: 4px 0 8px; }
.panel-body h2 small { font: 14px var(--sans); color: var(--mute); margin-left: 4px; }
.panel-body h5 { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--mute); font-weight: 500; margin: 22px 0 8px; }
.panel-body > p { color: var(--soft); }
.lead { color: var(--soft); line-height: 1.65; }
.kicker { font-size: 11px; letter-spacing: .12em; color: var(--acc); font-weight: 600; text-transform: uppercase; }
.portrait { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 12px; margin-bottom: 18px; }
.portrait.is-drawing { background: var(--side); display: grid; place-items: center; }
.portrait.is-drawing img { width: 150px; height: 150px; border-radius: 50%; background: #fff; border: 1px solid var(--line); }
.shot { margin-bottom: 16px; }
.shot img { width: 100%; max-height: 300px; object-fit: cover; object-position: top; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.archive .shot img { max-height: none; }
.shot.is-logo img { padding: 8% 12%; object-fit: contain; }
.shot figcaption { font-size: 12px; color: var(--mute); margin-top: 6px; }
.facts { margin-top: 16px; border-top: 1px solid var(--line); }
.facts div { display: grid; grid-template-columns: 84px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.facts dt { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--mute); padding-top: 2px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.tags span { font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; color: var(--soft); background: var(--bg); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--ink); color: var(--bg); border: 1px solid var(--ink); border-radius: 10px; padding: 8px 14px; font-size: 13px; font-weight: 500; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--mute); }
.btn.is-soon { opacity: .45; cursor: default; }
.rows { border-top: 1px solid var(--line); }
.rows a { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.rows a:hover b { color: var(--acc); }
.rows span { color: var(--mute); font-size: 12.5px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skills li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.skill { font-size: 13px; border: 1px solid var(--line); border-radius: 99px; padding: 3px 11px; background: var(--bg); }
.used { font-size: 12.5px; color: var(--mute); }
.used a:hover { color: var(--acc); }
.details { margin-top: 26px; padding-top: 6px; border-top: 1px solid var(--line); color: var(--soft); font-size: 14px; }
.details h4 { color: var(--ink); font-size: 13px; font-weight: 600; margin: 18px 0 6px; }
.details p + p { margin-top: 8px; }
.details ul { list-style: disc; padding-left: 18px; }
.details li + li { margin-top: 4px; }
.details code { font-size: 12.5px; background: var(--side); padding: 1px 5px; border-radius: 4px; }
.scrim { display: none; }

/* ── Narrower screens ─────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .app.has-panel { grid-template-columns: var(--left-w) minmax(0, 1fr); }
  .right { position: fixed; top: 0; right: 0; bottom: 0; width: min(var(--right-w), 92vw); z-index: 20; box-shadow: -12px 0 32px rgba(0, 0, 0, .12); }
  .app.has-panel .scrim { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(20, 16, 12, .25); }
  .thread, .composer { padding-left: 40px; padding-right: 40px; }
  .hello { padding: 40px; }
}
@media (max-width: 820px) {
  .app, .app.has-panel { grid-template-columns: minmax(0, 1fr); }
  .left { position: fixed; top: 0; left: 0; bottom: 0; width: min(300px, 86vw); z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .app.menu-open .left { transform: none; box-shadow: 12px 0 32px rgba(0, 0, 0, .15); }
  .app.menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(20, 16, 12, .25); }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 600; }
  .mini-avatar { width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 1px solid var(--line); }
  .right { width: 100vw; box-shadow: none; }
  .thread, .composer { padding-left: 16px; padding-right: 16px; }
  .hello { padding: 32px 20px; }
  .msg-user { max-width: 88%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ── Projects page ────────────────────────────────────────────────────── */
.page { min-height: 100vh; }
.archive-bar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; background: color-mix(in srgb, var(--bg) 92%, transparent); border-bottom: 1px solid var(--line); font-size: 13.5px; }
.archive-bar a { display: inline-flex; align-items: center; gap: 6px; color: var(--soft); }
.archive-bar a:hover { color: var(--ink); }
.archive { max-width: 760px; margin: 0 auto; padding: 48px 24px 80px; }
.archive h1 { font: 400 52px/1.05 var(--serif); }
.archive > .muted { margin-top: 8px; }
.index { margin: 28px 0 12px; border-top: 1px solid var(--line); }
.index a { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); }
.index a:hover b { color: var(--acc); }
.index span { color: var(--mute); font-size: 13px; }
.entry { padding-top: 56px; scroll-margin-top: 60px; }
.entry h2 { font: 400 38px/1.1 var(--serif); margin: 4px 0 10px; }
.entry .links { margin: 10px 0 16px; font-size: 13.5px; }
.entry .links a { color: var(--acc); }
.archive-foot { margin-top: 64px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--mute); font-size: 13px; }
