:root {
  --bg: #ffffff; --fg: #17191c; --muted: #5f6b76; --line: #e8ecef; --hover: #f6f8f9; --soft: #f1f4f8;
  --accent: #2f6fde; --accent-soft: #e8f0fd; --mark: #fff3a3; --danger: #c62828;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111315; --fg: #e6e8ea; --muted: #8b949c; --line: #2a2e33; --hover: #181b1e; --soft: #1b1f23;
          --accent: #6ea2ff; --accent-soft: #1b2a44; --mark: #5c4d00; --danger: #ef7070; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg);
       font: 15px/1.55 -apple-system, "Segoe UI", "Hiragino Sans", "Meiryo", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
mark { background: var(--mark); color: inherit; padding: 0 1px; }
button { font: inherit; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
        stroke-linejoin: round; flex: none; }
.small { font-size: 13px; color: var(--muted); }
.err { color: var(--danger); font-size: 14px; }

/* sign-in */
.signin { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.signin .card { max-width: 380px; width: 100%; border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px;
                text-align: center; }
.signin .logo { font-size: 26px; font-weight: 800; color: var(--accent); }
.signin #gbutton { display: flex; justify-content: center; margin: 18px 0 6px; min-height: 44px; }

/* the column */
.col { max-width: 640px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line);
       min-height: 100vh; }
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent);
       backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.bar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; position: relative; }
.bar .logo { font-size: 19px; color: var(--accent); }
.bar select { min-width: 0; max-width: 60%; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line);
              background: var(--hover); color: var(--fg); }
.spacer { flex: 1; }
.ghost { background: none; border: 0; color: var(--fg); padding: 6px; border-radius: 50%; cursor: pointer; display: flex; }
.ghost:hover { background: var(--hover); }
.menu { position: absolute; right: 12px; top: 44px; background: var(--bg); border: 1px solid var(--line);
        border-radius: 12px; box-shadow: 0 6px 24px rgba(0, 0, 0, .12); min-width: 220px; padding: 6px; }
.menu .who { padding: 8px 10px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line);
             margin-bottom: 4px; overflow-wrap: anywhere; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--fg);
               padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--hover); }
.tabs { display: flex; }
.tabs button { flex: 1; background: none; border: 0; color: var(--muted); padding: 10px 0 9px; cursor: pointer;
               font-weight: 600; border-bottom: 3px solid transparent; }
.tabs button.on { color: var(--fg); border-bottom-color: var(--accent); }
.tabs button:hover { background: var(--hover); }

/* profile */
.banner { height: 150px; background: var(--line) center/cover no-repeat; }
.profile { padding: 0 16px 12px; border-bottom: 1px solid var(--line); }
.profile .big { width: 100px; height: 100px; border-radius: 50%; border: 4px solid var(--bg); margin-top: -50px;
                background: var(--line); display: block; }
