* { box-sizing: border-box; }
:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --text: #131418;
  --muted: #737780;
  --line: #e1e3e8;
  --accent: #2f6feb;
  --hot: #ef5b5b;
  --warn: #d97706;
  --shadow: 0 8px 30px rgba(0,0,0,.08);
  --post-font-size: 15px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1012;
    --surface: #181a1e;
    --surface-2: #22252a;
    --text: #f3f4f6;
    --muted: #989da7;
    --line: #2b2e34;
    --accent: #76a7ff;
    --hot: #ff7777;
    --warn: #ffb454;
    --shadow: none;
  }
}
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", sans-serif; }
body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
button, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  min-height: calc(54px + env(safe-area-inset-top));
  padding: calc(6px + env(safe-area-inset-top)) 12px 6px;
  display: grid; grid-template-columns: 38px 1fr 38px; align-items: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}
.title-wrap { text-align: center; min-width: 0; }
.eyebrow { color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .04em; }
h1 { margin: 1px 0 0; font-size: 16px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-button {
  width: 34px; height: 34px; border: 0; border-radius: 11px;
  background: var(--surface); font-size: 24px; line-height: 1; box-shadow: var(--shadow);
}
.controls { padding: 14px 14px 8px; position: sticky; top: calc(69px + env(safe-area-inset-top)); z-index: 10; background: var(--bg); }
.search {
  height: 44px; display: flex; align-items: center; gap: 8px;
  padding: 0 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
}
.search span { color: var(--muted); font-size: 22px; }
.search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 16px; min-width: 0; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 10px; padding: 4px; border-radius: 12px; background: var(--surface-2); }
.segment { border: 0; border-radius: 9px; padding: 8px 6px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 700; }
.segment.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.tool-row { display: flex; gap: 8px; align-items: center; margin-top: 9px; overflow-x: auto; }
.tool-button, .toggle-pill {
  min-height: 34px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 700;
}
.tool-button { padding: 7px 11px; }
.toggle-pill { display: inline-flex; gap: 6px; align-items: center; padding: 6px 10px; }
.toggle-pill input { accent-color: var(--accent); }

