/* JSON 工坊 — amber / brown code workbench. Shared shell: base.css */
:root {
  --accent: #a05f05;
  --accent-dark: #6f3c02;
  --accent-soft: #f5e2ba;
  --json-amber: #d99a2b;
  --json-gold: #f0bc5e;
  --json-brown: #3a2411;
  --json-brown-deep: #20160d;
  --json-brown-soft: #5a3a1d;
  --json-cream: #fff7e8;
  --json-line: #d9c39d;
  --json-green: #6f8f3a;
  --json-blue: #7a5c2c;
}

body {
  background-image:
    radial-gradient(circle at 92% 0%, rgba(217, 154, 43, .20), transparent 29rem),
    radial-gradient(circle at 3% 48%, rgba(111, 60, 2, .07), transparent 25rem),
    linear-gradient(rgba(25, 21, 16, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(25, 21, 16, .035) 1px, transparent 1px);
  background-size: auto, auto, 28px 28px, 28px 28px;
}

::selection { color: var(--json-cream); background: var(--accent-dark); }
.brand-mark { color: var(--json-cream); background: var(--accent); font-family: var(--font-mono); font-size: 15px; letter-spacing: -.08em; }
.eyebrow span { background: var(--json-brown); }
.top-nav a::after { background: var(--accent); }
.site-footer { background: #1e150d; }

/* Hero */
.json-hero {
  grid-template-columns: minmax(0, 1.16fr) minmax(330px, .84fr);
  gap: clamp(38px, 7vw, 88px);
  align-items: center;
  padding-block: clamp(54px, 7.5vw, 98px) 70px;
}
.json-hero .hero-lead { max-width: 610px; }
.json-hero .hero-facts span { border-color: var(--json-line); background: rgba(255, 250, 241, .66); }
.hero h1 em { color: var(--accent-dark); }
.hero h1 em::after { background: var(--json-amber); opacity: .24; }

.code-sheet {
  position: relative;
  width: min(100%, 440px);
  justify-self: end;
  padding: 18px;
  color: #f8ead1;
  background: var(--json-brown-deep);
  border: 2px solid var(--ink);
  border-radius: 22px;
  box-shadow: 11px 11px 0 var(--json-amber);
  transform: rotate(1.5deg);
}
.code-sheet::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(240, 188, 94, .13);
  border-radius: 16px;
  pointer-events: none;
}
.sheet-top,
.sheet-foot {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #bda47c;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .1em;
}
.sheet-top { padding: 2px 4px 14px; border-bottom: 1px dashed rgba(240, 188, 94, .2); }
.sheet-file { display: inline-flex; align-items: center; gap: 8px; color: #ead6b7; letter-spacing: .03em; }
.sheet-file i { width: 8px; height: 8px; border-radius: 50%; background: var(--json-gold); box-shadow: 0 0 0 4px rgba(240, 188, 94, .13); }
.sheet-top b {
  padding: 4px 7px;
  color: var(--json-brown-deep);
  background: var(--json-green);
  border-radius: 3px;
  font-size: 8px;
  letter-spacing: .09em;
}
.sheet-code { position: relative; z-index: 1; padding: 17px 2px 19px; }
.code-line {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  min-height: 25px;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: clamp(11px, 1.2vw, 12.5px);
  line-height: 1.85;
}
.code-line > i { color: #79654b; font-size: 9px; font-style: normal; text-align: right; }
.code-line > code { min-width: 0; overflow: hidden; color: #e9d6b8; white-space: nowrap; text-overflow: ellipsis; }
.code-line.is-focus { margin-inline: -8px; padding-inline: 8px; background: rgba(240, 188, 94, .1); border-left: 2px solid var(--json-amber); }
.tok-key { color: #efbd63; }
.tok-string { color: #bfd58a; }
.tok-bool { color: #e89555; }
.sheet-foot { padding: 13px 4px 2px; border-top: 1px dashed rgba(240, 188, 94, .2); font-size: 8px; }
.sheet-stamp {
  position: absolute;
  z-index: 2;
  right: -24px;
  bottom: 44px;
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  color: var(--json-brown-deep);
  background: var(--json-gold);
  border: 2px solid var(--ink);
  border-radius: 50%;
  box-shadow: 3px 3px 0 var(--ink);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  transform: rotate(9deg);
}

/* Tool shell */
.json-tool {
  grid-template-columns: minmax(0, 1.15fr) minmax(350px, .85fr);
  gap: 28px;
  scroll-margin-top: 26px;
}
.json-tool .card { border-radius: 20px; }
.editor-card { background: rgba(255, 250, 241, .97); }
.editor-card .status-pill { background: #fff4dc; border-color: var(--json-line); }
.editor-card .status-pill.is-ok { color: var(--card); background: var(--green); border-color: var(--green); }
.editor-card .status-pill.is-error { color: #fff; background: var(--accent-dark); border-color: var(--accent-dark); }

.editor-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding: 7px 11px;
  color: #796a58;
  background: #f0e5d2;
  border: 1px solid var(--json-line);
  border-bottom: 0;
  border-radius: 9px 9px 0 0;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .06em;
}
.editor-lang { color: var(--accent-dark); font-weight: 700; letter-spacing: .12em; }
.json-editor {
  min-height: 378px;
  height: 378px;
  margin-top: 0;
  padding: 17px 18px;
  color: #342414;
  background:
    linear-gradient(90deg, rgba(178, 107, 12, .055) 1px, transparent 1px) 0 0 / 34px 100%,
    #fffdf8;
  border-color: var(--json-line);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8);
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.78;
  tab-size: 2;
}
.json-editor:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(178, 107, 12, .15); }
.json-editor.has-error { border-color: #b34b24; box-shadow: 0 0 0 3px rgba(179, 75, 36, .14); }
.json-editor::placeholder { color: #a29179; }

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 11px;
  margin-top: 13px;
}
.toolbar-group { display: flex; flex-wrap: wrap; gap: 8px; }
.toolbar-group .button { background: #f6ecd9; }
.indent-switch {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  background: #f0e5d2;
  border: 1px solid var(--json-line);
  border-radius: 9px;
}
.indent-switch > span { padding: 0 7px; color: var(--muted); font-size: 10px; }
.indent-option {
  min-height: 44px;
  padding: 5px 9px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  cursor: pointer;
}
.indent-option.is-active { color: #fff7e8; background: var(--json-brown); box-shadow: 2px 2px 0 var(--json-amber); }

.run-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 20px;
  padding-top: 19px;
  border-top: 1px dashed var(--json-line);
}
.run-main { flex: 1 1 190px; }
.run-main span { font-family: var(--font-mono); font-size: 14px; letter-spacing: -.1em; }
.run-secondary { flex: 0 1 116px; background: #f6ecd9; }
.field-help kbd {
  padding: 1px 4px;
  color: var(--accent-dark);
  background: #f2e5cf;
  border: 1px solid var(--json-line);
  border-radius: 3px;
  font-size: 10px;
}

.free-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}
.free-strip > div {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 9px;
  padding: 12px 13px;
  background: rgba(255, 250, 241, .72);
  border: 1px solid var(--json-line);
  border-radius: 10px;
}
.free-strip span {
  grid-row: 1 / 3;
  align-self: center;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
}
.free-strip strong { font-size: 13px; line-height: 1.25; }
.free-strip small { color: var(--muted); font-size: 10px; }

/* Result card */
.result-card {
  position: sticky;
  top: 22px;
  background: rgba(255, 250, 241, .98);
  box-shadow: 5px 5px 0 var(--json-amber);
}
.result-card .status-pill { background: #fff4dc; border-color: var(--json-line); }
.result-card .status-pill.is-ok { color: var(--card); background: var(--green); border-color: var(--green); }
.result-card .status-pill.is-error { color: #fff; background: #8f3a16; border-color: #8f3a16; }
.view-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 20px 0 13px; }
.view-tabs .tool-button { background: #f6ecd9; }
.view-tabs .tool-button.is-active { color: var(--json-cream); background: var(--json-brown); box-shadow: 2px 2px 0 var(--json-amber); }
.view-tabs .lock-dot { margin-left: 2px; }

.result-stage { position: relative; }
#result.json-result {
  margin-top: 0;
  padding: 20px 18px;
  color: #f2e2c4;
  background:
    radial-gradient(circle at 100% 0%, rgba(217, 154, 43, .14), transparent 15rem),
    var(--json-brown-deep);
  border: 1.5px solid var(--ink);
  border-radius: 11px;
  box-shadow: inset 3px 3px 0 rgba(0, 0, 0, .24);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  scrollbar-color: #7e5d33 #2a1e12;
}
.result-stamp {
  position: absolute;
  z-index: 2;
  right: 14px;
  top: -10px;
  padding: 2px 6px;
  color: var(--accent-dark);
  background: var(--card);
  border: 1px solid var(--json-line);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 7.5px;
  line-height: 1.35;
  letter-spacing: .1em;
  text-align: right;
  pointer-events: none;
}
.json-result {
  min-height: 322px;
  max-height: 500px;
  overflow: auto;
}
#result.json-result:empty::before { color: #947c5b; }
#result.json-result.is-error {
  color: #ffddce;
  background: #35190f;
  border-color: #8f3a16;
  box-shadow: inset 3px 3px 0 rgba(143, 58, 22, .18);
}
#result.json-result.is-stale { opacity: .66; }

.result-meta { min-height: 18px; }
.result-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.result-chips span {
  padding: 4px 8px;
  color: var(--accent-dark);
  background: #f7ead1;
  border: 1px solid var(--json-line);
  border-radius: 100px;
  font-family: var(--font-mono);
  font-size: 9px;
}
.result-actions .button { background: #f6ecd9; }
.result-actions .button[data-premium-control] { background: #f2e5cf; }
.lock-note { background: #fff0d8; border-left-color: var(--accent); color: #6f3c02; }
.privacy-strip {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 17px;
  padding-top: 13px;
  color: #7a6b58;
  border-top: 1px dashed var(--json-line);
  font-size: 10.5px;
}
.privacy-strip span { color: var(--json-green); font-size: 8px; }

/* Tree view */
.tree-panel { margin-top: 2px; }
.tree-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.tree-toolbar > div:first-child { display: grid; gap: 2px; }
.tree-toolbar strong { font-size: 13px; }
.tree-toolbar span { color: var(--muted); font-size: 10.5px; }
.tree-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.tree-actions .copy-button { background: #f6ecd9; }
.tree-view {
  min-height: 322px;
  max-height: 500px;
  padding: 12px;
  overflow: auto;
  color: #e9d6b8;
  background: var(--json-brown-deep);
  border: 1.5px solid var(--ink);
  border-radius: 11px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.65;
  scrollbar-color: #7e5d33 #2a1e12;
}
.tree-list { margin: 0; padding: 0; list-style: none; }
.tree-list .tree-list { margin-left: 15px; padding-left: 11px; border-left: 1px solid rgba(240, 188, 94, .18); }
.tree-node { margin: 1px 0; }
.tree-line { display: flex; align-items: flex-start; gap: 5px; min-height: 24px; padding: 1px 3px; border-radius: 4px; }
.tree-line:hover { background: rgba(240, 188, 94, .08); }
.tree-toggle {
  flex: 0 0 auto;
  width: 20px;
  height: 22px;
  padding: 0;
  color: #c8a46a;
  background: transparent;
  border: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 22px;
  cursor: pointer;
}
.tree-spacer { display: inline-block; width: 20px; flex: 0 0 auto; }
.tree-key { color: #efbd63; overflow-wrap: anywhere; }
.tree-index { color: #b59a71; }
.tree-colon { color: #927a58; }
.tree-value { min-width: 0; overflow-wrap: anywhere; }
.tree-type {
  display: inline-block;
  margin-left: 5px;
  padding: 0 5px;
  color: #baa887;
  background: rgba(240, 188, 94, .1);
  border-radius: 3px;
  font-size: 8.5px;
  vertical-align: 1px;
}
.tree-value.is-string { color: #bfd58a; }
.tree-value.is-number { color: #f3a96a; }
.tree-value.is-boolean { color: #ea8c74; }
.tree-value.is-null { color: #a79577; font-style: italic; }
.tree-empty-note { margin: 10px 2px; color: #a89270; font-size: 10.5px; }
.tree-limit-note { margin: 12px 2px; padding-top: 10px; color: #c9a877; border-top: 1px dashed rgba(240, 188, 94, .18); font-size: 10px; }

/* Advanced workbench */
.advanced-shell { margin-top: 54px; scroll-margin-top: 28px; }
.advanced-heading { margin-bottom: 22px; }
.advanced-grid {
  display: grid;
  grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr);
  gap: 24px;
  align-items: start;
}
.advanced-card { background: rgba(255, 250, 241, .96); }
.advanced-card .premium-chip { background: var(--accent-dark); border-color: var(--accent-dark); }
.sort-option { margin: 19px 0 16px; padding: 10px 12px; background: #f7ecd9; border: 1px solid var(--json-line); border-radius: 9px; }
.sort-option small { display: block; color: var(--muted); font-size: 10px; line-height: 1.5; }
.sort-option input { accent-color: var(--accent); }
.button-block { width: 100%; }

.csv-source-field { margin-top: 19px; }
.csv-source-field select { font-family: var(--font-mono); font-size: 11px; }
.csv-actions { margin-top: 13px; }
.csv-actions .button { flex: 0 1 auto; }
.csv-preview {
  margin-top: 13px;
  max-height: 330px;
  overflow: auto;
  border: 1px solid var(--json-line);
  border-radius: 9px;
  background: #fffdf8;
}
.csv-preview .empty-state { margin: 0; border: 0; background: transparent; }
.csv-preview table { min-width: 520px; font-family: var(--font-mono); font-size: 10.5px; }
.csv-preview th { position: sticky; top: 0; z-index: 1; color: var(--accent-dark); background: #f7ead1; border-bottom: 1px solid var(--json-line); white-space: nowrap; }
.csv-preview td { max-width: 220px; overflow: hidden; color: #4b3a27; text-overflow: ellipsis; white-space: nowrap; }
.csv-preview tr:nth-child(even) td { background: rgba(247, 234, 209, .38); }
.csv-preview caption { padding: 9px 10px; color: var(--muted); font-family: var(--font-sans); font-size: 10px; text-align: left; }

@media (max-width: 900px) {
  .json-hero { grid-template-columns: 1fr; }
  .code-sheet { justify-self: start; width: min(100%, 520px); transform: rotate(.7deg); }
  .json-tool { grid-template-columns: 1fr; }
  .result-card { position: static; }
  .advanced-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .json-hero { gap: 36px; padding-bottom: 50px; }
  .code-sheet { padding: 15px; box-shadow: 7px 7px 0 var(--json-amber); }
  .sheet-stamp { right: -8px; bottom: 38px; width: 56px; height: 56px; font-size: 8px; }
  .json-editor { min-height: 300px; height: 300px; font-size: 12.5px; }
  .editor-toolbar { align-items: flex-start; }
  .indent-switch { width: 100%; justify-content: flex-end; }
  .run-row { align-items: stretch; }
  .run-main { flex: 1 0 100%; }
  .run-secondary { flex: 1 1 calc(50% - 5px); }
  .free-strip { grid-template-columns: 1fr; }
  .free-strip > div { grid-template-columns: 28px 1fr auto; grid-template-rows: auto; align-items: center; }
  .free-strip span { grid-row: auto; }
  .free-strip small { text-align: right; }
  #result.json-result, .tree-view { min-height: 270px; max-height: 420px; }
  .tree-toolbar { flex-direction: column; }
  .tree-actions { width: 100%; }
  .tree-actions .copy-button { flex: 1 1 auto; }
  .advanced-grid { gap: 18px; }
  .csv-actions { align-items: stretch; flex-direction: column; }
  .csv-actions .button { width: 100%; }
}

@media (max-width: 400px) {
  .code-sheet { width: 100%; padding: 13px; }
  .code-line { grid-template-columns: 19px minmax(0, 1fr); gap: 6px; font-size: 10px; }
  .sheet-stamp { display: none; }
  .json-tool { gap: 20px; }
  .editor-card, .result-card, .advanced-card { padding: 17px; }
  .json-editor { min-height: 270px; height: 270px; padding: 14px; font-size: 12px; }
  .indent-switch { justify-content: space-between; }
  .indent-option { flex: 1; }
  #result.json-result { padding: 16px 14px; font-size: 11px; }
  .tree-view { padding: 9px; font-size: 10.5px; }
  .tree-list .tree-list { margin-left: 10px; padding-left: 8px; }
  .result-chips span { font-size: 8.5px; }
}

@media (max-width: 700px), (pointer: coarse) {
  .tree-toggle {
    width: 44px;
    height: 44px;
    margin: -9px 0 -9px -6px;
    line-height: 44px;
  }
  .tree-spacer { width: 38px; }
  .tree-line { min-height: 36px; }
}

@media (prefers-reduced-motion: no-preference) {
  .code-line.is-focus { animation: json-focus 4.8s ease-in-out infinite; }
  .sheet-stamp { animation: json-stamp 5.2s ease-in-out infinite; }
  @keyframes json-focus {
    0%, 55%, 100% { background: rgba(240, 188, 94, .1); }
    68% { background: rgba(240, 188, 94, .2); }
  }
  @keyframes json-stamp {
    0%, 80%, 100% { transform: rotate(9deg); }
    88% { transform: rotate(4deg); }
  }
}
