/* ============ Folo-inspired theme ============ */
:root {
  --accent: #ff5c00;
  --accent-soft: rgba(255, 92, 0, 0.12);
}
[data-theme="dark"] {
  --bg-0: #0c0c0d;
  --bg-1: #141416;
  --bg-2: #1b1b1f;
  --bg-3: #232329;
  --border: #2a2a30;
  --text-0: #f2f2f3;
  --text-1: #b8b8c0;
  --text-2: #77777f;
  --shadow: rgba(0, 0, 0, 0.5);
}
[data-theme="light"] {
  --bg-0: #f6f6f7;
  --bg-1: #ffffff;
  --bg-2: #f1f1f3;
  --bg-3: #e9e9ec;
  --border: #e2e2e6;
  --text-0: #18181b;
  --text-1: #4b4b53;
  --text-2: #8b8b93;
  --shadow: rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-0);
  color: var(--text-0);
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.62; }

.favicon,
.letter-icon {
  width: var(--icon-size, 17px);
  height: var(--icon-size, 17px);
  border-radius: 4px;
  flex: none;
  background: var(--bg-3);
  object-fit: cover;
}
.letter-icon {
  color: var(--text-2);
  font-size: calc(var(--icon-size, 17px) * 0.58);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#app {
  display: grid;
  grid-template-columns: 252px minmax(320px, 400px) minmax(460px, 1fr) 340px;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
}
#app.agent-collapsed {
  grid-template-columns: 252px minmax(320px, 400px) minmax(460px, 1fr) 0;
}
#app.agent-collapsed #agent-pane { display: none; }

/* ============ Sidebar ============ */
#sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 14px 12px;
  flex: none;
}
.brand-logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #ff8a3d);
  color: #fff; font-weight: 800; font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(255, 92, 0, 0.35);
}
.brand-name { font-weight: 700; font-size: 15px; flex: 1; }

