/* ==========================================================================
   JSON Verifier — design system
   Aesthetic: "phosphor lab notebook" — editorial serif meets terminal mono.
   ========================================================================== */

:root{
  color-scheme: dark;

  --bg: #0b0f0d;
  --surface: #131a17;
  --surface-2: #17201c;
  --surface-raised: #1b2420;
  --border: #263029;
  --border-soft: #1d2620;

  --text: #e9efe9;
  --text-dim: #93a89c;
  --text-faint: #5c6d63;

  --accent: #6ff0a8;      /* phosphor green */
  --accent-strong: #8dffbe;
  --accent-warm: #ffb454;  /* amber, secondary */
  --accent-cool: #7bc7ff;  /* cool blue, tertiary for numbers */
  --accent-violet: #d9a8ff; /* booleans */
  --danger: #ff6b5e;
  --danger-soft: #3a1f1c;

  --shadow-lg: 0 20px 60px -20px rgba(0,0,0,0.65);
  --shadow-sm: 0 2px 10px -4px rgba(0,0,0,0.5);

  --font-display: "Fraunces", "Iowan Old Style", ui-serif, Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --radius: 10px;
  --radius-sm: 6px;
}

:root[data-theme="light"]{
  color-scheme: light;
  --bg: #f4f0e6;
  --surface: #fffdf8;
  --surface-2: #faf5ea;
  --surface-raised: #ffffff;
  --border: #e0d8c4;
  --border-soft: #ece4d2;

  --text: #201d16;
  --text-dim: #675f4d;
  --text-faint: #948a72;

  --accent: #0d8a52;
  --accent-strong: #086b3f;
  --accent-warm: #b5650c;
  --accent-cool: #1968b0;
  --accent-violet: #7a3fa0;
  --danger: #b8402c;
  --danger-soft: #fbe7e2;

  --shadow-lg: 0 20px 50px -24px rgba(60,50,20,0.28);
  --shadow-sm: 0 2px 10px -4px rgba(60,50,20,0.18);
}

@media (prefers-color-scheme: light){
  :root:not([data-theme="dark"]){
    color-scheme: light;
    --bg: #f4f0e6;
    --surface: #fffdf8;
    --surface-2: #faf5ea;
    --surface-raised: #ffffff;
    --border: #e0d8c4;
    --border-soft: #ece4d2;

    --text: #201d16;
    --text-dim: #675f4d;
    --text-faint: #948a72;

    --accent: #0d8a52;
    --accent-strong: #086b3f;
    --accent-warm: #b5650c;
    --accent-cool: #1968b0;
    --accent-violet: #7a3fa0;
    --danger: #b8402c;
    --danger-soft: #fbe7e2;

    --shadow-lg: 0 20px 50px -24px rgba(60,50,20,0.28);
    --shadow-sm: 0 2px 10px -4px rgba(60,50,20,0.18);
  }
}

*, *::before, *::after{ box-sizing: border-box; }
html{ -webkit-text-size-adjust: 100%; }

body{
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 12% -10%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, color-mix(in srgb, var(--accent-warm) 5%, transparent), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.5;
  padding: 0 20px;
}

::selection{ background: color-mix(in srgb, var(--accent) 35%, transparent); }

a{ color: var(--accent); }

/* subtle grain overlay for texture */
.grain{
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------------------------------- header ---------------------------------- */

.site-header{
  position: relative; z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 4px 20px;
  gap: 16px;
}

.brand{ display: flex; align-items: center; gap: 12px; }
.brand-mark{ color: var(--accent); flex-shrink: 0; }
.brand-text{ display: flex; flex-direction: column; line-height: 1.15; }
.brand-name{
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: 0.2px;
}
.brand-tag{
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 2px;
}

.header-actions{ display: flex; align-items: center; gap: 14px; }

.privacy-note{
  display: flex; align-items: center; gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface);
}
.privacy-note svg{ color: var(--accent); }

