:root {
  --bg: #0b1120;
  --bg-soft: #0f172a;
  --panel: #131c31;
  --panel-2: #1a2540;
  --border: #26324f;
  --text: #e7ecf6;
  --muted: #94a3b8;
  --primary: #6366f1;
  --primary-hi: #818cf8;
  --accent: #22d3ee;
  --concept: #38bdf8;
  --example: #34d399;
  --counter: #fb7185;
  --apply: #fbbf24;
  --question: #c084fc;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 80% -10%, #1e293b 0%, var(--bg) 55%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 17, 32, 0.75);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 30px; line-height: 1; }
.brand-text h1 { margin: 0; font-size: 19px; letter-spacing: 0.2px; }
.brand-text p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

.topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Buttons */
.btn {
  font: inherit;
  font-size: 13.5px;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 9px 16px;
  cursor: pointer;
  color: var(--text);
  background: var(--panel-2);
  transition: transform 0.06s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: var(--primary-hi); }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: transparent; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-mini { padding: 4px 10px; font-size: 12px; }

/* Workspace */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.25fr);
  gap: 20px;
  padding: 20px 24px 8px;
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
  align-items: start;
}

.pane {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 60vh;
}
.pane-input { position: sticky; top: 88px; }

.pane-head { margin-bottom: 12px; }
.pane-head h2 { margin: 0 0 4px; font-size: 15px; }
.hint { font-size: 12px; color: var(--muted); }
.hint code {
  background: var(--panel-2);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 11.5px;
}

textarea {
  flex: 1;
  min-height: 320px;
  width: 100%;
  resize: vertical;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  font: inherit;
  font-size: 14px;
  line-height: 1.7;
}
textarea:focus { outline: none; border-color: var(--primary-hi); }
textarea::placeholder { color: #56617d; }

.input-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}
.counters { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.privacy { margin: 12px 0 0; font-size: 11.5px; color: var(--muted); }

/* Tag bar */
.tagbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--border);
}
.tag-cloud-chip {
  font-size: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 4px 11px;
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
}
.tag-cloud-chip:hover { border-color: var(--accent); color: var(--accent); }
.tag-cloud-chip .count { color: var(--muted); margin-left: 4px; }

/* Cards */
.cards { display: flex; flex-direction: column; gap: 16px; }

.card {
  background: linear-gradient(180deg, var(--panel-2) 0%, #16203a 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 16px 14px;
  animation: rise 0.28s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-title { margin: 0; font-size: 16px; line-height: 1.4; }

.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.chip {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(129, 140, 248, 0.35);
  color: var(--primary-hi);
}

.card-sections { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.section {
  border-left: 3px solid var(--border);
  padding: 2px 0 2px 12px;
}
.section-label {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
  text-transform: uppercase;
}
.section p { margin: 0; font-size: 13.5px; color: #d7deee; }
.section ul { margin: 0; padding-left: 18px; font-size: 13.5px; color: #d7deee; }
.section li { margin: 2px 0; }

.section.concept { border-left-color: var(--concept); }
.section.concept .section-label { color: var(--concept); }
.section.example { border-left-color: var(--example); }
.section.example .section-label { color: var(--example); }
.section.counter { border-left-color: var(--counter); }
.section.counter .section-label { color: var(--counter); }
.section.apply { border-left-color: var(--apply); }
.section.apply .section-label { color: var(--apply); }
.section.question { border-left-color: var(--question); }
.section.question .section-label { color: var(--question); }

.card-links, .card-review { margin-top: 14px; }
.card-links h4, .card-review h4 {
  margin: 0 0 7px; font-size: 12px; color: var(--muted); font-weight: 600;
}
.link-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.link-chip {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 8px;
  background: rgba(34, 211, 238, 0.1);
  border: 1px solid rgba(34, 211, 238, 0.3);
  color: var(--accent);
  cursor: pointer;
}
.link-chip:hover { background: rgba(34, 211, 238, 0.2); }
.link-chip .shared { color: var(--muted); font-size: 10.5px; margin-left: 3px; }

.review-list { margin: 0; padding-left: 20px; }
.review-list li { font-size: 13px; color: #d7deee; margin: 3px 0; }

.card.flash { box-shadow: 0 0 0 2px var(--accent); }

/* Empty state */
.empty {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 34px 22px;
  text-align: center;
  color: var(--muted);
}
.empty-icon { font-size: 40px; margin-bottom: 6px; }
.empty p { margin: 0 0 14px; font-size: 14px; }
.empty-list {
  text-align: left;
  max-width: 380px;
  margin: 0 auto;
  font-size: 13px;
  padding-left: 18px;
}
.empty-list li { margin: 6px 0; }
.empty-list b { color: var(--text); }

/* Footer */
.sitefoot {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 20px 24px 26px;
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.sitefoot .dot { opacity: 0.5; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  background: #0b1120;
  border: 1px solid var(--primary-hi);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Responsive */
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .pane { min-height: unset; }
  .pane-input { position: static; }
  textarea { min-height: 220px; }
}
@media (max-width: 560px) {
  .topbar { padding: 12px 14px; }
  .workspace { padding: 14px; }
  .brand-text p { display: none; }
  .btn { padding: 8px 12px; }
  .input-foot { flex-direction: column; align-items: stretch; }
  .btn-lg { width: 100%; }
}
