/* Canonical UI refinement. Loaded after the historical stylesheet. */
:root {
  --ui-bg: #f5f6f8;
  --ui-card: #fff;
  --ui-ink: #20262d;
  --ui-muted: #707b84;
  --ui-hairline: #ebedf0;
  --ui-green: #06b86b;
  --ui-reply: #263f64;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ui-bg: #15181c;
    --ui-card: #202429;
    --ui-ink: #edf0f3;
    --ui-muted: #9aa3ad;
    --ui-hairline: #2d333a;
    --ui-green: #54ce94;
    --ui-reply: #b2cbed;
  }
}
html { background: var(--ui-bg); }
button, input, select { font-family: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--ui-green);
  outline-offset: 3px;
}
.topbar {
  background: var(--ui-card) !important;
  border-bottom: 1px solid var(--ui-hairline) !important;
  box-shadow: none !important;
}
.topbar h1 { font-weight: var(--general-bold-weight, 720); letter-spacing: -.025em; }

/* Gray-on-gray, compact silhouette: no oversized outlined stick figure. */
.default-profile-avatar {
  display: grid !important;
  place-items: center !important;
  background: #e7eaee !important;
  color: #a4adb8 !important;
}
.default-profile-avatar::before,
.default-profile-avatar::after {
  content: none !important;
  display: none !important;
}
.profile-glyph {
  display: block;
  width: 68%;
  height: 68%;
  fill: currentColor;
  stroke: none;
}
.photo-profile-avatar .profile-glyph { display: none; }
@media (prefers-color-scheme: dark) {
  .default-profile-avatar { background: #3a424c !important; color: #778390 !important; }
}

/* Lower-bowed arrow and numeral share one precisely centered line box. */
.post-reply-mini,
.tree-chain-reaction {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 0 0 auto !important;
  gap: 2px !important;
  height: 14px !important;
  min-width: 0 !important;
  padding: 0 2px !important;
  margin: 0 !important;
  line-height: 1 !important;
  font-size: calc(9px * var(--general-font-scale, 1)) !important;
  font-weight: var(--general-bold-weight, 650) !important;
  color: var(--ui-reply) !important;
  background: none !important;
  box-shadow: none !important;
}
.post-reply-mini > span,
.tree-chain-reaction > span {
  display: flex;
  align-items: center;
  height: 12px;
  line-height: 12px;
  font-variant-numeric: tabular-nums;
}
.post-reply-mini .reply-arrow-svg,
.tree-chain-reaction .reply-arrow-svg {
  display: block !important;
  flex: 0 0 12px !important;
  width: 12px !important;
  height: 12px !important;
  fill: none !important;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: translateY(-1px);
}
.post-head, .chain-head { flex-wrap: nowrap !important; }
.post-name, .chain-name { flex: 0 1 auto !important; min-width: 0; }
.post-id-compact, .chain-id { flex: 0 1 auto; font-variant-numeric: tabular-nums; }
#threadMeta, #filterSummary { display: none !important; }

/* Home components use their own classes so older decorative rules cannot leak in. */
#homeView.hub-page { background: var(--ui-bg); padding: 12px 14px 100px; color: var(--ui-ink); }
.hub-brand { display: flex; align-items: center; gap: 10px; padding: 1px 2px 12px; }
.hub-brand strong { font-size: calc(22px * var(--general-font-scale, 1)); font-weight: var(--general-bold-weight, 750); letter-spacing: -.055em; }
.hub-brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px;
  color: #fff; background: #06b86b;
  box-shadow: inset 0 1px 0 #ffffff29;
}
.hub-brand-mark svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.hub-hero {
  display: grid; grid-template-columns: minmax(0, 1fr) 48px; align-items: center; gap: 10px 12px;
  width: 100%; margin: 0 0 16px; padding: 14px;
  border: 1px solid var(--ui-hairline); border-radius: 16px; text-align: left;
  background: var(--ui-card); color: var(--ui-ink);
  box-shadow: 0 2px 8px #163e2805;
}
.hub-hero-copy { min-width: 0; display: grid; gap: 4px; }
.hub-hero-copy small { font-size: calc(12px * var(--general-font-scale, 1)); color: var(--ui-muted); font-weight: var(--general-bold-weight, 500); }
.hub-hero-copy strong { font-size: calc(22px * var(--general-font-scale, 1)); font-weight: var(--general-bold-weight, 700); line-height: 1.4; letter-spacing: -.035em; overflow-wrap: anywhere; }
.hub-board-symbol { display: grid; place-items: center; flex: 0 0 auto; width: 44px; height: 44px; border-radius: 14px; color: #1a8865; background: #e7f4ee; }
.hub-board-symbol.is-archive { color: var(--ui-muted); background: var(--ui-bg); }
.interface-icon { display: block; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.hub-hero .hub-board-symbol { width: 44px; height: 44px; border-radius: 13px; background: color-mix(in srgb, var(--ui-green) 10%, var(--ui-card)); color: var(--ui-green); box-shadow: none; }
.hub-hero .interface-icon { width: 27px; height: 27px; }
.hub-section { margin: 0 0 16px; padding: 0; border: 0; border-radius: 0; background: transparent; overflow: visible; }
.hub-section-heading { display: flex; align-items: center; justify-content: space-between; min-height: 30px; margin-bottom: 6px; padding: 0 2px; gap: 12px; }
.hub-section-heading h2 { margin: 0; font-size: calc(15px * var(--general-font-scale, 1)); line-height: 1.5; font-weight: var(--general-bold-weight, 650); color: var(--ui-ink); }
.hub-heading-button { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 30px; padding: 0; border: 0; background: none; color: var(--ui-ink); font-size: calc(15px * var(--general-font-scale, 1)); font-weight: var(--general-bold-weight, 650); text-align: left; }
.hub-count { display: grid; place-items: center; min-width: 20px; height: 20px; border-radius: 7px; background: var(--ui-hairline); color: var(--ui-muted); font-size: calc(12px * var(--general-font-scale, 1)); font-weight: var(--general-bold-weight, 500); font-variant-numeric: tabular-nums; }
.hub-chevron { display: block; width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; color: var(--ui-muted); }
.hub-heading-button > .hub-chevron { margin-left: auto; }
.hub-text-action { border: 0; background: none; color: var(--ui-green); padding: 6px 1px 6px 10px; font-size: calc(13px * var(--general-font-scale, 1)); font-weight: var(--general-bold-weight, 600); }
.hub-list, .hub-favorites { background: var(--ui-card); border: 1px solid var(--ui-hairline); border-radius: 16px; box-shadow: none; }
.hub-list { overflow: hidden; }
.hub-board-row, .hub-history-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 20px; align-items: center; column-gap: 11px; width: 100%; min-height: 66px; padding: 11px 12px; border: 0; border-bottom: 1px solid var(--ui-hairline); background: transparent; text-align: left; color: var(--ui-ink); }
.hub-board-row:last-child, .hub-history-row:last-child { border-bottom: 0; }
.hub-row-copy { min-width: 0; }
.hub-row-title { display: block; font-size: calc(15px * var(--general-font-scale, 1)); font-weight: var(--general-bold-weight, 650); line-height: 1.45; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hub-row-sub { display: block; margin-top: 3px; font-size: calc(12px * var(--general-font-scale, 1)); line-height: 1.4; color: var(--ui-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hub-board-check { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: var(--ui-green); background: color-mix(in srgb, var(--ui-green) 9%, transparent); }
.hub-board-check .interface-icon { width: 13px; height: 13px; stroke-width: 2.1; }
.hub-board-row > .hub-chevron .interface-icon { width: 16px; height: 16px; }
.hub-add-board { display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%; min-height: 38px; margin-top: 7px; padding: 8px; border: 1px dashed color-mix(in srgb, var(--ui-muted) 25%, transparent); border-radius: 14px; background: transparent; color: var(--ui-muted); font-size: calc(13px * var(--general-font-scale, 1)); font-weight: var(--general-bold-weight, 550); }
.hub-add-board svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.hub-favorites { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 8px; padding: 12px 10px; }
.hub-favorite-item { position: relative; display: flex; align-items: center; flex-direction: column; gap: 7px; min-width: 0; padding: 0; border: 0; background: none; color: var(--ui-ink); }
.hub-favorite-avatar { width: 42px !important; height: 42px !important; border-radius: 14px !important; }
.hub-favorite-name { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: calc(11px * var(--general-font-scale, 1)); line-height: 1.5; }
.hub-favorite-unread { position: absolute; top: -4px; right: max(0px, calc(50% - 26px)); display: grid; place-items: center; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px; background: var(--ui-green); color: #fff; border: 2px solid var(--ui-card); box-sizing: content-box; font-size: calc(8px * var(--general-font-scale, 1)); font-weight: var(--general-bold-weight, 650); }
.hub-favorite-empty { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 2px; }
.hub-favorite-empty > .interface-icon { width: 24px; height: 24px; flex: 0 0 auto; color: #a5b2ba; }
.hub-favorite-empty strong { display: block; font-size: calc(14px * var(--general-font-scale, 1)); font-weight: var(--general-bold-weight, 550); color: var(--ui-ink); }
.hub-favorite-empty small { display: block; margin-top: 4px; font-size: calc(12px * var(--general-font-scale, 1)); line-height: 1.5; color: var(--ui-muted); }
.hub-history-row { grid-template-columns: 42px minmax(0, 1fr) 34px; column-gap: 10px; min-height: 74px; }
.hub-history-avatar { width: 42px !important; height: 42px !important; border-radius: 13px !important; }
.hub-history-row .hub-row-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; white-space: normal; font-size: calc(14px * var(--general-font-scale, 1)); line-height: 1.45; }
.hub-history-time { align-self: start; padding-top: 3px; font-size: calc(11px * var(--general-font-scale, 1)); line-height: 1.5; color: var(--ui-muted); font-variant-numeric: tabular-nums; }
.hub-list .home-empty { color: var(--ui-muted); font-size: calc(14px * var(--general-font-scale, 1)); padding: 18px 12px; }
#homeView.history-mode > .hub-brand, #homeView.history-mode > .hub-hero,
#homeView.settings-mode > .hub-brand, #homeView.settings-mode > .hub-hero { display: none; }
.hub-hero:active, .hub-board-row:active, .hub-history-row:active { filter: brightness(.97); }
@media (prefers-color-scheme: dark) {
  .hub-board-symbol { color: #77cfaa; background: #254037; }
  .hub-board-symbol.is-archive { color: var(--ui-muted); background: var(--ui-bg); }
}
#boardView { background: var(--ui-card) !important; }
#boardView .thread-card { padding: 13px 15px !important; column-gap: 12px !important; border-bottom-color: var(--ui-hairline); }
#boardView .thread-title { font-weight: var(--general-bold-weight, 620) !important; line-height: 1.5; letter-spacing: -.015em; }
#boardView .thread-stats { color: var(--ui-muted); gap: 9px; }
#boardView .thread-age { color: var(--ui-muted); font-size: calc(9px * var(--general-font-scale, 1)) !important; }
#boardView .thread-avatar { width: 44px; height: 44px; }
.home-bottom-bar {
  left: 12px !important; right: 12px !important;
  bottom: max(10px, env(safe-area-inset-bottom)) !important;
  border: 1px solid var(--ui-hairline) !important;
  border-radius: 25px !important;
  min-height: 62px !important;
  padding: 7px 6px !important;
  background: var(--ui-card) !important;
  box-shadow: 0 6px 28px #14273714 !important;
}
.home-bottom-bar .home-tab-action { gap: 5px !important; color: var(--ui-muted) !important; border-radius: 17px; background: none !important; }
.home-bottom-bar .home-tab-action.active { color: var(--ui-green) !important; background: color-mix(in srgb, var(--ui-green) 7%, transparent) !important; }
.home-bottom-bar .home-tab-svg { width: 21px !important; height: 21px !important; stroke-width: 1.65 !important; }
.home-bottom-bar .home-tab-action small { font-size: calc(11px * var(--general-font-scale, 1)) !important; font-weight: var(--general-bold-weight, 650); }

/* Each native date control lives inside a bounded field; no separator overlaps it. */
.archive-period-fields { padding: 12px; border-top: 1px solid var(--ui-hairline); }
.archive-clear-dates { padding: 0 2px; background: transparent; border: 0; color: var(--ui-green); font-size: calc(10px * var(--general-font-scale, 1)); }
.archive-range-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.archive-date-field { display: block; min-width: 0; }
.archive-date-field > span:first-child { display: block; margin: 0 0 5px 2px; color: var(--ui-muted); font-size: calc(10px * var(--general-font-scale, 1)); }
.archive-date-picker { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 7px; width: 100%; min-width: 0; height: 40px; padding: 0 11px; border: 1px solid var(--ui-hairline); border-radius: 11px; background: var(--ui-card); overflow: hidden; }
.archive-date-picker:focus-within { outline: 2px solid var(--ui-green); outline-offset: 2px; }
.archive-date-value { min-width: 0; font-size: calc(12px * var(--general-font-scale, 1)); line-height: 1.2; font-variant-numeric: tabular-nums; color: var(--ui-muted); white-space: nowrap; }
.archive-date-value.has-date { color: var(--ui-ink); }
.archive-date-picker svg { flex: 0 0 15px; width: 15px; height: 15px; fill: none; stroke: var(--ui-muted); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.archive-date-picker input[type="date"] { position: absolute; inset: 0; width: 100%; min-width: 0; max-width: 100%; height: 100%; margin: 0; padding: 0; opacity: 0; border: 0; font-size: calc(16px * var(--general-font-scale, 1)); cursor: pointer; }
.archive-date-picker input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; cursor: pointer; }
.thread-compose-bar { gap: 6px; }
.thread-filter-actions { gap: 2px; }
.thread-filter-mini { width: 36px; }
.thread-filter-mini.active { color: var(--ui-green); background: color-mix(in srgb, var(--ui-green) 7%, transparent); }

/* Settings is ordinary document flow, not an overlay or bottom sheet. */
.settings-page { position: static; width: 100%; background: transparent; }
.settings-page.hidden { display: none !important; }
.settings-page-content { padding: 0; }
.prefs-group { margin: 0 0 16px; }
.prefs-group h2 { margin: 0 2px 7px; color: var(--ui-muted); font-size: calc(13px * var(--general-font-scale, 1)); line-height: 1.5; font-weight: var(--general-bold-weight, 600); }
.prefs-card { overflow: hidden; border: 1px solid var(--ui-hairline); border-radius: 14px; background: var(--ui-card); }
.prefs-select, .prefs-toggle, .prefs-link, .prefs-range { width: 100%; padding: 12px 13px; margin: 0; border: 0; border-bottom: 1px solid var(--ui-hairline); border-radius: 0; background: transparent; text-align: left; color: var(--ui-ink); }
.prefs-card > :last-child, .prefs-card > .prefs-link { border-bottom: 0; }
.prefs-select, .prefs-toggle, .prefs-link { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 62px; }
.prefs-select > span, .prefs-toggle > span, .prefs-link > span { min-width: 0; }
.prefs-card strong { display: block; font-size: calc(15px * var(--general-font-scale, 1)); line-height: 1.45; font-weight: var(--general-bold-weight, 600); }
.prefs-card small { display: block; margin-top: 4px; color: var(--ui-muted); font-size: calc(12px * var(--general-font-scale, 1)); line-height: 1.45; }
.prefs-select { flex-wrap: wrap; gap: 12px; }
.prefs-select > span { flex: 1 1 140px; }
.prefs-select #defaultBoardSelect { flex: 0 1 116px; min-width: 0; max-width: 100%; margin: 0; padding: 8px 10px; border: 1px solid var(--ui-hairline); border-radius: 9px; background: var(--ui-bg); color: var(--ui-ink); font-size: calc(15px * var(--general-font-scale, 1)); }
.prefs-range { display: block; }
.prefs-range > span { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.prefs-range #fontSizeValue { margin: 0; font-variant-numeric: tabular-nums; }
.prefs-range input { display: block; width: 100%; margin: 12px 0 2px; accent-color: var(--ui-green); }
.prefs-link { min-height: 54px; }
.prefs-link svg { flex: 0 0 17px; width: 17px; height: 17px; fill: none; stroke: var(--ui-muted); stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.prefs-link:active { background: var(--ui-bg); }
.prefs-switch { position: relative; appearance: none; -webkit-appearance: none; display: block; flex: 0 0 43px; width: 43px; height: 26px; margin: 0; padding: 0; border: 0; border-radius: 13px; background: #cbd1d8; cursor: pointer; transition: background .15s; }
.prefs-switch::before { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #19263526; transition: transform .15s; }
.prefs-switch:checked { background: var(--ui-green); }
.prefs-switch:checked::before { transform: translateX(17px); }
.settings-past-log { margin: 0 15px 16px; padding-top: 0; }
@media (max-width: 350px) {
  #homeView.hub-page { padding-right: 14px; padding-left: 14px; }
  .hub-board-row, .hub-history-row { padding-right: 12px; padding-left: 12px; column-gap: 9px; }
  .prefs-select, .prefs-toggle, .prefs-link, .prefs-range { padding-right: 13px; padding-left: 13px; }
}

/* NG editor is a full-screen detail page, with three categories. */
#ngOverlay { background: var(--ui-bg) !important; }
#ngOverlay > .overlay-dismiss { display: none; }
#ngOverlay > .sheet {
  position: absolute !important; inset: 0 !important;
  box-sizing: border-box; width: 100% !important; height: 100% !important;
  max-height: none !important; max-width: none !important;
  border-radius: 0 !important;
  padding: calc(20px + env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom)) !important;
  background: var(--ui-bg) !important;
  overflow-y: auto !important; transform: none !important;
}
#ngOverlay .sheet-handle { display: none; }
#ngOverlay .sheet-title-row { margin-bottom: 20px; }
#ngOverlay .ng-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: var(--ui-hairline); margin-bottom: 18px; }
#ngOverlay .ng-tab { border: 0; border-radius: 10px; padding: 10px 4px; font-size: calc(12px * var(--general-font-scale, 1)); background: transparent; color: var(--ui-muted); }
#ngOverlay .ng-tab.active { background: var(--ui-card); color: var(--ui-green); box-shadow: 0 1px 3px #00000009; }
.ng-add-form { padding: 17px; border: 1px solid var(--ui-hairline); border-radius: 18px; background: var(--ui-card); margin-bottom: 16px; }
.ng-add-form > label { display: block; font-size: calc(12px * var(--general-font-scale, 1)); margin-bottom: 10px; color: var(--ui-ink); font-weight: var(--general-bold-weight, 650); }
#ngPattern { width: 100%; box-sizing: border-box; padding: 12px; border-radius: 10px; background: var(--ui-bg); border: 1px solid var(--ui-hairline); color: var(--ui-ink); font-size: calc(16px * var(--general-font-scale, 1)); }
.ng-add-options { display: flex; flex-wrap: wrap; gap: 10px 14px; margin: 14px 0; color: var(--ui-ink); }
.ng-add-options label { display: flex; align-items: center; gap: 5px; font-size: calc(11px * var(--general-font-scale, 1)); }
.ng-add-options input { accent-color: var(--ui-green); }
.ng-help { font-size: calc(10px * var(--general-font-scale, 1)); color: var(--ui-muted); line-height: 1.6; }
.ng-form-error { color: #d45255; font-size: calc(11px * var(--general-font-scale, 1)); line-height: 1.5; }
.ng-form-error:empty { display: none; }
.ng-add-button { width: 100%; border: 0; border-radius: 11px; padding: 12px; background: var(--ui-green); color: #fff; font-size: calc(12px * var(--general-font-scale, 1)); font-weight: var(--general-bold-weight, 700); }
.ng-item-title { overflow-wrap: anywhere; }
.ng-item-main { min-width: 0; }
#ngOverlay .ng-item { padding: 15px 4px; border-color: var(--ui-hairline); }
@media (prefers-reduced-motion: reduce) {
  .home-tab-action, .prefs-switch, .prefs-switch::before { transition: none !important; }
}

/* Center the text block within the bubble, including minimum-width one-character posts. */
.post-body, .chain-body, .chain-pinned-root .chain-body {
  padding: 8px 11px !important;
  text-align: center;
  white-space: normal;
}
.bubble-text {
  display: inline-block;
  max-width: 100%;
  vertical-align: top;
  text-align: left;
  white-space: pre-wrap;
}
.board-url-field { position: relative; min-width: 0; }
.board-add-form input { font-size: calc(16px * var(--general-font-scale, 1)); user-select: text; -webkit-user-select: text; }
.board-url-field input { padding-right: 42px; }
.board-url-clear {
  position: absolute; top: 0; right: 0; width: 40px; height: 40px;
  display: grid; place-items: center; padding: 0; border: 0;
  border-radius: 0 11px 11px 0; background: transparent; color: var(--ui-muted); font-size: calc(24px * var(--general-font-scale, 1));
}
.board-form-error { margin: 0; color: #c74646; font-size: calc(13px * var(--general-font-scale, 1)); line-height: 1.5; }
.board-form-error:empty { display: none; }
.board-add-form > small { font-size: calc(12px * var(--general-font-scale, 1)); }
.board-add-form > button:disabled { opacity: .55; }