.views { padding: 0 10px 10px; display: flex; flex-direction: column; gap: 2px; flex: none; }
.view-btn {
  display: flex; align-items: center; gap: 9px;
  background: none; border: none; color: var(--text-1);
  padding: 7px 10px; border-radius: 8px; font-size: 13.5px;
  text-align: left;
}
.view-btn:hover { background: var(--bg-2); color: var(--text-0); }
.view-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.view-ico { width: 16px; text-align: center; font-size: 12px; }
.count { margin-left: auto; font-size: 11.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.view-btn.active .count { color: var(--accent); }

.asset-dashboard {
  margin: 0 10px 10px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-2);
  flex: none;
}
.asset-dashboard-open {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: 3px;
  text-align: left;
  background: none;
  border: none;
  color: var(--text-1);
  border-radius: 7px;
  padding: 3px 4px 7px;
}
.asset-dashboard-open:hover,
.asset-dashboard-open.active {
  color: var(--text-0);
}
.asset-dashboard-open:disabled {
  cursor: default;
  opacity: 0.72;
}
.asset-dashboard-kicker {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
}
.asset-dashboard-open strong {
  font-size: 18px;
  line-height: 1.1;
  color: var(--text-0);
  font-variant-numeric: tabular-nums;
}
.asset-dashboard-open.active strong { color: var(--accent); }
#asset-dashboard-recent {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  color: var(--text-2);
}
.asset-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.asset-stat {
  min-width: 0;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  padding: 6px 7px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-1);
  color: var(--text-1);
  font-size: 11.5px;
}
.asset-stat:hover:not(:disabled),
.asset-stat.active {
  background: var(--bg-3);
  color: var(--text-0);
  border-color: var(--text-2);
}
.asset-stat:disabled {
  cursor: default;
  opacity: 0.48;
}
.asset-stat strong {
  color: var(--text-0);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.asset-stat.active strong { color: var(--accent); }
.asset-stat-translation.active { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.asset-stat-rewrite.active { border-color: color-mix(in srgb, #c89b22 42%, var(--border)); }
.asset-stat-comments.active { border-color: color-mix(in srgb, #2f855a 42%, var(--border)); }
.asset-stat-chat.active { border-color: color-mix(in srgb, #4a789f 42%, var(--border)); }

.sidebar-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 10px 10px;
}
.group-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0;
  color: var(--text-2); text-transform: uppercase;
  padding: 12px 10px 6px;
  display: flex; align-items: center; gap: 6px;
}
.feed-item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 10px; border-radius: 8px;
  color: var(--text-1); font-size: 13px;
  cursor: pointer; user-select: none;
  border: none; background: none; width: 100%; text-align: left;
}
.feed-item:hover { background: var(--bg-2); color: var(--text-0); }
.feed-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.feed-item .favicon {
  width: 17px; height: 17px; border-radius: 4px; flex: none;
  background: var(--bg-3); object-fit: cover;
}
.feed-item .letter-icon {
  width: 17px; height: 17px; border-radius: 4px; flex: none;
  background: var(--bg-3); color: var(--text-2);
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.feed-item .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-item .fcount { font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.feed-item .err-dot { width: 6px; height: 6px; border-radius: 50%; background: #e5484d; flex: none; }

.sidebar-footer {
  padding: 10px; border-top: 1px solid var(--border);
  display: flex; gap: 8px;
  flex: none;
  background: var(--bg-1);
}
.account-strip {
  padding: 9px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  background: var(--bg-1);
}
.account-strip .ghost-btn { flex: 1; }
.account-info {
  flex: 1;
  min-width: 0;
  color: var(--text-1);
  font-size: 12.5px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ghost-btn {
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text-1); border-radius: 8px;
  padding: 6px 12px; font-size: 12.5px;
  text-decoration: none; display: inline-flex; align-items: center; gap: 4px;
  flex: 1; justify-content: center;
}
.ghost-btn:hover { color: var(--text-0); border-color: var(--text-2); }
.ghost-btn:disabled:hover { color: var(--text-1); border-color: var(--border); }
.icon-btn {
  background: none; border: none; color: var(--text-2);
  font-size: 15px; padding: 4px 8px; border-radius: 7px;
}
.icon-btn:hover { background: var(--bg-2); color: var(--text-0); }

/* ============ Entry list ============ */
#entry-pane {
  background: var(--bg-0);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
}
.pane-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  gap: 10px; min-height: 57px;
}
.pane-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane-actions { display: flex; align-items: center; gap: 6px; }
#search {
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text-0); border-radius: 8px;
  padding: 6px 10px; font-size: 12.5px; width: 150px;
  outline: none;
}
#search:focus { border-color: var(--accent); }

.entry-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px; }
.entry-card {
  display: flex; gap: 10px;
  padding: 11px 12px; border-radius: 10px;
  cursor: pointer; border: 1px solid transparent;
}
.entry-card:hover { background: var(--bg-1); }
.entry-card.active { background: var(--bg-1); border-color: var(--border); box-shadow: 0 2px 8px var(--shadow); }
.entry-main { flex: 1; min-width: 0; }
.entry-top {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--text-2); margin-bottom: 4px;
}
.entry-top img { width: 13px; height: 13px; border-radius: 3px; }
.entry-top .src { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.entry-title {
  font-size: 13.5px; font-weight: 600; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.entry-original {
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.45;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.entry-card.read .entry-title { color: var(--text-2); font-weight: 500; }
.entry-summary {
  font-size: 12px; color: var(--text-2); line-height: 1.5; margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.asset-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}
.entry-asset-badges { margin-top: 7px; }
.entry-asset-activity {
  margin-top: 5px;
  color: var(--text-2);
  font-size: 11.5px;
  line-height: 1.35;
}
.reader-asset-badges { margin-top: 12px; }
.asset-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 20px;
  max-width: 100%;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}
.asset-jump {
  font-family: inherit;
  cursor: pointer;
}
.asset-jump:hover {
  background: var(--bg-3);
  transform: translateY(-1px);
}
.asset-jump:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}
.asset-translation { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.asset-rewrite { color: #7a5c18; border-color: color-mix(in srgb, #c89b22 35%, var(--border)); }
.asset-comments { color: #276749; border-color: color-mix(in srgb, #2f855a 35%, var(--border)); }
.asset-chat { color: #315174; border-color: color-mix(in srgb, #4a789f 35%, var(--border)); }
.reader-asset-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(152px, 1fr));
  gap: 6px;
  margin-top: 10px;
}
.asset-summary-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  gap: 5px;
}
.asset-summary-item {
  min-width: 0;
  width: 100%;
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-1);
  color: var(--text-1);
  font-family: inherit;
  text-align: left;
}
.asset-summary-item:hover {
  background: var(--bg-2);
  border-color: var(--text-2);
}
.asset-summary-item:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}
.asset-summary-item span {
  display: block;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 3px;
}
.asset-summary-item strong {
  display: block;
  overflow: hidden;
  color: var(--text-1);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.asset-summary-copy {
  width: 32px;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-1);
  color: var(--text-2);
  font-family: inherit;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  outline: none;
}
.asset-summary-copy:hover {
  background: var(--bg-2);
  color: var(--text-0);
  border-color: var(--text-2);
}
.asset-summary-copy:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}
.asset-summary-translation span { color: var(--accent); }
.asset-summary-rewrite span { color: #7a5c18; }
.asset-summary-comments span { color: #276749; }
.asset-summary-chat span { color: #315174; }
.entry-thumb {
  width: 64px; height: 64px; border-radius: 8px; flex: none;
  object-fit: cover; background: var(--bg-2);
}
.unread-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); flex: none; margin-top: 7px;
}
.entry-card.read .unread-dot { background: transparent; }
.entry-star { color: var(--accent); font-size: 11px; }
.list-empty { text-align: center; color: var(--text-2); padding: 60px 20px; font-size: 13px; }

/* ============ Reader ============ */
#reader-pane { overflow-y: auto; background: var(--bg-0); min-width: 0; min-height: 0; }
.reader-empty {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  color: var(--text-2); font-size: 14px;
}
.empty-logo {
  width: 64px; height: 64px; border-radius: 20px;
  background: var(--bg-2); color: var(--text-2);
  font-size: 34px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.hidden { display: none !important; }

.reader { max-width: 720px; margin: 0 auto; padding: 40px 36px 80px; }
.reader-source {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--accent); font-weight: 600;
  background: var(--accent-soft); border-radius: 999px;
  padding: 4px 12px; margin-bottom: 14px;
}
.reader-source img { width: 14px; height: 14px; border-radius: 3px; }
.reader h1 { font-size: 26px; line-height: 1.35; letter-spacing: 0; }
.reader-title-zh {
  margin-top: 8px;
  color: var(--text-1);
  font-size: 18px;
  line-height: 1.55;
  font-weight: 650;
}
.reader-meta { color: var(--text-2); font-size: 12.5px; margin-top: 10px; }
.reader-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 16px; padding-bottom: 20px; border-bottom: 1px solid var(--border);
}
.reader-toolbar .ghost-btn { flex: none; }
#reader-star.starred { color: var(--accent); border-color: var(--accent); }

#reader-audio { margin-top: 18px; }
#reader-audio audio { width: 100%; }

.reader-tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 6px;
  margin: 18px 0;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg-0) 92%, transparent);
  backdrop-filter: blur(12px);
}
.reader-tab {
  flex: 1 1 0;
  min-width: 0;
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 10px;
}
.reader-tab:hover {
  color: var(--text-0);
  background: var(--bg-2);
}
.reader-tab.active {
  color: var(--accent);
  background: var(--accent-soft);
}
.reader-tab-panel { min-width: 0; }

