:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-strong: #f1f4f8;
  --ink: #19202a;
  --muted: #697386;
  --line: #d9e0ea;
  --teal: #118a8a;
  --coral: #d85f4a;
  --leaf: #4f8a3d;
  --gold: #b58316;
  --violet: #7254a4;
  --blue: #3f6fb3;
  --shadow: 0 18px 48px rgba(39, 48, 67, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 16% 12%, rgba(17, 138, 138, 0.12), transparent 28%),
    radial-gradient(circle at 86% 18%, rgba(216, 95, 74, 0.1), transparent 24%),
    linear-gradient(135deg, #f9fafc 0%, var(--bg) 62%, #eef4f3 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
  min-height: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 76px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(217, 224, 234, 0.78);
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #ffffff 0 12%, transparent 13%),
    conic-gradient(from 20deg, var(--teal), var(--gold), var(--coral), var(--violet), var(--teal));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.75), 0 10px 24px rgba(63, 111, 179, 0.24);
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 760;
  line-height: 1.1;
}

.brand p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.searchbox {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(320px, 26vw);
  min-width: 210px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
}

.searchbox svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.searchbox input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(78px, auto));
  gap: 2px;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
}

.segmented-button,
.icon-button,
.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  border-radius: 6px;
  color: var(--ink);
  white-space: nowrap;
}

.segmented-button {
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.segmented-button svg,
.primary-button svg,
.secondary-button svg {
  width: 16px;
  height: 16px;
}

.segmented-button.is-active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(31, 41, 55, 0.08);
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 420px);
  min-height: 0;
}

.map-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.stage-head {
  position: absolute;
  top: 14px;
  left: 16px;
  right: 16px;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.metric-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.metric-group span,
.hint-line {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(217, 224, 234, 0.82);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--muted);
  font-size: 12px;
  box-shadow: 0 8px 24px rgba(39, 48, 67, 0.08);
}

.metric-group strong {
  color: var(--ink);
}

.graph-view {
  display: block;
  width: 100%;
  height: 100%;
}

.word-cloud,
.note-list {
  position: absolute;
  inset: 64px 24px 24px;
  overflow: auto;
}

.word-cloud {
  display: flex;
  align-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 24px;
}

.word-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 10px 30px rgba(39, 48, 67, 0.08);
  color: var(--chip-color, var(--teal));
  transition: transform 140ms ease, border-color 140ms ease;
}

.word-chip:hover,
.word-chip:focus-visible {
  border-color: currentColor;
  transform: translateY(-2px);
  outline: none;
}

.note-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  align-content: start;
  gap: 12px;
  padding: 6px;
}

.note-card {
  display: grid;
  gap: 10px;
  min-height: 180px;
  padding: 16px;
  border: 1px solid rgba(217, 224, 234, 0.9);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 12px 34px rgba(39, 48, 67, 0.08);
  text-align: left;
}

.note-card h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
}

.note-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.card-tags,
.concept-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(17, 138, 138, 0.1);
  color: #0b6f72;
  font-size: 12px;
}

.detail-panel {
  min-height: 0;
  overflow: hidden;
  border-left: 1px solid rgba(217, 224, 234, 0.84);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(16px);
}

.detail-placeholder,
.detail-content {
  height: 100%;
  overflow: auto;
}

