/* JSON to TypeScript Converter — options, JSON input and generated code side by side.
   Colours come from the shared tokens, so the panel follows the light and dark themes. */
.j2t {
  display: grid;
  gap: 1.25rem;
  padding: clamp(16px, 2.4vw, 32px);
  text-align: left;
  color: var(--ink);
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 12px;
  box-shadow: 4px 4px 0 var(--shade);
}
.j2t *, .j2t *::before, .j2t *::after { box-sizing: border-box; }
.j2t [hidden] { display: none !important; }
.j2t h2 { margin: 0 0 .35rem; font-size: 1.45rem; letter-spacing: -.02em; }
.j2t h3 { margin: 0; font-size: 1.05rem; }
.j2t p { margin: 0; color: var(--ink-soft); }
.j2t code, .j2t pre, .j2t textarea { font-family: var(--font-mono); }
.j2t-head p { max-width: 76ch; }
.j2t-sub { display: block; font-size: .8rem; font-weight: 450; color: var(--ink-soft); }
.j2t-sub:empty { display: none; }

/* Controls */
.j2t input:not([type="radio"]):not([type="checkbox"]):not([type="file"]), .j2t select, .j2t textarea {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: .5rem .6rem;
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  background: var(--field);
  border: 1.5px solid var(--border-soft);
  border-radius: 6px;
}
.j2t :is(input, textarea, select, button, pre):focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.j2t button, .j2t-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: .5rem .95rem;
  font: inherit;
  font-size: .92rem;
  font-weight: 650;
  color: var(--ink);
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.j2t button:hover:not(:disabled), .j2t-button:hover { background: var(--paper-3); }
.j2t button:disabled { opacity: .5; cursor: default; }
.j2t .j2t-primary { color: var(--on-action); background: var(--action); box-shadow: 3px 3px 0 var(--shade); }
.j2t .j2t-primary:hover:not(:disabled) { background: var(--primary-dark); }

/* Options */
.j2t-options { padding: .85rem 1rem; background: var(--blue-tint); border: 2px solid var(--line); border-radius: 10px; }
.j2t-options summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .75rem; min-height: 32px; list-style: none; cursor: pointer; border-radius: 6px; }
.j2t-options summary::-webkit-details-marker { display: none; }
.j2t-options summary::before { content: ''; align-self: center; width: .55rem; height: .55rem; margin-right: .1rem; border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: rotate(-45deg); transition: transform .15s; }
.j2t-options[open] summary::before { transform: rotate(45deg); }
.j2t-options summary:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
.j2t-options[open] summary { margin-bottom: .85rem; }
.j2t-summary { font-family: var(--font-mono); font-size: .8rem; color: var(--ink-soft); overflow-wrap: anywhere; }
.j2t-options[open] .j2t-summary { display: none; }
.j2t-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.5rem), 1fr)); gap: .9rem 1.25rem; align-items: start; }
.j2t-field { display: grid; gap: .3rem; min-width: 0; font-size: .85rem; font-weight: 650; }
.j2t-pills { display: flex; flex-wrap: wrap; gap: .45rem; min-width: 0; margin: 0; padding: 0; border: 0; }
.j2t-pills legend { width: 100%; margin-bottom: .3rem; padding: 0; font-size: .85rem; font-weight: 650; }
.j2t-pills label { position: relative; display: inline-flex; align-items: center; min-height: 42px; padding: .4rem .85rem; font-size: .92rem; font-weight: 600; background: var(--bg-2); border: 2px solid var(--line); border-radius: 999px; cursor: pointer; }
.j2t-pills input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.j2t-pills label:has(input:checked) { color: var(--on-action); background: var(--action); box-shadow: 2px 2px 0 var(--shade); }
.j2t-pills label:has(input:focus-visible) { outline: 3px solid var(--primary); outline-offset: 2px; }
.j2t-pills code { font-size: .88rem; }
.j2t-checks { display: grid; gap: .1rem; }
.j2t-check { display: flex; align-items: center; gap: .55rem; min-height: 40px; font-size: .92rem; font-weight: 500; line-height: 1.3; cursor: pointer; }
.j2t-check input { flex: none; width: 1.2rem; height: 1.2rem; margin: 0; accent-color: var(--action); }
.j2t-check code { font-size: .9rem; }