.reader-comments,
.reader-translation,
#reader-rewrite-panel {
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-1);
  padding: 14px 16px 15px;
}
.reader-comments { margin-top: 28px; }
.reader-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}
.reader-section-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}
.reader-section-actions span {
  color: var(--text-2);
  font-weight: 500;
  font-size: 11.5px;
}
.reader-section-actions .ghost-btn {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
  white-space: nowrap;
}
.comments-list { margin-top: 12px; display: grid; gap: 10px; }
.comments-empty { color: var(--text-2); font-size: 13px; }
.comment-item {
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}
.comment-meta {
  color: var(--text-2);
  font-size: 11.5px;
  margin-bottom: 4px;
}
.comment-body {
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.7;
}
.comment-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 12px;
}
.asset-gate {
  margin-top: 12px;
  display: flex;
}
.asset-gate .ghost-btn { flex: none; }
.asset-empty {
  display: grid;
  gap: 10px;
  justify-items: start;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.6;
  margin-top: 12px;
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--bg-2);
}
.comment-form input,
.comment-form textarea {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-0);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  padding: 8px 9px;
  outline: none;
}
.comment-form textarea { resize: vertical; min-height: 38px; }
.comment-form input:focus,
.comment-form textarea:focus { border-color: var(--accent); }
.translation-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}
.translation-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.translation-source,
.translation-target {
  font-size: 14px;
  line-height: 1.75;
}
.translation-source { color: var(--text-2); }
.translation-target { color: var(--text-0); }

