/* =========================================================
   Kirinya Hub · Studio-Grade Modular Personal Workbench CSS
   Light & Dark Dual Theme · Desktop (Mac) + Mobile (Android)
   ========================================================= */

:root {
  --bg: #F5F6F8;
  --bg-elevated: #FFFFFF;
  --bg-subtle: #EEF1F6;
  --bg-glass: rgba(255, 255, 255, 0.82);
  --bg-code: #0F172A;
  --text: #0F172A;
  --text-secondary: #475569;
  --text-muted: #64748B;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.15);

  --accent: #3B5BDB;
  --accent-hover: #364FC7;
  --accent-soft: rgba(59, 91, 219, 0.10);
  --accent-glow: rgba(59, 91, 219, 0.22);

  --emerald: #059669;
  --emerald-soft: rgba(5, 150, 105, 0.10);
  --crimson: #DC2626;
  --crimson-soft: rgba(220, 38, 38, 0.10);
  --amber: #D97706;
  --amber-soft: rgba(217, 119, 6, 0.12);
  --sky: #0284C7;
  --sky-soft: rgba(2, 132, 199, 0.11);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.12);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 999px;

  --sidebar-w: 248px;
  --topbar-h: 58px;
  --tabbar-h: 64px;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

[data-theme="dark"] {
  --bg: #0B0F17;
  --bg-elevated: #121826;
  --bg-subtle: #1A2234;
  --bg-glass: rgba(18, 24, 38, 0.82);
  --bg-code: #080B12;
  --text: #F1F5F9;
  --text-secondary: #CBD5E1;
  --text-muted: #8B9BB4;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  --accent: #6382FF;
  --accent-hover: #7B96FF;
  --accent-soft: rgba(99, 130, 255, 0.15);
  --accent-glow: rgba(99, 130, 255, 0.30);

  --emerald: #34D399;
  --emerald-soft: rgba(52, 211, 153, 0.13);
  --crimson: #F87171;
  --crimson-soft: rgba(248, 113, 113, 0.14);
  --amber: #FBBF24;
  --amber-soft: rgba(251, 191, 36, 0.14);
  --sky: #38BDF8;
  --sky-soft: rgba(56, 189, 248, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }

/* ---------- Boot Splash ---------- */
.boot-splash {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.boot-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
}
.boot-text {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
  color: var(--text-secondary);
}

/* ---------- Login Screen ---------- */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 70% 50% at 20% 10%, var(--accent-soft), transparent 60%),
    radial-gradient(ellipse 60% 50% at 85% 85%, var(--sky-soft), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 390px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 36px 30px 30px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.auth-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  margin: 0 auto 16px;
  display: block;
  box-shadow: 0 10px 26px var(--accent-glow);
}
.auth-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.auth-sub {
  margin: 0 0 26px;
  font-size: 13.5px;
  color: var(--text-muted);
}
.auth-input-wrap {
  position: relative;
  margin-bottom: 14px;
}
.auth-input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  font-size: 15px;
  background: var(--bg-subtle);
  border: 1.5px solid transparent;
  border-radius: 12px;
  outline: none;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.auth-input:focus {
  background: var(--bg-elevated);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.auth-error {
  color: var(--crimson);
  font-size: 13px;
  min-height: 20px;
  margin-bottom: 10px;
}

/* ---------- Buttons & Pills ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.18s var(--ease);
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--border-strong); background: var(--bg-elevated); }

.btn-ghost {
  color: var(--text-secondary);
  height: 34px;
  padding: 0 10px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
}
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text); }

.btn-danger-ghost { color: var(--crimson); }
.btn-danger-ghost:hover { background: var(--crimson-soft); color: var(--crimson); }

.btn-block { width: 100%; height: 46px; font-size: 15px; border-radius: 12px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--bg-subtle); color: var(--text); }

/* ---------- Main App Shell ---------- */
.shell {
  display: flex;
  min-height: 100dvh;
}

/* Desktop Sidebar */
.sidebar {
  width: var(--sidebar-w);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 16px;
  z-index: 40;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 18px;
}
.brand img {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  box-shadow: 0 4px 12px var(--accent-glow);
}
.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.brand-tag {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 12px 10px 6px;
}
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s var(--ease);
  margin-bottom: 3px;
  text-align: left;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { background: var(--bg-subtle); color: var(--text); text-decoration: none; }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-muted);
}
.nav-item.active .nav-badge {
  background: var(--accent);
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sse-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 9px;
  background: var(--bg-subtle);
}
.sse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}
.sse-dot.live {
  background: var(--emerald);
  box-shadow: 0 0 0 3px var(--emerald-soft);
  animation: pulse 2.2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
.sidebar-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

/* Mobile Topbar & Bottom Tab Bar */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 14px 0;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  z-index: 45;
}
.mobile-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
}
.mobile-brand img { width: 28px; height: 28px; border-radius: 8px; }
.mobile-top-actions { display: flex; align-items: center; gap: 4px; }