/* Input and output */
.j2t-panes { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); gap: 1.25rem; align-items: start; }
.j2t-pane { display: grid; gap: .55rem; min-width: 0; border-radius: 10px; }
.j2t-pane.is-dragging { background: var(--action-tint); outline: 2px dashed var(--action-text); outline-offset: 6px; }
.j2t-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem .75rem; }
.j2t-title { font-size: 1.05rem; font-weight: 700; }
.j2t-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.j2t-file { position: relative; overflow: hidden; }
.j2t-file input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.j2t-file:has(input:focus-visible) { outline: 3px solid var(--primary); outline-offset: 2px; }
.j2t textarea { height: clamp(18rem, 52vh, 32rem); font-family: var(--font-mono); font-size: .86rem; line-height: 1.5; resize: vertical; tab-size: 2; }
.j2t textarea[aria-invalid="true"] { border-color: var(--error); }
.j2t-code {
  height: clamp(18rem, 52vh, 32rem);
  min-height: 12rem;
  margin: 0;
  padding: .7rem .8rem;
  overflow: auto;
  font-size: .86rem;
  line-height: 1.55;
  white-space: pre;
  tab-size: 2;
  color: var(--ink);
  background: var(--paper-3);
  border: 1.5px solid var(--border-soft);
  border-radius: 6px;
  resize: vertical;
}
.j2t-code.is-stale { opacity: .55; }
.j2t-code .j2t-k { color: var(--action-text); font-weight: 650; }
.j2t-code .j2t-n { font-weight: 750; }
.j2t-code .j2t-p { color: var(--info); }
.j2t-code .j2t-g { color: var(--action-text); }
.j2t-code .j2t-s { color: var(--success-strong); }
.j2t-code .j2t-c { color: var(--ink-soft); font-style: italic; }

.j2t-error { display: grid; gap: .5rem; justify-items: start; }
.j2t-error.is-visible { padding: .6rem .8rem; background: var(--error-soft); border-left: 4px solid var(--error); border-radius: 6px; }
.j2t-error p { font-weight: 600; color: var(--ink); }
.j2t-error p:empty { display: none; }
.j2t-error button { min-height: 38px; padding: .35rem .8rem; font-size: .88rem; }

.j2t-status { min-height: 1.4em; font-weight: 600; color: var(--ink) !important; }
.j2t-notes { display: grid; gap: .4rem; margin: 0; padding: .75rem 1rem .75rem 2rem; font-size: .9rem; line-height: 1.45; color: var(--ink); background: var(--warning-soft); border: 1.5px solid var(--border-soft); border-radius: 8px; }
.j2t-notes li { overflow-wrap: anywhere; }
.j2t-foot { font-size: .85rem; }

@media (max-width: 480px) {
  .j2t-actions button, .j2t-actions .j2t-button { flex: 1 1 auto; }
}

/* Space the page holds for this view until it mounts (see .tool-view-placeholder in _workspace.css).
   Each height is a little under the space the view takes at that width, measured as how far the
   content below moves when the view replaces the placeholder, so nothing below it moves. Re-measure
   after changing the view's layout: node scripts/measure-tool-views.js --apply <id>. */
.tool-view-placeholder[data-tool="json-to-typescript"] { min-height: 973px; }
@media (max-width: 1224px) { .tool-view-placeholder[data-tool="json-to-typescript"] { min-height: 1048px; } }
@media (max-width: 1064px) { .tool-view-placeholder[data-tool="json-to-typescript"] { min-height: 1065px; } }
@media (max-width: 944px) { .tool-view-placeholder[data-tool="json-to-typescript"] { min-height: 1467px; } }
@media (max-width: 719px) { .tool-view-placeholder[data-tool="json-to-typescript"] { min-height: 1152px; } }
@media (max-width: 568px) { .tool-view-placeholder[data-tool="json-to-typescript"] { min-height: 1185px; } }
@media (max-width: 488px) { .tool-view-placeholder[data-tool="json-to-typescript"] { min-height: 1229px; } }
@media (max-width: 416px) { .tool-view-placeholder[data-tool="json-to-typescript"] { min-height: 1312px; } }
@media (max-width: 376px) { .tool-view-placeholder[data-tool="json-to-typescript"] { min-height: 1361px; } }
@media (max-width: 360px) { .tool-view-placeholder[data-tool="json-to-typescript"] { min-height: 1409px; } }
@media (max-height: 639px) { .tool-view-placeholder[data-tool="json-to-typescript"] { min-height: 300px; } }