.icon-btn{
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s ease, transform .15s ease, background .15s ease;
}
.icon-btn:hover{ border-color: var(--accent); transform: translateY(-1px); }
.icon-btn:active{ transform: translateY(0); }
.icon-moon{ display: none; }
:root[data-theme="light"] .icon-sun{ display: none; }
:root[data-theme="light"] .icon-moon{ display: inline-block; }

/* ---------------------------------- layout ---------------------------------- */

.workspace{
  position: relative; z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
  padding-bottom: 40px;
}

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

.panel{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.panel-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap;
}

.panel-head h2{
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.2px;
}

.panel-head-actions{ display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------- buttons ---------------------------------- */

.btn{
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease, transform .1s ease;
  white-space: nowrap;
}
.btn:hover:not(:disabled){ border-color: var(--accent); }
.btn:active:not(:disabled){ transform: translateY(1px); }
.btn:disabled{ opacity: 0.4; cursor: not-allowed; }
.btn:focus-visible{ outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-ghost{ background: var(--surface-2); }
.btn-outline{ border-color: var(--accent); color: var(--accent); }
.btn-outline:hover:not(:disabled){ background: color-mix(in srgb, var(--accent) 12%, transparent); }
.btn-solid{
  background: var(--accent);
  border-color: var(--accent);
  color: #06140d;
}
.btn-solid:hover:not(:disabled){ background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-xs{ padding: 4px 9px; font-size: 11.5px; }

/* ---------------------------------- input panel ---------------------------------- */

.editor-frame{
  position: relative;
  display: flex;
  height: 420px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-soft);
}

.editor-gutter{
  flex-shrink: 0;
  width: 46px;
  padding: 14px 8px 14px 0;
  text-align: right;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-faint);
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  overflow: hidden;
  white-space: pre;
  user-select: none;
}

.editor-area{
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  padding: 14px 16px;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
}
.editor-area::placeholder{ color: var(--text-faint); }

.dropzone-overlay{
  position: absolute; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent) 14%, var(--bg) 70%);
  border: 2px dashed var(--accent);
  pointer-events: none;
}
.editor-frame.is-dragover .dropzone-overlay{ display: flex; }
.dropzone-msg{
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  color: var(--accent-strong);
  background: var(--surface);
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
}

.status-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  flex-wrap: wrap;
}