.reader-content,
.rewrite-content { font-size: 15.5px; line-height: 1.8; color: var(--text-0); }
.rewrite-content {
  margin-top: 14px;
  font-size: 16px;
  line-height: 1.85;
}
.reader-content p,
.rewrite-content p { margin: 0 0 1em; }
.reader-content h1, .reader-content h2, .reader-content h3, .reader-content h4,
.rewrite-content h1, .rewrite-content h2, .rewrite-content h3, .rewrite-content h4 { margin: 1.4em 0 0.6em; line-height: 1.4; }
.rewrite-content h2 { font-size: 22px; }
.rewrite-content h3 { font-size: 18px; }
.reader-content img,
.rewrite-content img { max-width: 100%; height: auto; border-radius: 10px; margin: 8px 0; }
.reader-content a,
.rewrite-content a { color: var(--accent); text-decoration: none; }
.reader-content a:hover,
.rewrite-content a:hover { text-decoration: underline; }
.reader-content blockquote,
.rewrite-content blockquote {
  border-left: 3px solid var(--accent); padding: 2px 0 2px 16px;
  color: var(--text-1); margin: 1em 0;
}
.reader-content pre,
.rewrite-content pre {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px; overflow-x: auto;
  font-size: 13px; line-height: 1.6;
}
.reader-content code,
.rewrite-content code { background: var(--bg-2); border-radius: 5px; padding: 1px 5px; font-size: 0.9em; }
.reader-content pre code,
.rewrite-content pre code { background: none; padding: 0; }
.reader-content ul, .reader-content ol,
.rewrite-content ul, .rewrite-content ol { padding-left: 1.4em; margin: 0 0 1em; }
.rewrite-content li + li { margin-top: 5px; }
.reader-content table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: 14px; }
.reader-content td, .reader-content th { border: 1px solid var(--border); padding: 6px 10px; }
.reader-content iframe { max-width: 100%; border-radius: 10px; }
.reader-content hr { border: none; border-top: 1px solid var(--border); margin: 1.6em 0; }

/* ============ Agent ============ */
#agent-pane {
  background: var(--bg-1);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.agent-head {
  flex: none;
  min-height: 69px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.agent-kicker {
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
}
.agent-title {
  margin-top: 4px;
  color: var(--text-0);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.agent-profile {
  margin-top: 4px;
  color: var(--text-2);
  font-size: 11.5px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 210px;
}
.agent-head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.settings-note {
  color: var(--text-2);
  font-size: 11.5px;
  line-height: 1.5;
}
.agent-open {
  position: fixed;
  right: 14px;
  bottom: 18px;
  z-index: 30;
  width: 48px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 8px 24px var(--shadow);
}
.agent-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
}
.agent-empty {
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.65;
  padding-top: 30px;
  text-align: center;
}
.agent-msg {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}
.agent-msg-head {
  display: flex;
  align-items: center;
  gap: 6px;
}
.agent-msg-role {
  color: var(--text-2);
  font-size: 11px;
  font-weight: 650;
}
.agent-msg-copy {
  width: 22px;
  height: 22px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  opacity: 0;
}
.agent-msg:hover .agent-msg-copy,
.agent-msg-copy:focus {
  opacity: 1;
}
.agent-msg-copy:hover {
  border-color: var(--border);
  color: var(--text-0);
  background: var(--bg-2);
}
.agent-msg-body {
  color: var(--text-1);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 13px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.agent-msg-body p { margin: 0; }
.agent-msg-body p + p,
.agent-msg-body ul + p,
.agent-msg-body ol + p { margin-top: 8px; }
.agent-msg-body ul,
.agent-msg-body ol {
  margin: 0;
  padding-left: 1.25em;
}
.agent-msg-body li + li { margin-top: 4px; }
.agent-msg-body strong { color: var(--text-0); font-weight: 750; }
.agent-msg-body code {
  background: var(--bg-3);
  border-radius: 5px;
  padding: 1px 4px;
  font-size: 0.92em;
}
.agent-msg.user { align-items: flex-end; }
.agent-msg.user .agent-msg-head { flex-direction: row-reverse; }
.agent-msg.user .agent-msg-body {
  color: var(--text-0);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 38%, var(--border));
}
.agent-msg.pending .agent-msg-body { color: var(--text-2); }
.agent-prompts {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px 0;
  border-top: 1px solid var(--border);
}
.agent-prompt {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-1);
  font-size: 11.5px;
  padding: 4px 8px;
}
.agent-prompt:hover { color: var(--text-0); border-color: var(--text-2); }
.agent-form {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 12px 12px;
}
#agent-input {
  width: 100%;
  resize: none;
  min-height: 38px;
  max-height: 130px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-0);
  border-radius: 8px;
  padding: 8px 9px;
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
  outline: none;
}
#agent-input:focus { border-color: var(--accent); }
#agent-send {
  width: 56px;
  flex: none;
  padding-left: 0;
  padding-right: 0;
}