.profile h1 { font-size: 20px; margin: 8px 0 0; }
.profile .handle, .profile .stats { color: var(--muted); }
.profile .stats b { color: var(--fg); }
.profile .bio { margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* filters */
.filters { padding: 10px 16px; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px 14px;
           align-items: center; font-size: 14px; }
.filters input[type=search] { flex: 1 1 100%; min-width: 0; padding: 9px 16px; border-radius: 999px;
                              border: 1px solid var(--line); background: var(--hover); color: var(--fg); font-size: 15px; }
.filters select, .filters input[type=date] { background: var(--hover); color: var(--fg); border: 1px solid var(--line);
                                             border-radius: 8px; padding: 5px 8px; }
.filters label { color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.count { padding: 8px 16px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); }

/* posts */
article { padding: 12px 16px; border-bottom: 1px solid var(--line); }
article:hover { background: var(--hover); }
.rt { color: var(--muted); font-size: 13px; font-weight: 700; margin: 0 0 4px 30px; display: flex; align-items: center;
      gap: 6px; }
.rt svg { width: 15px; height: 15px; }
.row { display: flex; gap: 12px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; background: var(--line); object-fit: cover; }
.main { min-width: 0; flex: 1; }
.head { display: flex; gap: 4px; align-items: baseline; white-space: nowrap; overflow: hidden; }
.head b { overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; max-width: 60%; }
.head .meta { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.head .meta a { color: var(--muted); }
.replyto { color: var(--muted); font-size: 14px; }
.text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.media { margin-top: 12px; display: grid; gap: 2px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line);
         aspect-ratio: 16 / 9; max-height: 510px; }
.media .cell { position: relative; display: block; min-width: 0; min-height: 0; overflow: hidden; background: var(--line);
               cursor: zoom-in; }
.media .cell.video { cursor: auto; background: #000; }
.media img, .media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media .video video { object-fit: contain; }
.m2 { grid-template-columns: 1fr 1fr; }
.m3, .m4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.m3 > :first-child { grid-row: span 2; }
.media .tag { position: absolute; left: 8px; bottom: 8px; background: rgba(0, 0, 0, .75); color: #fff; font-size: 12px;
              font-weight: 700; padding: 0 5px; border-radius: 4px; }
.quote { margin-top: 10px; border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; }
.quote .avatar { width: 20px; height: 20px; }
.quote .row { gap: 6px; align-items: center; }
.quote .text { font-size: 14px; }
.actions { display: flex; justify-content: space-between; max-width: 425px; margin-top: 10px; color: var(--muted);
           font-size: 13px; }
.actions span { display: inline-flex; align-items: center; gap: 4px; }
.actions svg { width: 16px; height: 16px; }
.actions .hot { color: var(--accent); font-weight: 700; }
.more { text-align: center; padding: 16px; color: var(--muted); }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

/* ask */
#view-ask { display: flex; flex-direction: column; min-height: calc(100vh - 92px); }
.chat { flex: 1; padding: 8px 0 16px; }
.intro { padding: 24px 16px; color: var(--muted); }
.intro h2 { color: var(--fg); font-size: 18px; margin: 0 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chips button { background: var(--soft); color: var(--fg); border: 1px solid var(--line); border-radius: 999px;
                padding: 7px 14px; cursor: pointer; font-size: 14px; text-align: left; }
.chips button:hover { border-color: var(--accent); }
.q { margin: 14px 16px 6px auto; max-width: 85%; width: fit-content; background: var(--accent-soft); padding: 9px 14px;
     border-radius: 16px 16px 4px 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.a { padding: 4px 16px 10px; }
.steps { margin: 4px 0 8px; display: flex; flex-direction: column; gap: 3px; }
.steps div { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.steps svg { width: 14px; height: 14px; }
.answer { overflow-wrap: anywhere; }
.answer p { margin: 0 0 10px; }
.answer ul, .answer ol { margin: 0 0 10px; padding-left: 22px; }
.answer li { margin: 2px 0; }
.answer h3 { font-size: 16px; margin: 14px 0 6px; }
.cite { display: inline-block; min-width: 20px; padding: 0 5px; margin: 0 1px; border-radius: 6px; font-size: 12px;
        line-height: 18px; text-align: center; background: var(--accent-soft); color: var(--accent); font-weight: 700;
        vertical-align: 1px; cursor: pointer; }
.cites { margin-top: 10px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.cites > .label { font-size: 12px; color: var(--muted); padding: 8px 12px; background: var(--soft); }
.cites article { padding: 10px 12px; }
.cites article .n { color: var(--accent); font-weight: 700; margin-right: 4px; }
.cites article.flash { background: var(--accent-soft); }
.foot { font-size: 12px; color: var(--muted); margin-top: 6px; }
.thinking { color: var(--muted); font-size: 14px; }
.thinking::after { content: "…"; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .2; } }
.ask { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 10px 16px 14px; background: var(--bg);
       border-top: 1px solid var(--line); }
.ask textarea { flex: 1; resize: none; max-height: 160px; padding: 10px 14px; border-radius: 18px; font: inherit;
                border: 1px solid var(--line); background: var(--hover); color: var(--fg); }
.ask button { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--accent); color: #fff;
              cursor: pointer; display: flex; align-items: center; justify-content: center; align-self: flex-end; }
.ask button:disabled { opacity: .5; cursor: default; }

/* admin */
.pad { padding: 16px; }
.pad h2 { margin: 0 0 4px; font-size: 18px; }
.inline { display: flex; gap: 8px; margin: 12px 0; }
.inline input { flex: 1; min-width: 0; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line);
                background: var(--hover); color: var(--fg); }
.inline button, .users button { background: var(--fg); color: var(--bg); border: 0; border-radius: 999px; padding: 6px 14px;
                                cursor: pointer; font-weight: 600; }
.users { width: 100%; border-collapse: collapse; font-size: 14px; }
.users td, .users th { border-bottom: 1px solid var(--line); padding: 8px 4px; text-align: left; }
.users th { color: var(--muted); font-weight: 600; font-size: 12px; }

/* the full-size viewer */
#viewer { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .92); display: flex; align-items: center;
          justify-content: center; }
#viewer img { max-width: 100vw; max-height: 100vh; object-fit: contain; }
#viewer button { position: absolute; width: 40px; height: 40px; border-radius: 50%; border: 0;
                 background: rgba(40, 40, 40, .8); color: #fff; font-size: 24px; line-height: 40px; cursor: pointer; padding: 0; }
#viewer .close { top: 12px; left: 12px; }
#viewer .prev { left: 12px; top: 50%; transform: translateY(-50%); }
#viewer .next { right: 12px; top: 50%; transform: translateY(-50%); }
#viewer .count { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: #ccc; font-size: 13px; }
@media (max-width: 640px) { .col { border: 0; } .banner { height: 110px; } }