.status-badge{
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.status-badge .dot{
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}
.status-idle{ color: var(--text-dim); }
.status-valid{ color: var(--accent-strong); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.status-valid .dot{ background: var(--accent); box-shadow: 0 0 8px 1px color-mix(in srgb, var(--accent) 70%, transparent); }
.status-invalid{ color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.status-invalid .dot{ background: var(--danger); box-shadow: 0 0 8px 1px color-mix(in srgb, var(--danger) 60%, transparent); }
.status-busy .dot{ background: var(--accent-warm); animation: pulse 1s ease-in-out infinite; }

@keyframes pulse{
  0%, 100%{ opacity: 1; }
  50%{ opacity: 0.35; }
}

.stats-line{
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.error-detail{
  margin: 0 16px 16px;
  border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--border));
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.error-msg{
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--danger);
  font-weight: 600;
  border-bottom: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
}
.error-snippet{
  margin: 0;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.6;
  overflow-x: auto;
  color: var(--text-dim);
}
.error-snippet .caret-line{ color: var(--danger); }

/* ---------------------------------- output panel ---------------------------------- */

.tabs{ display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 999px; border: 1px solid var(--border); }
.tab-btn{
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 13px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.tab-btn.is-active{ background: var(--accent); color: #06140d; }
.tab-btn:not(.is-active):hover{ color: var(--text); }

.output-toolbar{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap;
}

.indent-select{
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}
.indent-select select{
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  cursor: pointer;
}
.indent-select select:focus-visible{ outline: 2px solid var(--accent); }

.toolbar-spacer{ flex: 1; }

.view{ display: none; height: 420px; }
.view.is-active{ display: block; }

.code-view{ overflow: hidden; }
.code-output{
  margin: 0;
  height: 100%;
  overflow: auto;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre;
}
.code-output:focus-visible{ outline: none; }
.code-output .placeholder,
.tree-root .placeholder{
  color: var(--text-faint);
  font-style: normal;
  white-space: pre-wrap;
}

/* JSON syntax colors */
.tok-key{ color: var(--accent-cool); }
.tok-str{ color: var(--accent); }
.tok-num{ color: var(--accent-warm); }
.tok-bool{ color: var(--accent-violet); }
.tok-null{ color: var(--text-faint); font-style: italic; }
.tok-punc{ color: var(--text-dim); }

.tree-view{ display: none; flex-direction: column; }
.tree-view.is-active{ display: flex; }
.tree-toolbar{
  display: flex; gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.tree-root{
  flex: 1;
  overflow: auto;
  padding: 10px 8px;
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.tree-root:focus-visible{ outline: none; }

/* tree nodes */
.tnode{ margin: 0; }
.tnode-row{
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 6px;
  border-radius: 5px;
  cursor: default;
}
.tnode-row.is-expandable{ cursor: pointer; }
.tnode-row.is-expandable:hover{ background: var(--surface-2); }
.tnode-toggle{
  width: 14px; flex-shrink: 0;
  color: var(--text-faint);
  font-size: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .12s ease;
}
.tnode.is-open > .tnode-row .tnode-toggle{ transform: rotate(90deg); }
.tnode-key{ color: var(--accent-cool); font-weight: 600; }
.tnode-meta{ color: var(--text-faint); font-size: 11px; }
.tnode-preview{ color: var(--text-dim); }
.tnode-children{ margin-left: 17px; padding-left: 8px; border-left: 1px solid var(--border-soft); display: none; }
.tnode.is-open > .tnode-children{ display: block; }
.tnode-value-str{ color: var(--accent); }
.tnode-value-num{ color: var(--accent-warm); }
.tnode-value-bool{ color: var(--accent-violet); }
.tnode-value-null{ color: var(--text-faint); font-style: italic; }

.tree-more-btn{
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px 6px;
  margin-left: 8px;
}
.tree-more-btn:hover{ text-decoration: underline; }

/* ---------------------------------- footer ---------------------------------- */

.site-footer{
  position: relative; z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 4px 40px;
  text-align: center;
}
.site-footer p{
  margin: 0;
  font-size: 11.5px;
  color: var(--text-faint);
}

/* ---------------------------------- scrollbars ---------------------------------- */

.editor-area::-webkit-scrollbar,
.code-output::-webkit-scrollbar,
.tree-root::-webkit-scrollbar,
.error-snippet::-webkit-scrollbar{
  width: 10px; height: 10px;
}
.editor-area::-webkit-scrollbar-track,
.code-output::-webkit-scrollbar-track,
.tree-root::-webkit-scrollbar-track{ background: transparent; }
.editor-area::-webkit-scrollbar-thumb,
.code-output::-webkit-scrollbar-thumb,
.tree-root::-webkit-scrollbar-thumb{
  background: var(--border);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* ---------------------------------- responsive ---------------------------------- */

@media (max-width: 560px){
  body{ font-size: 14px; padding: 0 12px; }
  .site-header{ padding: 20px 2px 14px; }
  .brand-name{ font-size: 19px; }
  .brand-tag{ display: none; }
  .privacy-note{ display: none; }
  .panel-head{ padding: 12px; }
  .editor-frame, .view{ height: 340px; }
  .editor-gutter{ width: 34px; font-size: 11.5px; }
  .editor-area{ font-size: 12.5px; padding: 12px; }
  .output-toolbar{ padding: 8px 12px; }
  .status-row{ padding: 10px 12px; }
  .error-detail{ margin: 0 12px 12px; }
}

@media (max-width: 400px){
  .panel-head-actions .btn{ padding: 6px 9px; font-size: 11.5px; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