/* ============ Modal ============ */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: 16px; width: min(560px, 92vw); max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 64px var(--shadow);
}
.modal-box header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-box h2 { font-size: 15px; }
.modal-box header p {
  margin-top: 5px;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.5;
}
.manage-list { min-height: 0; overflow-y: auto; padding: 10px 14px 16px; }
.manage-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 8px; border-radius: 8px; font-size: 13px;
}
.manage-row:hover { background: var(--bg-2); }
.manage-row .m-name { font-weight: 600; }
.manage-row .m-note { font-size: 11.5px; color: var(--text-2); }
.manage-row .m-info { flex: 1; min-width: 0; }
.manage-row .m-status { font-size: 11px; color: var(--text-2); flex: none; }
.m-status.ok { color: #46a758; }
.m-status.error { color: #e5484d; }
.switch {
  position: relative; width: 34px; height: 20px; flex: none;
  background: var(--bg-3); border-radius: 999px; border: none;
  transition: background 0.15s;
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform 0.15s;
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(14px); }

/* ============ AI Config ============ */
.ai-config-box {
  width: min(980px, 94vw);
  max-height: min(86vh, 760px);
}
.ai-config-content {
  display: grid;
  grid-template-columns: minmax(200px, 260px) minmax(0, 1fr);
  min-height: 0;
}
.ai-profile-side {
  min-height: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
}
.ai-side-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
}
.ai-side-head .ghost-btn {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}
.ai-profile-list {
  min-height: 0;
  overflow-y: auto;
  padding: 0 10px 12px;
}
.ai-profile-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-1);
  display: grid;
  gap: 4px;
  padding: 9px 10px;
  text-align: left;
}
.ai-profile-item:hover {
  background: var(--bg-1);
  border-color: var(--border);
}
.ai-profile-item.active {
  background: var(--bg-1);
  border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
}
.ai-profile-name {
  color: var(--text-0);
  font-size: 13px;
  font-weight: 700;
}
.ai-profile-meta,
.ai-profile-key {
  color: var(--text-2);
  font-size: 11.5px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-profile-form {
  min-height: 0;
  overflow-y: auto;
  display: grid;
  gap: 14px;
  padding: 14px 18px 18px;
}
.ai-config-alert {
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--border));
  background: var(--accent-soft);
  color: var(--text-0);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 12.5px;
  line-height: 1.5;
}
.ai-form-section {
  display: grid;
  gap: 10px;
}
.ai-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
}
.ai-key-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 650;
}
.ai-key-link:hover { text-decoration: underline; }
.ai-template-list {
  display: grid;
  gap: 10px;
  max-height: 170px;
  overflow-y: auto;
  padding-right: 2px;
}
.ai-template-group {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
}
.ai-template-category {
  color: var(--text-2);
  font-size: 11.5px;
  line-height: 28px;
}
.ai-template-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ai-template-group .ai-template {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-2);
  color: var(--text-1);
  font-size: 12px;
}
.ai-template:hover {
  border-color: var(--text-2);
  color: var(--text-0);
}
.ai-form-grid {
  display: grid;
  gap: 10px;
}
.ai-form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ai-form-grid.three { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; }
.ai-profile-form label {
  display: grid;
  gap: 5px;
}
.ai-profile-form label span {
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 650;
}
.ai-profile-form input {
  width: 100%;
  min-height: 36px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-0);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
}
.ai-profile-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.ai-default-check {
  min-height: 36px;
  display: flex !important;
  grid-auto-flow: column;
  align-items: center;
  justify-content: start;
  gap: 8px !important;
  padding-bottom: 1px;
}
.ai-default-check input {
  width: 16px;
  min-height: 16px;
}
.ai-default-check span {
  color: var(--text-1) !important;
  font-size: 12.5px !important;
}
.ai-quick-models {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ai-model-chip {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-2);
  color: var(--text-1);
  font-size: 11.5px;
  line-height: 1.25;
  padding: 5px 8px;
  overflow-wrap: anywhere;
}
.ai-model-chip:hover {
  color: var(--text-0);
  border-color: var(--text-2);
}
.ai-form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 2px;
}
.ghost-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.ghost-btn.danger {
  color: #d33;
}

