/* 言 Yan — X-grade dark UI. Single committed theme: true black, hairline borders, one blue. */
:root {
  --bg: #000000;
  --surface: #16181c;
  --surface-hover: rgba(231, 233, 234, 0.03);
  --border: #2f3336;
  --text: #e7e9ea;
  --muted: #71767b;
  --accent: #1d9bf0;
  --accent-hover: #1a8cd8;
  --accent-soft: rgba(29, 155, 240, 0.1);
  --like: #f91880;
  --like-soft: rgba(249, 24, 128, 0.1);
  --success: #00ba7c;
  --danger: #f4212e;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: var(--font); cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: rgba(29, 155, 240, 0.4); }

/* ---------- shell: nav rail | 600px column | right bar ---------- */
.shell {
  display: grid;
  grid-template-columns: 275px minmax(0, 600px) 350px;
  justify-content: center;
  min-height: 100vh;
  gap: 0 24px;
}
.column {
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  min-height: 100vh;
  padding-bottom: 96px;
}

/* ---------- left rail ---------- */
.rail { position: relative; }
.rail-inner {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 8px 8px 16px 8px; margin-left: auto; width: 245px;
}
.brand { display: inline-flex; padding: 6px; border-radius: 999px; margin: 2px 0 4px; }
.brand:hover { background: var(--surface-hover); text-decoration: none; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1d9bf0, #0b6bb8);
  color: #fff; font-size: 24px; font-weight: 700;
}
.nav { display: flex; flex-direction: column; width: 100%; }
.nav a {
  display: flex; align-items: center; gap: 18px;
  color: var(--text); font-size: 19px; padding: 4px;
  border-radius: 999px; width: fit-content;
}
.nav a:hover { text-decoration: none; }
.nav a .ico {
  width: 50px; height: 50px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.nav a:hover .ico { background: var(--surface-hover); }
.nav a .lbl { padding-right: 20px; }
.nav a.active .lbl { font-weight: 700; }
.nav a svg { width: 25px; height: 25px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.nav a.active svg { stroke-width: 2.6; }

.compose-cta {
  margin-top: 14px; width: 86%;
  background: var(--accent); color: #fff; border: none;
  border-radius: 999px; height: 50px;
  font-size: 17px; font-weight: 700; letter-spacing: 0.06em;
  transition: background 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.compose-cta:hover { background: var(--accent-hover); }
.compose-cta .cta-icon svg { width: 22px; height: 22px; stroke: #fff; stroke-width: 2.2; fill: none; stroke-linecap: round; stroke-linejoin: round; display: none; }

.identity { margin-top: auto; width: 100%; }
.identity .id-chip {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; border-radius: 999px; border: none; background: none;
  color: var(--text); text-align: left; font-size: 15px;
  transition: background 0.15s;
}
.identity .id-chip:hover { background: var(--surface-hover); }
.identity .id-name { font-weight: 700; line-height: 1.25; }
.identity .id-npub { color: var(--muted); font-size: 13px; line-height: 1.25; }
.identity .gen-key {
  width: 86%; background: none; border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; height: 44px; font-size: 15px; font-weight: 700;
}
.identity .gen-key:hover { background: var(--surface-hover); }

/* ---------- avatars ---------- */
.avatar {
  border-radius: 999px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255, 255, 255, 0.92); font-weight: 700; user-select: none;
}
.avatar.a40 { width: 40px; height: 40px; font-size: 17px; }
.avatar.a48 { width: 48px; height: 48px; font-size: 20px; }
.avatar.a88 { width: 88px; height: 88px; font-size: 40px; border: 4px solid var(--bg); }

/* ---------- column header ---------- */
.col-head {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  height: 53px; padding: 0 16px;
  background: rgba(0, 0, 0, 0.68); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.col-head .title { font-size: 19px; font-weight: 700; }
.col-head .subtitle { font-size: 12.5px; color: var(--muted); line-height: 1.2; }
.col-head .back {
  width: 36px; height: 36px; border-radius: 999px; border: none; background: none; color: var(--text);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.col-head .back:hover { background: var(--surface-hover); }
.col-head .back svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2.2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.col-head .m-brand { display: none; }

/* ---------- composer ---------- */
.composer { display: flex; gap: 12px; padding: 14px 16px 8px; border-bottom: 1px solid var(--border); }
.composer .c-body { flex: 1; min-width: 0; }
.composer textarea {
  width: 100%; border: none; background: none; color: var(--text); resize: none;
  font-family: var(--font); font-size: 19px; line-height: 1.45; padding: 8px 0 2px;
  min-height: 52px; max-height: 40vh; outline: none;
}
.composer textarea::placeholder { color: var(--muted); }
.composer .c-bar {
  display: flex; align-items: center; gap: 14px;
  border-top: 1px solid var(--border); margin-top: 10px; padding-top: 10px;
}
.composer.bare .c-bar { border-top: none; margin-top: 4px; padding-top: 4px; }
.composer .c-hint { color: var(--muted); font-size: 12.5px; }
.composer .c-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.ring { transform: rotate(-90deg); }
.ring .track { stroke: var(--border); }
.ring .bar { stroke: var(--accent); transition: stroke-dashoffset 0.1s linear; }
.ring.warn .bar { stroke: #ffd400; }
.ring.over .bar { stroke: var(--danger); }
.btn-post {
  background: var(--accent); color: #fff; border: none; border-radius: 999px;
  padding: 0 18px; height: 36px; font-size: 15px; font-weight: 700;
  transition: background 0.15s, opacity 0.15s;
}
.btn-post:hover { background: var(--accent-hover); }
.btn-post:disabled { opacity: 0.5; cursor: default; }

/* ---------- note rows ---------- */
.row {
  display: flex; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.15s;
}
.row:hover { background: var(--surface-hover); }
.row .r-body { flex: 1; min-width: 0; }
.row .r-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; min-width: 0; }
.row .r-name { font-weight: 700; color: var(--text); }
.row .r-name:hover { text-decoration: underline; }
.row .r-meta { color: var(--muted); font-size: 14px; }
.row .r-reply-ctx { color: var(--muted); font-size: 13.5px; margin-top: 1px; }
.row .r-reply-ctx a { color: var(--accent); }
.row .r-text { margin-top: 2px; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; font-size: 15px; }
.row .r-actions { display: flex; gap: 4px; margin-top: 6px; margin-left: -8px; max-width: 340px; justify-content: space-between; }
.act {
  display: flex; align-items: center; gap: 2px;
  background: none; border: none; color: var(--muted); font-size: 13px;
  padding: 0; border-radius: 999px;
}
.act .a-ico {
  width: 34px; height: 34px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.act svg { width: 18.5px; height: 18.5px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.act.reply:hover { color: var(--accent); }
.act.reply:hover .a-ico { background: var(--accent-soft); }
.act.like:hover { color: var(--like); }
.act.like:hover .a-ico { background: var(--like-soft); }
.act.like.on { color: var(--like); }
.act.like.on svg { fill: var(--like); stroke: var(--like); }
.act.plink:hover { color: var(--accent); }
.act.plink:hover .a-ico { background: var(--accent-soft); }

/* ---------- thread ---------- */
.root-note { padding: 14px 16px 6px; border-bottom: 1px solid var(--border); }
.root-note .rn-head { display: flex; align-items: center; gap: 12px; }
.root-note .rn-names { min-width: 0; }
.root-note .rn-name { font-weight: 700; display: block; line-height: 1.3; }
.root-note .rn-name:hover { text-decoration: underline; }
.root-note .rn-npub { color: var(--muted); font-size: 13.5px; display: block; line-height: 1.3; }
.root-note .rn-text { font-size: 21px; line-height: 1.5; margin: 12px 0 10px; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
.root-note .rn-stats { color: var(--muted); font-size: 14px; padding: 12px 0; border-top: 1px solid var(--border); display: flex; gap: 18px; flex-wrap: wrap; }
.root-note .rn-stats b { color: var(--text); font-weight: 700; }
.root-note .rn-actions { display: flex; justify-content: space-around; border-top: 1px solid var(--border); padding: 4px 0; }
.parent-link { display: block; padding: 10px 16px; color: var(--muted); font-size: 13.5px; border-bottom: 1px solid var(--border); }

/* ---------- profile ---------- */
.p-banner { height: 140px; }
.p-head { padding: 0 16px 14px; border-bottom: 1px solid var(--border); }
.p-avatar-row { display: flex; justify-content: space-between; align-items: flex-end; margin-top: -44px; }
.p-actions { display: flex; gap: 8px; padding-top: 52px; flex-wrap: wrap; }
.btn-ghost {
  background: none; border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; height: 34px; padding: 0 14px; font-size: 14px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-ghost:hover { background: var(--surface-hover); text-decoration: none; }
.btn-ghost svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.p-name { font-size: 20px; font-weight: 800; margin-top: 10px; line-height: 1.25; }
.p-npub {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 4px;
  color: var(--muted); font-size: 13px; background: var(--surface);
  border-radius: 999px; padding: 3px 12px; border: none; max-width: 100%;
}
.p-npub:hover { color: var(--text); }
.p-npub code { background: none; padding: 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.p-about { margin-top: 10px; white-space: pre-wrap; word-break: break-word; }
.p-meta { color: var(--muted); font-size: 14px; margin-top: 8px; display: flex; gap: 16px; flex-wrap: wrap; }
.p-meta b { color: var(--text); }
.p-edit { padding: 4px 16px 16px; border-bottom: 1px solid var(--border); display: none; }
.p-edit.open { display: block; }

/* ---------- cards (right bar / keys / about) ---------- */
.rightbar { padding: 8px 0; }
.rb-inner { position: sticky; top: 8px; width: 320px; display: flex; flex-direction: column; gap: 16px; }
.card {
  background: var(--surface); border-radius: 16px; padding: 14px 16px;
}
.card h3 { margin: 0 0 8px; font-size: 17px; font-weight: 800; }
.card .kv { display: flex; justify-content: space-between; padding: 5px 0; font-size: 14px; }
.card .kv .k { color: var(--muted); }
.card .kv .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.card p { margin: 6px 0; font-size: 13.5px; color: var(--muted); line-height: 1.55; }
.card .chip {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; font-size: 12px; color: var(--muted); cursor: pointer; width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; text-align: left;
}
.card .chip:hover { border-color: var(--muted); color: var(--text); }
.rb-foot { color: var(--muted); font-size: 12.5px; padding: 0 16px; line-height: 1.8; }
.rb-foot a { color: var(--muted); }

/* ---------- generic panels inside column ---------- */
.panel { padding: 16px; border-bottom: 1px solid var(--border); }
.panel h2 { font-size: 17px; font-weight: 800; margin: 0 0 4px; }
.panel .p-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 12px; }
.keybox {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 11px 13px; word-break: break-all; margin-top: 8px; line-height: 1.6;
}
.keybox.secret { border-color: rgba(255, 212, 0, 0.35); }
.rowline { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.btn-pill {
  background: var(--text); color: #0f1419; border: none; border-radius: 999px;
  height: 38px; padding: 0 18px; font-size: 14px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn-pill:hover { opacity: 0.9; }
.btn-pill.blue { background: var(--accent); color: #fff; }
.btn-pill.outline { background: none; border: 1px solid var(--border); color: var(--text); }
.btn-pill.outline:hover { background: var(--surface-hover); opacity: 1; }
.btn-pill.danger { background: none; border: 1px solid rgba(244, 33, 46, 0.45); color: var(--danger); }
.btn-pill.danger:hover { background: rgba(244, 33, 46, 0.08); opacity: 1; }
.btn-pill svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
input.txt {
  width: 100%; background: none; color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 13px; font-family: var(--font); font-size: 15px; outline: none;
}
input.txt:focus { border-color: var(--accent); }
label.lbl { display: block; color: var(--muted); font-size: 13px; margin: 12px 0 2px; }

/* keys hero (no key yet) */
.hero { padding: 44px 28px 36px; text-align: center; border-bottom: 1px solid var(--border); }
.hero .h-mark {
  width: 76px; height: 76px; border-radius: 22px; margin: 0 auto 18px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1d9bf0, #0b5f9e);
  color: #fff; font-size: 42px; font-weight: 700;
  box-shadow: 0 12px 44px rgba(29, 155, 240, 0.35);
}
.hero h1 { font-size: 25px; font-weight: 800; margin: 0 0 8px; text-wrap: balance; }
.hero p { color: var(--muted); margin: 0 auto; max-width: 400px; font-size: 14.5px; line-height: 1.7; }
.hero .rowline { justify-content: center; margin-top: 22px; }

/* about timeline */
.phases { position: relative; margin: 4px 0 0; padding-left: 26px; }
.phases::before { content: ''; position: absolute; left: 8px; top: 8px; bottom: 14px; width: 2px; background: var(--border); }
.phase { position: relative; padding: 0 0 20px; }
.phase::before {
  content: ''; position: absolute; left: -24px; top: 7px; width: 12px; height: 12px;
  border-radius: 999px; background: var(--border); border: 3px solid var(--bg);
}
.phase.now::before { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.phase .ph-tag { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.phase.now .ph-tag { color: var(--accent); }
.phase .ph-title { font-weight: 700; font-size: 15.5px; margin: 2px 0; }
.phase p { color: var(--muted); font-size: 13.5px; margin: 2px 0 0; line-height: 1.65; }

/* ---------- skeleton / empty ---------- */
.skel-row { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.skel { background: var(--surface); border-radius: 8px; position: relative; overflow: hidden; }
.skel::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.empty { text-align: center; padding: 48px 32px; }
.empty .e-ico { color: var(--muted); margin-bottom: 10px; }
.empty .e-ico svg { width: 34px; height: 34px; stroke: currentColor; stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.empty .e-title { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.empty .e-sub { color: var(--muted); font-size: 14px; max-width: 320px; margin: 0 auto; line-height: 1.7; }

.show-more {
  display: block; width: 100%; padding: 14px; text-align: center;
  background: none; border: none; border-bottom: 1px solid var(--border);
  color: var(--accent); font-size: 15px;
}
.show-more:hover { background: var(--surface-hover); }

/* ---------- banners ---------- */
.notice {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-bottom: 1px solid var(--border);
  background: rgba(255, 212, 0, 0.05); font-size: 13.5px; color: var(--text);
}
.notice svg { width: 18px; height: 18px; stroke: #ffd400; stroke-width: 2; fill: none; flex-shrink: 0; stroke-linecap: round; stroke-linejoin: round; }
.notice a { font-weight: 700; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 34px; left: 50%; transform: translateX(-50%) translateY(16px);
  background: var(--accent); color: #fff; border-radius: 8px;
  padding: 11px 18px; font-size: 14px; font-weight: 500; z-index: 200;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.6);
  opacity: 0; pointer-events: none; transition: opacity 0.18s, transform 0.18s;
  max-width: min(88vw, 480px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

/* ---------- modal composer ---------- */
.modal-root { position: fixed; inset: 0; z-index: 100; }
.modal-back { position: absolute; inset: 0; background: rgba(91, 112, 131, 0.4); }
.modal {
  position: relative; margin: 6vh auto 0; width: min(600px, calc(100vw - 16px));
  background: var(--bg); border-radius: 16px; padding: 8px 0 6px;
  box-shadow: 0 0 0 1px var(--border), 0 24px 64px rgba(0, 0, 0, 0.7);
}
.modal .m-top { display: flex; padding: 4px 10px; }
.modal .m-close {
  width: 36px; height: 36px; border-radius: 999px; border: none; background: none; color: var(--text);
  display: flex; align-items: center; justify-content: center;
}
.modal .m-close:hover { background: var(--surface-hover); }
.modal .m-close svg { width: 19px; height: 19px; stroke: currentColor; stroke-width: 2.2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.modal .composer { border-bottom: none; }

/* ---------- mobile tab bar + FAB ---------- */
.tabbar {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; display: flex; align-items: center; justify-content: center;
  height: 52px; color: var(--text);
}
.tabbar a svg { width: 24.5px; height: 24.5px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.active svg { stroke-width: 2.7; }
.fab {
  display: none; position: fixed; right: 18px; bottom: 76px; z-index: 61;
  width: 56px; height: 56px; border-radius: 999px; border: none;
  background: var(--accent); color: #fff;
  box-shadow: 0 8px 28px rgba(29, 155, 240, 0.45);
  align-items: center; justify-content: center;
}
.fab:hover { background: var(--accent-hover); }
.fab svg { width: 24px; height: 24px; stroke: #fff; stroke-width: 2.1; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- responsive ---------- */
@media (max-width: 1300px) {
  .shell { grid-template-columns: 88px minmax(0, 600px) 320px; gap: 0 16px; }
  .rail-inner { width: 72px; align-items: center; padding-left: 0; padding-right: 0; }
  .nav a .lbl, .compose-cta .cta-label, .identity .id-name, .identity .id-npub { display: none; }
  .compose-cta { width: 50px; height: 50px; margin-top: 12px; }
  .compose-cta .cta-icon svg { display: block; }
  .identity .id-chip { justify-content: center; padding: 8px; }
  .identity .gen-key { display: none; }
  .rb-inner { width: 300px; }
}
@media (max-width: 1005px) {
  .shell { grid-template-columns: 88px minmax(0, 600px); }
  .rightbar { display: none; }
}
@media (max-width: 705px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .column { border: none; padding-bottom: 130px; }
  .tabbar { display: flex; }
  .fab { display: flex; }
  .col-head .m-brand {
    display: flex; width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
    align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1d9bf0, #0b6bb8); color: #fff; font-size: 16px; font-weight: 700;
  }
  .root-note .rn-text { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
