:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --paper: #fffdf8;
  --ink: #1f2526;
  --muted: #687170;
  --line: #ded8cd;
  --line-strong: #c8c0b3;
  --accent: #1f6f68;
  --accent-soft: #d9efeb;
  --blue: #284f88;
  --rose: #9a4051;
  --gold: #8a681b;
  --green: #3b7651;
  --shadow: 0 18px 45px rgba(54, 48, 38, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0) 260px),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 22px;
}

.topbar {
  align-items: end;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin: 0 auto 18px;
  max-width: 1480px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  font-weight: 850;
  line-height: 1.16;
}

.top-actions,
.toolbar,
.segmented,
.input-footer,
.pane-head,
.summary-strip {
  align-items: center;
  display: flex;
}

.top-actions {
  gap: 8px;
}

.icon-button,
.text-button,
.segment {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}

.icon-button {
  border-radius: 8px;
  font-size: 22px;
  height: 40px;
  line-height: 1;
  width: 40px;
}

.icon-button:hover,
.text-button:hover,
.segment:hover {
  border-color: var(--accent);
}

.workspace {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(320px, 0.74fr) minmax(520px, 1.26fr);
  margin: 0 auto;
  max-width: 1480px;
}

.input-pane,
.reader-pane {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: calc(100vh - 118px);
}

.input-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pane-head {
  border-bottom: 1px solid var(--line);
  justify-content: space-between;
  padding: 16px;
}

.pane-head h2 {
  font-size: 17px;
  line-height: 1.2;
}

.pane-head p,
.input-footer,
.outline-title,
.summary-strip span,
.field-meta,
.type-badge,
.path-chip {
  color: var(--muted);
  font-size: 12px;
}

.text-button {
  border-radius: 8px;
  font-size: 13px;
  font-weight: 750;
  padding: 8px 12px;
}

textarea {
  background: #151918;
  border: 0;
  color: #ecf5ef;
  flex: 1;
  line-height: 1.55;
  min-height: 460px;
  outline: 0;
  padding: 18px;
  resize: none;
  tab-size: 2;
  white-space: pre;
}

textarea::placeholder {
  color: #8d9994;
  white-space: normal;
}

.input-footer {
  border-top: 1px solid var(--line);
  gap: 12px;
  justify-content: space-between;
  min-height: 44px;
  padding: 10px 16px;
}

#errorText {
  color: #a13d3a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.toolbar {
  border-bottom: 1px solid var(--line);
  gap: 12px;
  justify-content: space-between;
  padding: 14px;
}

.search-wrap {
  align-items: center;
  background: #f3f0e8;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex: 1;
  gap: 8px;
  min-width: 160px;
  padding: 0 11px;
}

.search-wrap span {
  color: var(--muted);
  font-size: 18px;
}

.search-wrap input {
  background: transparent;
  border: 0;
  color: var(--ink);
  height: 38px;
  min-width: 0;
  outline: 0;
  width: 100%;
}

.segmented {
  background: #eee9df;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
}

.segment {
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 750;
  min-width: 58px;
  padding: 7px 10px;
}

.segment.active {
  background: var(--paper);
  box-shadow: 0 1px 7px rgba(48, 42, 32, 0.12);
  color: var(--accent);
}

.summary-strip {
  border-bottom: 1px solid var(--line);
  gap: 8px;
  padding: 12px 14px;
}

.summary-strip div {
  background: #f5f1e8;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 96px;
  padding: 8px 10px;
}

.summary-strip strong {
  display: block;
  font-size: 18px;
  line-height: 1.05;
}

.reader-layout {
  display: grid;
  flex: 1;
  grid-template-columns: 210px minmax(0, 1fr);
  min-height: 0;
}

.outline {
  border-right: 1px solid var(--line);
  min-height: 0;
  overflow: auto;
  padding: 14px;
}

.outline-title {
  font-weight: 800;
  margin-bottom: 10px;
}

.outline a {
  border-radius: 6px;
  color: var(--ink);
  display: block;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  padding: 7px 8px;
  text-decoration: none;
}

.outline a:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.preview-area {
  min-height: 0;
  overflow: auto;
  padding: 22px;
  position: relative;
}

.empty-state {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
  min-height: 380px;
  text-align: center;
}

.empty-state h2 {
  color: var(--ink);
  font-size: 22px;
}

.empty-state p {
  line-height: 1.6;
  max-width: 460px;
}