/* ============ Auth ============ */
.auth-box {
  width: min(420px, 92vw);
}
.auth-form {
  display: grid;
  gap: 10px;
  padding: 16px 20px 20px;
}
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 3px;
  border-radius: 8px;
  background: var(--bg-2);
}
.auth-tab {
  height: 32px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 650;
}
.auth-tab.active {
  background: var(--bg-1);
  color: var(--accent);
  box-shadow: 0 1px 4px var(--shadow);
}
.auth-form input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-0);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  padding: 9px 10px;
  outline: none;
}
.auth-form input:focus { border-color: var(--accent); }
.auth-form .ghost-btn {
  min-height: 38px;
  flex: none;
}

/* ============ Toast ============ */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--bg-3); color: var(--text-0);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 18px; font-size: 13px; z-index: 99;
  box-shadow: 0 8px 24px var(--shadow);
}

/* ============ Scrollbars ============ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* ============ Responsive ============ */
@media (max-width: 1100px) {
  #app { grid-template-columns: 188px minmax(238px, 280px) minmax(320px, 1fr) 230px; }
}
@media (max-width: 1380px) and (min-width: 1101px) {
  #app { grid-template-columns: 232px minmax(288px, 340px) minmax(360px, 1fr) 280px; }
}
@media (max-width: 980px) {
  #app { grid-template-columns: 64px minmax(240px, 1fr) 0; }
  #agent-pane { display: none; }
}
@media (max-width: 860px) {
  #app { grid-template-columns: 64px minmax(240px, 1fr) 0; }
  #reader-pane { display: none; }
  #app.reading { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(260px, 38vh); }
  #app.reading #sidebar, #app.reading #entry-pane { display: none; }
  #app.reading #reader-pane { display: block; grid-column: 1 / -1; }
  #app.reading #agent-pane {
    display: flex;
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--border);
  }
  #app.reading .agent-head { min-height: auto; padding: 10px 14px; }
  #app.reading .agent-prompts {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  #app.reading .agent-prompt { white-space: nowrap; }
  .reader { max-width: none; padding: 26px 20px 64px; }
  .reader h1 { font-size: 22px; }
  .reader-title-zh { font-size: 16px; }
  .reader-section-head { align-items: flex-start; flex-direction: column; gap: 4px; }
  .reader-section-actions { justify-content: space-between; width: 100%; }
  .translation-pair { grid-template-columns: 1fr; }
  .comment-form { grid-template-columns: 1fr; }
  .sidebar-footer {
    display: flex;
    flex-direction: column;
    padding: 8px 10px 10px;
  }
  .account-strip {
    flex-direction: column;
    padding: 8px 10px;
  }
  .sidebar-footer .ghost-btn {
    width: 44px;
    height: 36px;
    padding: 0;
    font-size: 0;
    flex: none;
  }
  .account-strip .ghost-btn {
    width: 44px;
    height: 36px;
    padding: 0;
    font-size: 0;
    flex: none;
  }
  .account-info { display: none; }
  #auth-open::before { content: '⎋'; font-size: 15px; }
  #refresh-btn::before { content: '↻'; font-size: 15px; }
  #manage-btn::before { content: '⚙'; font-size: 15px; }
  .asset-dashboard { display: none; }
  .brand-name, .feed-item .fname, .feed-item .fcount, .view-btn span:not(.view-ico), .count, .group-label { display: none; }
}
@media (max-width: 720px) {
  .ai-config-box {
    width: 94vw;
    max-height: 88vh;
  }
  .ai-config-content {
    grid-template-columns: 1fr;
  }
  .ai-profile-side {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    max-height: 190px;
  }
  .ai-form-grid.two,
  .ai-form-grid.three {
    grid-template-columns: 1fr;
  }
  .ai-template-group {
    grid-template-columns: 1fr;
  }
  .ai-form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .ai-form-actions .ghost-btn {
    width: 100%;
  }
}