.mobile-tabbar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 6px 10px env(safe-area-inset-bottom);
  background: var(--bg-glass);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-top: 1px solid var(--border);
  z-index: 45;
  justify-content: space-around;
  align-items: center;
}
.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 50px;
  border-radius: 14px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  transition: color 0.15s;
}
.tab-btn svg { width: 22px; height: 22px; }
.tab-btn.active { color: var(--accent); }
.tab-btn.active .tab-icon-wrap {
  background: var(--accent-soft);
  padding: 3px 16px;
  border-radius: var(--radius-full);
}
.tab-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px 16px;
  border-radius: var(--radius-full);
  transition: background 0.18s var(--ease);
}

/* Main Stage */
.main-stage {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 28px 32px 60px;
  min-width: 0;
}
.container {
  max-width: 920px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-title {
  margin: 0;
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -0.025em;
  line-height: 1.2;
}
.page-sub {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

/* ---------- Cards & Surfaces ---------- */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* ---------- Cross-Device Sync Module ---------- */
.composer {
  padding: 16px 18px;
  margin-bottom: 18px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.composer.dragover {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.composer-textarea {
  width: 100%;
  min-height: 76px;
  max-height: 280px;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
}
.composer-textarea::placeholder { color: var(--text-muted); }

.pending-file-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 10px;
  padding: 8px 12px;
  border-radius: 11px;
  background: var(--bg-subtle);
  font-size: 13px;
}
.pending-file-thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
}
.pending-file-meta { flex: 1; min-width: 0; }
.pending-file-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pending-file-size { font-size: 11.5px; color: var(--text-muted); }

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.composer-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.tag-quick-pill {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition: all 0.15s;
}
.tag-quick-pill:hover { border-color: var(--border-strong); color: var(--text); }
.tag-quick-pill.selected {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-box {
  position: relative;
  flex: 1;
  min-width: 190px;
}
.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 36px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 11px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.filter-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.filter-strip::-webkit-scrollbar { display: none; }
.chip {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active {
  background: var(--text);
  color: var(--bg-elevated);
  border-color: var(--text);
}

/* Sync Timeline Cards */
.sync-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sync-card {
  padding: 15px 18px;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
  animation: fadeUp 0.22s var(--ease);
}
.sync-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
.sync-card.pinned {
  border-left: 3.5px solid var(--accent);
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.sync-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.sync-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge-mac { background: var(--accent-soft); color: var(--accent); }
.badge-android { background: var(--emerald-soft); color: var(--emerald); }
.badge-ios { background: var(--sky-soft); color: var(--sky); }
.badge-web { background: var(--bg-subtle); color: var(--text-secondary); }
.badge-pin { background: var(--amber-soft); color: var(--amber); }
.badge-tag { background: var(--bg-subtle); color: var(--text-secondary); border-radius: var(--radius-full); }

.sync-title {
  font-weight: 700;
  font-size: 15.5px;
  margin: 0 0 6px;
}
.sync-body {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.sync-code {
  margin: 6px 0 2px;
  padding: 12px 14px;
  border-radius: 11px;
  background: var(--bg-code);
  color: #E2E8F0;
  font-family: var(--font-mono);
  font-size: 12.8px;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
}
.sync-link-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  margin: 4px 0;
  transition: border-color 0.15s;
}
.sync-link-card:hover { border-color: var(--accent); text-decoration: none; }
.sync-link-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sync-link-info { min-width: 0; flex: 1; }
.sync-link-host { font-size: 12px; font-weight: 700; color: var(--accent); }
.sync-link-url {
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-img-wrap {
  margin-top: 8px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  max-width: 440px;
  cursor: zoom-in;
  background: var(--bg-subtle);
}
.sync-img-wrap img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
}
.sync-file-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  max-width: 100%;
}
.sync-file-pill:hover { border-color: var(--accent); text-decoration: none; }

.sync-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ---------- Academic Digest Module ---------- */
.date-rail {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 10px;
  margin-bottom: 14px;
  scrollbar-width: none;
}
.date-rail::-webkit-scrollbar { display: none; }
.date-chip {
  flex-shrink: 0;
  padding: 9px 14px;
  border-radius: 13px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 96px;
  transition: all 0.16s var(--ease);
}
.date-chip:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.date-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 6px 18px var(--accent-glow);
}
.date-chip-day { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.date-chip-sub { font-size: 11px; opacity: 0.78; margin-top: 2px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.kpi-card {
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.kpi-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-top: 4px;
  line-height: 1.1;
}
.kpi-value.blue { color: var(--accent); }
.kpi-value.red { color: var(--crimson); }
.kpi-value.muted { color: var(--text-muted); }

.overview-banner {
  padding: 16px 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent-soft), var(--sky-soft));
  border: 1px solid var(--border);
  margin-bottom: 18px;
}
.overview-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.overview-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}

.section-heading {
  font-size: 16px;
  font-weight: 750;
  margin: 22px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
}
.paper-card {
  padding: 18px 20px;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.paper-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.paper-card.core { border-left: 4px solid var(--crimson); }
.paper-card.strong { border-left: 4px solid var(--accent); }

.paper-badges {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.badge-core { background: var(--crimson); color: #fff; }
.badge-strong { background: var(--accent); color: #fff; }
.badge-journal { background: var(--bg-subtle); color: var(--text); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-abs-ok { background: var(--emerald-soft); color: var(--emerald); }
.badge-abs-title { background: var(--amber-soft); color: var(--amber); }

.paper-zh {
  font-size: 16.5px;
  font-weight: 750;
  line-height: 1.4;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.paper-en {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  margin: 0 0 12px;
  line-height: 1.45;
}
.paper-field {
  font-size: 13.8px;
  line-height: 1.65;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.paper-field b { color: var(--text); }
.paper-insight {
  padding: 10px 13px;
  border-radius: 11px;
  background: var(--emerald-soft);
  color: var(--text);
  font-size: 13.6px;
  line-height: 1.65;
  margin: 10px 0 12px;
  border-left: 3px solid var(--emerald);
}
.paper-insight b { color: var(--emerald); }
.paper-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.paper-links {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 600;
}

.journal-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.jbar-row {
  display: grid;
  grid-template-columns: 1fr 120px 44px;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
}
.jbar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); }
.jbar-track { height: 7px; border-radius: 99px; background: var(--bg-subtle); overflow: hidden; }
.jbar-fill { height: 100%; border-radius: 99px; background: var(--accent); }
.jbar-num { text-align: right; font-weight: 600; color: var(--text-muted); }

/* ---------- Module Center & Settings ---------- */
.module-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.module-card {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.18s var(--ease), border-color 0.18s;
}
.module-card.clickable { cursor: pointer; }
.module-card.clickable:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.module-card.planned { opacity: 0.72; }
.module-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.module-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.module-name { font-size: 16px; font-weight: 700; margin: 0; }
.module-desc { font-size: 13px; color: var(--text-muted); margin: 0; line-height: 1.55; }

.settings-card { padding: 20px 22px; margin-bottom: 16px; }
.settings-title { font-size: 16px; font-weight: 700; margin: 0 0 6px; }
.settings-desc { font-size: 13px; color: var(--text-muted); margin: 0 0 14px; line-height: 1.55; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.field-input {
  height: 40px;
  padding: 0 13px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 14px;
  outline: none;
  flex: 1;
  min-width: 180px;
}
.field-input:focus { border-color: var(--accent); background: var(--bg-elevated); }
.token-box {
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  word-break: break-all;
  flex: 1;
}

/* ---------- Empty State, Toast, Modal ---------- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state h3 { margin: 8px 0 4px; color: var(--text); font-size: 16px; }

.toast-root {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: #0F172A;
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-full);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.22s var(--ease);
}
[data-theme="dark"] .toast { background: #F1F5F9; color: #0F172A; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.modal-box {
  width: 100%;
  max-width: 820px;
  max-height: 88dvh;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
}
.modal-body { overflow: auto; flex: 1; padding: 16px; }
.lightbox-img {
  max-width: 94vw;
  max-height: 88dvh;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}

/* ---------- Mobile Responsive (Android & Narrow Viewports) ---------- */
@media (max-width: 860px) {
  .sidebar { display: none; }
  .mobile-topbar { display: flex; }
  .mobile-tabbar { display: flex; }
  .main-stage {
    margin-left: 0;
    padding: calc(var(--topbar-h) + env(safe-area-inset-top) + 14px) 14px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 22px);
  }
  .page-header { margin-bottom: 14px; }
  .page-title { font-size: 20px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .module-grid { grid-template-columns: 1fr; }
  .paper-card { padding: 15px; }
  .sync-card { padding: 14px; }
  .jbar-row { grid-template-columns: 1fr 78px 40px; }
  .toast-root { top: calc(var(--topbar-h) + env(safe-area-inset-top) + 10px); }
}