.detail-placeholder {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.detail-placeholder svg {
  width: 44px;
  height: 44px;
  color: var(--teal);
}

.detail-placeholder h2 {
  margin: 0;
  color: var(--ink);
  font-size: 19px;
}

.detail-placeholder p {
  margin: 0;
  max-width: 280px;
  line-height: 1.7;
}

.detail-content {
  padding: 24px;
}

.detail-eyebrow {
  color: var(--coral);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-content h2 {
  margin: 8px 0 8px;
  font-size: 25px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.detailMeta {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.related-block {
  margin: 20px 0;
}

.related-block h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.related-list {
  display: grid;
  gap: 8px;
}

.related-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  text-align: left;
}

.related-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.reader {
  color: #202938;
  font-size: 15px;
  line-height: 1.82;
  overflow-wrap: anywhere;
}

.reader h1,
.reader h2,
.reader h3 {
  line-height: 1.3;
}

.reader img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

.reader table {
  width: 100%;
  border-collapse: collapse;
}

.reader td,
.reader th {
  border: 1px solid var(--line);
  padding: 6px 8px;
}

.concept-analysis {
  display: grid;
  gap: 14px;
}

.analysis-summary,
.meaning-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.analysis-summary strong,
.meaning-card strong {
  color: var(--ink);
}

.analysis-summary p,
.meaning-card p {
  margin: 8px 0 0;
}

.context-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.mini-tag {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(63, 111, 179, 0.1);
  color: #315b95;
  font-size: 12px;
  line-height: 1.3;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.analysis-grid div {
  display: grid;
  gap: 2px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
}

.analysis-grid span {
  color: var(--muted);
  font-size: 12px;
}

.analysis-grid strong {
  color: var(--ink);
  font-size: 20px;
  line-height: 1.15;
}

.concept-analysis h3 {
  margin: 4px 0 0;
  font-size: 15px;
}

.meaning-card {
  display: grid;
  gap: 10px;
}

.meaning-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.meaning-card header span {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(216, 95, 74, 0.1);
  color: #a74636;
  font-size: 12px;
}

.text-link {
  padding: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 760;
  line-height: 1.4;
  text-align: left;
}

.text-link:hover,
.text-link:focus-visible {
  text-decoration: underline;
  outline: none;
}

.meaning-card details {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.evidence-quote {
  margin: 2px 0;
  padding: 10px 12px;
  border-left: 3px solid var(--gold);
  border-radius: 0 6px 6px 0;
  background: rgba(181, 131, 22, 0.08);
  color: #384152;
  font-size: 13px;
  line-height: 1.65;
}

.evidence-quote mark {
  border-radius: 4px;
  padding: 0 3px;
  background: rgba(181, 131, 22, 0.22);
  color: #634609;
}

.meaning-card summary {
  color: var(--blue);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.occurrence-list {
  display: grid;
  gap: 10px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.occurrence-list li {
  padding: 10px;
  border-radius: 6px;
  background: #f8fafc;
}

.occurrence-list li > span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.occurrence-list p {
  margin: 5px 0 0;
  line-height: 1.65;
}

.occurrence-list mark {
  border-radius: 4px;
  padding: 0 3px;
  background: rgba(181, 131, 22, 0.22);
  color: #634609;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}

.empty-state svg {
  width: 42px;
  height: 42px;
  color: var(--coral);
}

.empty-state h2 {
  margin: 0;
  color: var(--ink);
}

.empty-state p {
  margin: 0;
}

.hidden {
  display: none !important;
}

.import-dialog {
  width: min(720px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 28px));
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.import-dialog::backdrop {
  background: rgba(25, 32, 42, 0.42);
  backdrop-filter: blur(4px);
}

.dialog-shell {
  display: grid;
  gap: 16px;
  padding: 18px;
  background: var(--panel);
}

.dialog-shell header,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-shell h2 {
  margin: 0;
  font-size: 19px;
}

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 150px;
  padding: 20px;
  border: 1px dashed #9ba8b8;
  border-radius: var(--radius);
  background: #f8fafc;
  color: var(--muted);
  text-align: center;
}

.dropzone svg {
  width: 32px;
  height: 32px;
  color: var(--teal);
}

.dropzone strong {
  color: var(--ink);
}

.dropzone input {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  cursor: pointer;
}

.paste-area {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.paste-area textarea {
  min-height: 190px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  color: var(--ink);
  line-height: 1.55;
}

.primary-button,
.secondary-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
}

.primary-button {
  background: var(--ink);
  color: #fff;
}

.secondary-button {
  border-color: var(--line);
  background: #fff;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app-shell {
    min-height: 100%;
    height: auto;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .searchbox {
    width: 100%;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(560px, 68vh) minmax(360px, auto);
  }

  .detail-panel {
    border-top: 1px solid rgba(217, 224, 234, 0.84);
    border-left: 0;
  }
}

@media (max-width: 620px) {
  .topbar {
    padding: 12px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .segmented {
    width: 100%;
    grid-template-columns: repeat(3, 1fr);
  }

  .segmented-button {
    padding: 0 6px;
  }

  .hint-line {
    display: none;
  }

  .word-cloud,
  .note-list {
    inset: 56px 12px 12px;
  }

  .detail-content {
    padding: 18px;
  }
}