.past-log-panel { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 9px; }
.past-log-panel input {
  min-width: 0; height: 40px; padding: 0 11px; border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface); color: var(--text); outline: none;
}
.past-log-panel button { border: 0; border-radius: 11px; padding: 0 15px; background: var(--accent); color: #fff; font-weight: 800; }

.gesture-hint { padding: 8px 14px 2px; color: var(--muted); font-size: 11px; text-align: center; }
.status { padding: 22px; text-align: center; color: var(--muted); font-size: 14px; }
.thread-list { padding: 0 12px calc(88px + env(safe-area-inset-bottom)); }
.thread-row { border-bottom: 1px solid var(--line); }
.thread-card { width: 100%; border: 0; padding: 15px 4px; background: transparent; text-align: left; min-width: 0; user-select: none; -webkit-user-select: none; }
.thread-card.longpress-active, .post.longpress-active { transform: scale(.99); background: var(--surface-2); }
.thread-title { margin: 0 0 8px; font-size: 16px; line-height: 1.45; font-weight: 700; overflow-wrap: anywhere; }
.thread-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.badge { display: inline-flex; align-items: center; border-radius: 99px; padding: 3px 7px; background: var(--surface-2); font-weight: 700; }
.badge.hot { color: var(--hot); }
.badge.red-reply { color: var(--hot); background: color-mix(in srgb, var(--hot) 12%, var(--surface)); }
.badge.image { color: var(--accent); }
.badge.ai { color: var(--warn); }

.thread-meta { padding: 12px 16px 6px; color: var(--muted); font-size: 12px; }
.filter-summary { min-height: 20px; padding: 0 16px 7px; color: var(--muted); font-size: 11px; border-bottom: 1px solid var(--line); }
.post-list { padding: 3px 7px calc(112px + env(safe-area-inset-bottom)); }
.post {
  margin: 3px 0; padding: 10px 11px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface); user-select: none; -webkit-user-select: none;
  transition: transform .08s ease, background .08s ease;
}
.post.red-post { border-color: color-mix(in srgb, var(--hot) 45%, var(--line)); }
.post.range-candidate { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); }
.post-head { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 5px; font-size: 12px; color: var(--muted); }
.post-number { color: var(--accent); font-weight: 800; font-size: 13px; }
.post-name { font-weight: 700; color: var(--text); }
.post-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.post-body { white-space: pre-wrap; word-break: break-word; font-size: var(--post-font-size); line-height: 1.65; user-select: text; -webkit-user-select: text; }
.post-body a { color: var(--accent); text-decoration: none; overflow-wrap: anywhere; }
.search-mark { background: color-mix(in srgb, var(--warn) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

.thread-bottom-bar {
  position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
.bottom-action {
  border: 0; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; gap: 2px; align-items: center; justify-content: center;
  min-height: 48px; border-radius: 10px;
}
.bottom-action span { font-size: 20px; line-height: 1; }
.bottom-action small { font-size: 10px; font-weight: 700; }
.bottom-action.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }

.thread-search-panel {
  position: fixed; z-index: 58; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: 1fr 38px; gap: 7px;
  padding: 9px 10px calc(9px + env(safe-area-inset-bottom));
  border-radius: 16px 16px 0 0; background: var(--surface); border-top: 1px solid var(--line); box-shadow: var(--shadow);
}
.compact-search { height: 40px; }
.small-close { border: 0; border-radius: 11px; background: var(--surface-2); font-size: 20px; }

.range-banner {
  position: fixed; z-index: 56; left: 12px; right: 12px; bottom: calc(72px + env(safe-area-inset-bottom));
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 11px 13px; border-radius: 14px; background: var(--accent); color: white; box-shadow: var(--shadow);
  font-size: 12px; font-weight: 800;
}
.range-banner button { border: 0; border-radius: 9px; padding: 6px 9px; background: rgba(255,255,255,.18); color: white; }

.jump-bottom {
  position: fixed; right: 16px; bottom: calc(82px + env(safe-area-inset-bottom));
  z-index: 45; border: 0; border-radius: 999px; padding: 11px 15px;
  background: var(--accent); color: white; font-weight: 800; box-shadow: var(--shadow);
}

.overlay { position: fixed; inset: 0; z-index: 90; display: flex; align-items: flex-end; }
.overlay-dismiss { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(0,0,0,.38); }
.sheet {
  position: relative; z-index: 1; width: 100%;
  max-height: min(78vh, 680px); overflow: auto;
  padding: 8px 14px calc(18px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0; background: var(--surface);
  box-shadow: 0 -14px 40px rgba(0,0,0,.2);
}
.tall-sheet { min-height: 48vh; }
.sheet-handle { width: 40px; height: 5px; margin: 2px auto 12px; border-radius: 999px; background: var(--line); }
.sheet h2 { margin: 0 0 4px; font-size: 18px; }
.sheet-subtitle { color: var(--muted); font-size: 12px; margin-bottom: 10px; word-break: break-word; }
.sheet-actions { display: grid; gap: 1px; }
.sheet-action, .sheet-row {
  width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent;
  padding: 14px 4px; text-align: left; font-size: 15px;
}
.sheet-action.danger { color: var(--hot); }
.sheet-toggle {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 2px; border-bottom: 1px solid var(--line);
}
.sheet-toggle span { display: grid; gap: 3px; }
.sheet-toggle small { color: var(--muted); font-size: 11px; }
.sheet-toggle input { width: 22px; height: 22px; accent-color: var(--accent); }

.sheet-title-row { display: flex; align-items: center; justify-content: space-between; }
.text-button { border: 0; background: transparent; color: var(--accent); font-weight: 700; }
.ng-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 12px 0; padding: 4px; border-radius: 12px; background: var(--surface-2); }
.ng-tab { border: 0; border-radius: 9px; padding: 8px; background: transparent; color: var(--muted); font-weight: 700; }
.ng-tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.ng-list { display: grid; gap: 6px; max-height: 42vh; overflow: auto; }
.ng-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 10px 11px; border: 1px solid var(--line); border-radius: 12px; }
.ng-item-main { min-width: 0; }
.ng-item-title { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ng-item-sub { margin-top: 3px; color: var(--muted); font-size: 10px; word-break: break-all; }
.ng-remove { border: 0; border-radius: 9px; padding: 6px 9px; background: var(--surface-2); color: var(--hot); font-size: 11px; font-weight: 800; }
.ng-empty { padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }
.danger-outline { width: 100%; margin-top: 12px; border: 1px solid color-mix(in srgb, var(--hot) 50%, var(--line)); border-radius: 12px; padding: 11px; background: transparent; color: var(--hot); font-weight: 800; }

.error-card { margin: 18px 14px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.error-card strong { display:block; margin-bottom: 6px; }
.toast {
  position: fixed; z-index: 120; left: 50%; bottom: calc(82px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 10px 14px; border-radius: 999px; background: #17181b; color: #fff;
  font-size: 12px; font-weight: 700; box-shadow: 0 8px 30px rgba(0,0,0,.25);
}

.inline-images {
  display: flex; flex-wrap: wrap; gap: 7px; margin-top: 7px;
}
.inline-image-link {
  display: block; width: 132px; height: 96px; padding: 0;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: var(--surface-2);
}
.inline-image {
  display: block; width: 100%; height: 100%; object-fit: cover; background: #0b0b0c;
}
.inline-image-error {
  width: 132px; min-height: 62px; padding: 10px;
  color: var(--muted); font-size: 11px; text-align: center;
}

.image-viewer-overlay {
  position: fixed; inset: 0; z-index: 140;
  display: flex; align-items: center; justify-content: center;
  padding: calc(18px + env(safe-area-inset-top)) 12px calc(18px + env(safe-area-inset-bottom));
}
.image-viewer-backdrop {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border: 0; background: rgba(0,0,0,.88);
}
.image-viewer-content {
  position: relative; z-index: 1; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.image-viewer-content img {
  display: block; max-width: 100%; max-height: 100%;
  object-fit: contain; border-radius: 8px;
}
.image-viewer-close {
  position: absolute; top: 4px; right: 4px; z-index: 2;
  width: 42px; height: 42px; border: 0; border-radius: 999px;
  background: rgba(20,20,20,.72); color: white; font-size: 28px; line-height: 1;
}

.tree-root { display: grid; gap: 3px; }
.tree-node { min-width: 0; }
.tree-children {
  margin-left: 14px; padding-left: 10px;
  border-left: 2px solid color-mix(in srgb, var(--accent) 24%, var(--line));
}
.tree-children .post { margin-top: 3px; margin-bottom: 3px; }
.tree-link-label { margin: -2px 0 4px 6px; color: var(--muted); font-size: 10px; }

.settings-section { padding: 10px 2px 14px; border-bottom: 1px solid var(--line); }
.settings-label { margin-bottom: 8px; font-size: 13px; font-weight: 800; }
.settings-segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); }
.settings-choice { border: 0; border-radius: 9px; padding: 9px; background: transparent; color: var(--muted); font-weight: 800; }
.settings-choice.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.settings-range { display: grid; gap: 9px; padding: 14px 2px; border-bottom: 1px solid var(--line); }
.settings-range span { display: flex; justify-content: space-between; align-items: center; }
.settings-range small { color: var(--muted); }
.settings-range input { width: 100%; accent-color: var(--accent); }


/* Board controls live at the bottom, same as thread controls. */
#boardView .gesture-hint { padding-top: 7px; }
.settings-past-log { margin: 6px 0 10px; }

/* In red-reply mode the right edge opens the entire descendant chain. */
.post.has-chain-button { position: relative; padding-right: 45px; }
.reply-chain-button {
  position: absolute; top: 0; right: 0; bottom: 0; width: 39px;
  border: 0; border-left: 1px solid var(--line);
  border-radius: 0 10px 10px 0;
  background: color-mix(in srgb, var(--accent) 5%, transparent);
  color: var(--accent);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; touch-action: manipulation;
}
.reply-chain-button strong { font-size: 23px; line-height: .9; }
.reply-chain-button small { font-size: 9px; font-weight: 800; }

.chain-sheet { max-height: 86vh; }
.chain-list { display: grid; gap: 3px; padding-top: 6px; }
.chain-node { min-width: 0; }
.chain-post {
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface);
}
.chain-post.root { border-color: color-mix(in srgb, var(--hot) 45%, var(--line)); }
.chain-head { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 4px; color: var(--muted); font-size: 11px; }
.chain-number { color: var(--accent); font-weight: 800; }
.chain-body { white-space: pre-wrap; word-break: break-word; font-size: var(--post-font-size); line-height: 1.55; }
.chain-children {
  margin-left: 13px; padding-left: 8px; margin-top: 3px;
  border-left: 2px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  display: grid; gap: 3px;
}

.compact-settings-section { padding-top: 3px; }
.image-viewer-content,
.image-viewer-content img {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.inline-image-url-label {
  color: var(--muted);
  font-size: .9em;
}

.board-bottom-bar { grid-template-columns: repeat(3, 1fr); }

.live-anchor {
  display: inline;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 800;
  text-decoration: none;
}
.quoted-transcript {
  margin-top: 7px;
  padding: 7px 9px;
  border-left: 3px solid var(--line);
  border-radius: 4px;
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  color: var(--muted);
  white-space: pre-wrap;
}


/* LINE-inspired chat UI */
:root {
  --accent: #06c755;
  --chat-bg: #b8c9dc;
  --chat-bubble: #ffffff;
  --chat-list: #ffffff;
  --avatar-bg: #d9dde3;
  --nav-bg: rgba(255,255,255,.96);
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #31d66b;
    --chat-bg: #20272e;
    --chat-bubble: #2b3036;
    --chat-list: #181a1e;
    --avatar-bg: #3b4148;
    --nav-bg: rgba(24,26,30,.96);
  }
}

body { background: var(--surface); }

.topbar {
  min-height: calc(49px + env(safe-area-inset-top));
  padding: calc(5px + env(safe-area-inset-top)) 10px 5px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  border-bottom: 1px solid var(--line);
}
.eyebrow { display: none; }
h1 { font-size: 16px; font-weight: 750; }
.icon-button {
  width: 32px; height: 32px; border-radius: 50%;
  background: transparent; box-shadow: none;
  font-size: 24px; font-weight: 400;
}

/* Talk list */
#boardView { min-height: calc(100vh - 49px); background: var(--chat-list); }
#boardView .gesture-hint {
  padding: 7px 12px 5px; background: var(--surface-2);
  font-size: 10px;
}
.thread-list { padding: 0 0 calc(76px + env(safe-area-inset-bottom)); background: var(--chat-list); }
.thread-row { border-bottom: 1px solid var(--line); }
.thread-card {
  display: grid; grid-template-columns: 48px minmax(0,1fr); gap: 11px;
  align-items: center;
  width: 100%; min-height: 72px;
  padding: 10px 14px;
  background: var(--chat-list);
}
.thread-card:active, .thread-card.longpress-active { background: var(--surface-2); transform: none; }
.thread-avatar {
  width: 48px; height: 48px; border-radius: 17px;
  display: grid; place-items: center;
  background: var(--avatar-bg); color: var(--text);
  font-size: 19px; font-weight: 800;
}
.thread-card-content { min-width: 0; }
.thread-title {
  margin: 0 0 5px;
  font-size: 15px; line-height: 1.35; font-weight: 700;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.thread-stats {
  gap: 8px; flex-wrap: nowrap; min-width: 0;
  font-size: 11px; color: var(--muted);
}
.thread-stats .badge {
  padding: 0; background: transparent; border-radius: 0; font-weight: 600;
}
.thread-stats .badge.hot { color: var(--accent); }
#boardStatus { background: var(--chat-list); }

/* Conversation */
#threadView { min-height: calc(100vh - 49px); background: var(--chat-bg); }
.thread-meta {
  padding: 6px 12px 2px;
  background: var(--chat-bg);
  color: color-mix(in srgb, var(--text) 62%, transparent);
  text-align: center; font-size: 10px;
}
.filter-summary {
  min-height: 0; padding: 0 12px 5px;
  background: var(--chat-bg); border-bottom: 0;
  color: color-mix(in srgb, var(--text) 58%, transparent);
  text-align: center; font-size: 10px;
}
#threadView .gesture-hint {
  padding: 3px 12px 7px;
  background: var(--chat-bg);
  color: color-mix(in srgb, var(--text) 55%, transparent);
  font-size: 9px;
}
.post-list {
  padding: 4px 8px calc(104px + env(safe-area-inset-bottom));
  background: var(--chat-bg);
}
.post {
  position: relative;
  display: grid; grid-template-columns: 34px minmax(0,1fr); gap: 7px;
  align-items: start;
  margin: 4px 0; padding: 0;
  border: 0; border-radius: 0; background: transparent;
  user-select: none; -webkit-user-select: none;
}
.post.longpress-active { transform: none; background: transparent; }
.post-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  margin-top: 16px;
  background: var(--avatar-bg);
  color: var(--muted);
  font-size: 10px; font-weight: 800;
}
.post-message { min-width: 0; max-width: min(82vw, 680px); }
.post-head {
  min-height: 16px; gap: 5px; margin: 0 0 2px 5px;
  font-size: 10px;
  color: color-mix(in srgb, var(--text) 60%, transparent);
}
.post-number { color: var(--accent); font-size: 10px; }
.post-name { font-size: 11px; color: var(--text); font-weight: 700; }
.post-body {
  position: relative;
  width: fit-content; max-width: 100%;
  padding: 9px 11px;
  border-radius: 5px 15px 15px 15px;
  background: var(--chat-bubble);
  box-shadow: 0 1px 1px rgba(0,0,0,.06);
  line-height: 1.5;
}
.post-body::before {
  content: "";
  position: absolute; left: -6px; top: 0;
  width: 0; height: 0;
  border-top: 8px solid var(--chat-bubble);
  border-left: 7px solid transparent;
}
.post.red-post { border: 0; }
.post.red-post .post-body {
  outline: 1px solid color-mix(in srgb, var(--hot) 48%, transparent);
}
.post .badge {
  padding: 1px 4px; background: color-mix(in srgb, var(--surface) 75%, transparent);
  font-size: 9px;
}
.post-body a, .live-anchor { color: #1687d9; }
.quoted-transcript {
  border-left: 2px solid color-mix(in srgb, var(--muted) 45%, transparent);
  background: color-mix(in srgb, var(--surface-2) 75%, transparent);
  border-radius: 5px; padding: 6px 8px;
}

/* Images behave like chat attachments. */
.inline-images {
  margin-top: 4px; margin-left: 0;
  display: flex; flex-wrap: wrap; gap: 5px;
}
.inline-image-link {
  width: 116px; height: 88px;
  border: 0; border-radius: 13px;
}
.inline-image { border-radius: 13px; }

/* Bottom navigation */
.thread-bottom-bar {
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
  background: var(--nav-bg);
  box-shadow: 0 -1px 5px rgba(0,0,0,.05);
}
.bottom-action { min-height: 45px; border-radius: 8px; }
.bottom-action span { font-size: 18px; font-weight: 700; }
.bottom-action small { font-size: 9px; }
.bottom-action.active {
  color: var(--accent); background: transparent;
}

/* Search and sheets */
.search { border-radius: 10px; background: var(--surface-2); border-color: transparent; }
.thread-search-panel { background: var(--nav-bg); }
.sheet { border-radius: 18px 18px 0 0; }
.settings-choice.active, .ng-tab.active {
  color: var(--accent);
}
.jump-bottom { background: var(--accent); }
.reply-chain-button { color: var(--accent); }


/* LINE-inspired v2: prioritize readability and message width */
:root {
  --line-green: #06c755;
  --line-chat-bg: #8fa8c4;
  --line-list-bg: #ffffff;
  --line-bubble: #ffffff;
  --line-muted: #747b84;
  --line-avatar: #dfe3e7;
}
@media (prefers-color-scheme: dark) {
  :root {
    --line-green: #2fd66b;
    --line-chat-bg: #27313b;
    --line-list-bg: #17191d;
    --line-bubble: #2b2e33;
    --line-muted: #9ba2aa;
    --line-avatar: #3c4249;
  }
}

.topbar {
  grid-template-columns: 36px minmax(0,1fr) 36px;
  min-height: calc(46px + env(safe-area-inset-top));
  padding: calc(4px + env(safe-area-inset-top)) 9px 4px;
  background: var(--line-list-bg);
}
#backButton { grid-column: 1; }
.title-wrap {
  grid-column: 2;
  min-width: 0;
  text-align: center;
}
#refreshButton { grid-column: 3; }
h1 {
  font-size: 16px;
  font-weight: 750;
  max-width: 100%;
}
.icon-button {
  width: 32px; height: 32px;
  background: transparent;
  box-shadow: none;
}

/* Main list: talk-list information hierarchy */
#boardView { background: var(--line-list-bg); }
.thread-list { background: var(--line-list-bg); }
.thread-card {
  grid-template-columns: 46px minmax(0,1fr);
  gap: 11px;
  min-height: 70px;
  padding: 10px 12px;
}
.thread-avatar {
  width: 46px; height: 46px;
  border-radius: 16px;
  background: var(--line-avatar);
  color: var(--text);
  font-size: 17px;
}
.thread-card-content { min-width: 0; width: 100%; }
.thread-topline {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 8px;
  align-items: start;
}
.thread-title {
  min-width: 0;
  margin: 0;
  font-size: 15px;
  line-height: 1.32;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.thread-age {
  flex: none;
  padding-top: 1px;
  color: var(--line-muted);
  font-size: 10px;
  white-space: nowrap;
}
.thread-stats {
  margin-top: 6px;
  display: flex;
  gap: 9px;
  color: var(--line-muted);
  font-size: 11px;
}
.thread-stats .badge {
  padding: 0;
  background: none;
  font-size: 11px;
}
.thread-stats .badge.hot {
  order: 0;
  color: var(--line-green);
  font-weight: 750;
}
.thread-stats .badge:not(.hot) {
  order: 1;
  color: var(--line-muted);
}

/* Thread screen: header info should not compete with the conversation */
#threadView { background: var(--line-chat-bg); }
.thread-meta {
  padding: 5px 10px 3px;
  background: var(--line-chat-bg);
  color: color-mix(in srgb, var(--text) 55%, transparent);
  font-size: 10px;
  text-align: center;
}
.filter-summary {
  padding: 0 10px 4px;
  min-height: 0;
  border: 0;
  background: var(--line-chat-bg);
  color: color-mix(in srgb, var(--text) 55%, transparent);
  font-size: 10px;
  text-align: center;
}
.post-list {
  padding: 4px 7px calc(96px + env(safe-area-inset-bottom));
  background: var(--line-chat-bg);
}

/* Message row */
.post {
  display: grid;
  grid-template-columns: 32px minmax(0,1fr);
  gap: 7px;
  align-items: start;
  margin: 6px 0;
  padding: 0;
  background: transparent;
  border: 0;
}
.post-avatar {
  width: 32px; height: 32px;
  margin-top: 15px;
  border-radius: 50%;
  background: var(--line-avatar);
  color: var(--line-muted);
  font-size: 9px;
  letter-spacing: -.02em;
}
.post-message {
  min-width: 0;
  width: 100%;
  max-width: 100%;
}
.post-head {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 2px 4px;
  min-height: 14px;
  color: color-mix(in srgb, var(--text) 57%, transparent);
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
}
.post-number {
  flex: none;
  color: var(--line-green);
  font-size: 10px;
  font-weight: 800;
}
.post-name {
  flex: none;
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
}
.post-id-compact {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: color-mix(in srgb, var(--text) 48%, transparent);
  font-size: 9px;
}
.post-head .badge {
  flex: none;
  padding: 0 3px;
  font-size: 8px;
}

.post-bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  min-width: 0;
}
.post-body {
  position: relative;
  width: fit-content;
  max-width: min(78vw, 640px);
  padding: 8px 11px;
  border-radius: 5px 15px 15px 15px;
  background: var(--line-bubble);
  color: var(--text);
  box-shadow: none;
  font-size: var(--post-font-size);
  line-height: 1.48;
}
.post-body::before {
  content: "";
  position: absolute;
  left: -6px; top: 0;
  border-top: 8px solid var(--line-bubble);
  border-left: 7px solid transparent;
}
.post-time {
  flex: none;
  padding-bottom: 2px;
  color: color-mix(in srgb, var(--text) 48%, transparent);
  font-size: 8px;
  line-height: 1;
}
.post.red-post .post-body {
  outline: 1.5px solid color-mix(in srgb, var(--hot) 55%, transparent);
}
.post.red-post { border: 0; }

/* Reply tree: indentation must not destroy bubble width */
.tree-root { gap: 2px; }
.tree-children {
  margin-left: 7px;
  padding-left: 5px;
  border-left: 1px solid color-mix(in srgb, var(--line-green) 42%, transparent);
}
.tree-children .post { margin: 5px 0; }

/* Attachments stay inside the message column */
.inline-images {
  margin: 5px 0 0;
  padding-left: 0;
  gap: 5px;
}
.inline-image-link {
  width: 112px; height: 84px;
  border-radius: 12px;
}

/* Quoted logs should look secondary */
.quoted-transcript {
  margin-top: 6px;
  padding: 6px 8px;
  border-left: 2px solid color-mix(in srgb, var(--line-muted) 50%, transparent);
  border-radius: 5px;
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  color: color-mix(in srgb, var(--text) 66%, transparent);
  font-size: .92em;
}

/* Bottom navigation: monochrome line icons, no emoji glyphs */
.thread-bottom-bar {
  min-height: 54px;
  padding: 3px 6px calc(3px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--line-list-bg) 96%, transparent);
}
.bottom-action {
  min-height: 46px;
  gap: 3px;
  color: var(--line-muted);
}
.bottom-action.active { color: var(--line-green); }
.bottom-action small { font-size: 9px; font-weight: 650; }
.nav-glyph {
  position: relative;
  display: block;
  width: 19px; height: 17px;
  color: currentColor;
}
.glyph-list {
  background: repeating-linear-gradient(
    to bottom,
    currentColor 0 1.5px,
    transparent 1.5px 5.5px
  );
  border-radius: 1px;
}
.glyph-reply::before {
  content: "";
  position: absolute; left: 3px; top: 4px;
  width: 12px; height: 8px;
  border-left: 1.7px solid currentColor;
  border-bottom: 1.7px solid currentColor;
  border-radius: 0 0 0 5px;
}
.glyph-reply::after {
  content: "";
  position: absolute; left: 1px; top: 2px;
  width: 6px; height: 6px;
  border-left: 1.7px solid currentColor;
  border-top: 1.7px solid currentColor;
  transform: rotate(-45deg);
}
.glyph-image {
  border: 1.5px solid currentColor;
  border-radius: 3px;
}
.glyph-image::before {
  content: "";
  position: absolute; right: 3px; top: 3px;
  width: 3px; height: 3px;
  border: 1.4px solid currentColor;
  border-radius: 50%;
}
.glyph-image::after {
  content: "";
  position: absolute; left: 3px; bottom: 3px;
  width: 10px; height: 7px;
  background: currentColor;
  clip-path: polygon(0 100%, 38% 44%, 58% 70%, 75% 50%, 100% 100%);
  opacity: .9;
}
.glyph-search::before {
  content: "";
  position: absolute; left: 3px; top: 1px;
  width: 10px; height: 10px;
  border: 1.6px solid currentColor;
  border-radius: 50%;
}
.glyph-search::after {
  content: "";
  position: absolute; left: 13px; top: 11px;
  width: 6px; height: 1.6px;
  background: currentColor;
  transform: rotate(45deg);
  transform-origin: left center;
}
.glyph-more {
  background:
    radial-gradient(circle at 3px 8px, currentColor 0 2px, transparent 2.2px),
    radial-gradient(circle at 9.5px 8px, currentColor 0 2px, transparent 2.2px),
    radial-gradient(circle at 16px 8px, currentColor 0 2px, transparent 2.2px);
}
.glyph-trend::before,
.glyph-trend::after {
  content: "";
  position: absolute;
  bottom: 2px;
  width: 3px;
  border-radius: 2px 2px 0 0;
  background: currentColor;
}
.glyph-trend::before {
  left: 3px; height: 6px;
  box-shadow: 6px -4px 0 currentColor, 12px -9px 0 currentColor;
}

/* Keep red-mode chain affordance narrow */
.post.has-chain-button { padding-right: 30px; }
.reply-chain-button {
  width: 28px;
  border-left: 0;
  background: transparent;
  color: var(--line-green);
}