.empty-mark {
  align-items: center;
  background: var(--accent-soft);
  border: 1px solid #b7dbd4;
  border-radius: 8px;
  color: var(--accent);
  display: flex;
  font-weight: 900;
  height: 58px;
  justify-content: center;
  width: 74px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.json-document {
  display: grid;
  gap: 14px;
}

.json-panel {
  background: #ffffff;
  border: 1px solid #dce6ec;
  border-radius: 8px;
  margin: 0 0 14px;
  overflow: hidden;
}

.json-panel summary::-webkit-details-marker {
  display: none;
}

.json-panel-head {
  align-items: center;
  background: #abe8ea;
  color: #1d2b31;
  cursor: pointer;
  display: flex;
  gap: 12px;
  min-height: 58px;
  padding: 12px 16px;
}

.json-panel-head strong {
  font-size: 18px;
  font-weight: 850;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.panel-depth-0 > .json-panel-head {
  background: #a8e6e8;
}

.panel-depth-1 > .json-panel-head {
  background: #b0eaec;
}

.panel-depth-2 > .json-panel-head,
.panel-depth-3 > .json-panel-head {
  background: #b9eef0;
}

.twisty::before {
  color: #03a69d;
  content: "▸";
  display: inline-block;
  font-size: 18px;
  transform: translateY(-1px);
}

.json-panel[open] > .json-panel-head .twisty::before {
  content: "▾";
}

.panel-icon {
  align-items: center;
  color: #05b9ad;
  display: inline-flex;
  font-size: 20px;
  height: 24px;
  justify-content: center;
  width: 24px;
}

.list-icon {
  font-size: 22px;
}

.panel-count {
  background: rgba(255, 255, 255, 0.72);
  border-radius: 6px;
  color: #57666b;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  margin-left: auto;
  padding: 10px 12px;
  white-space: nowrap;
}

.json-panel-body {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.json-card-list,
.array-record-list {
  display: grid;
  gap: 12px;
}

.json-value-card,
.array-record {
  background: #ffffff;
  border: 1px solid #dce6ec;
  border-radius: 8px;
  min-width: 0;
}

.json-value-card {
  padding: 12px;
}

.json-value-head,
.array-record-title {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.json-value-head strong,
.array-record-title strong,
.record-key {
  color: #00786f;
  font-weight: 850;
}

.type-pill {
  background: #9fe4e7;
  border-radius: 5px;
  color: #007a73;
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  padding: 8px 9px;
  white-space: nowrap;
}

.json-value-text,
.record-value {
  color: #0871e8;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.75;
  margin-top: 8px;
  max-width: 100%;
  overflow: visible;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  word-break: break-word;
}

.array-record {
  overflow: hidden;
}

.array-record-title {
  background: #f8fbfd;
  border-bottom: 1px solid #dce6ec;
  padding: 12px 14px;
}

.record-field {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(92px, 0.16fr) minmax(0, 1fr);
  padding: 12px 14px;
}

.record-field + .record-field {
  border-top: 1px solid #e9eef2;
}

.record-key {
  font-size: 14px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.long-record-field {
  background: #ffffff;
}

.long-record-field .record-value {
  color: #066bd8;
  font-size: 15px;
  line-height: 1.85;
}

.dialogue {
  color: #005fc5;
  font-weight: 900;
}

.speaker-mark {
  color: #9b3d57;
  font-weight: 850;
}

.ref-mark {
  color: #006f67;
  font-weight: 900;
}

.document-title {
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  padding-bottom: 18px;
}

.document-title h2 {
  font-size: 27px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.document-title p {
  color: var(--muted);
  margin-top: 8px;
}

.section-block {
  margin: 0 0 18px;
}

.section-heading {
  align-items: center;
  display: flex;
  gap: 10px;
  margin: 22px 0 10px;
}

.section-heading h3 {
  font-size: 18px;
  margin: 0;
  overflow-wrap: anywhere;
}

.section-heading::before {
  background: var(--accent);
  border-radius: 4px;
  content: "";
  flex: 0 0 auto;
  height: 22px;
  width: 5px;
}

.card-grid {
  display: grid;
  gap: 12px;
}

.field-card,
.array-item,
.tree-node {
  background: #fffaf0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.field-card {
  padding: 13px 14px;
}

.field-meta {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 7px;
}

.field-body {
  font-size: 15px;
  line-height: 1.72;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.script-line {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
}

.key-name {
  color: var(--accent);
  font-weight: 850;
}

.type-badge,
.path-chip {
  background: #efe9dc;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  line-height: 1;
  padding: 5px 8px;
}

.array-list {
  display: grid;
  gap: 10px;
}

.array-item {
  padding: 12px;
}

.array-item-title {
  align-items: center;
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.array-item-title strong {
  font-size: 14px;
}

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

.object-table th,
.object-table td {
  border-top: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.55;
  padding: 8px 6px;
  text-align: left;
  vertical-align: top;
}

.object-table th {
  color: var(--accent);
  font-weight: 850;
  width: 136px;
}

.object-table td {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.tree-node {
  margin: 0 0 8px;
  overflow: hidden;
}

.tree-node summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 8px;
  min-height: 38px;
  padding: 9px 12px;
}

.tree-node summary::-webkit-details-marker {
  display: none;
}

.tree-node summary::before {
  color: var(--accent);
  content: "▸";
  font-size: 13px;
}

.tree-node[open] > summary::before {
  content: "▾";
}

.tree-children {
  border-top: 1px solid var(--line);
  margin-left: 16px;
  padding: 10px 10px 10px 0;
}

.primitive-row {
  align-items: baseline;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(110px, 0.28fr) minmax(0, 1fr);
  padding: 9px 12px;
}

.primitive-row:first-child {
  border-top: 0;
}

.primitive-key {
  color: var(--accent);
  font-size: 13px;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.primitive-value {
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.value-string {
  color: var(--blue);
}

.value-number {
  color: var(--gold);
}

.value-boolean {
  color: var(--green);
}

.value-null {
  color: var(--rose);
}

.raw-view {
  background: #151918;
  border-radius: 8px;
  color: #ecf5ef;
  font-size: 13px;
  line-height: 1.55;
  margin: 0;
  overflow: auto;
  padding: 18px;
  white-space: pre-wrap;
}

.match {
  background: #ffe08a;
  border-radius: 3px;
  color: #332500;
}

.hidden-by-search {
  display: none;
}

.json-panel.hidden-by-search {
  display: none;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .input-pane,
  .reader-pane {
    min-height: auto;
  }

  textarea {
    min-height: 330px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .reader-layout {
    grid-template-columns: 1fr;
  }

  .outline {
    border-bottom: 1px solid var(--line);
    border-right: 0;
    max-height: 180px;
  }

  .summary-strip {
    overflow-x: auto;
  }

  .preview-area {
    padding: 16px;
  }

  .record-field {
    grid-template-columns: 1fr;
  }

  .json-panel-head {
    gap: 8px;
    padding: 10px 12px;
  }

  .json-panel-head strong {
    font-size: 16px;
  }

  .panel-count {
    font-size: 12px;
    padding: 8px;
  }
}
