.jf-tool {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(0, 1.05fr);
  gap: 1.25rem;
  align-items: start;
  margin: 1.5rem 0;
}

.jf-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.jf-input-panel,
.jf-output-panel {
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
}

.jf-toolbar,
.jf-options,
.jf-actions,
.jf-output-head,
.jf-tree-head,
.jf-output-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.jf-toolbar,
.jf-output-head,
.jf-tree-head {
  justify-content: space-between;
}

.jf-mode-group {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.35rem;
  width: 100%;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.jf-mode-btn {
  min-height: 44px;
  padding: 0.55rem 0.65rem;
  border: 0;
  border-radius: calc(var(--radius) - 4px);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
}

.jf-mode-btn:hover,
.jf-mode-btn:focus {
  color: var(--text);
}

.jf-mode-btn.is-active {
  background: var(--primary);
  color: rgb(var(--on-primary-rgb));
  box-shadow: 0 8px 18px rgba(var(--primary-rgb), 0.22);
}

.jf-file-btn {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
}

.jf-file-btn:hover,
.jf-file-btn:focus-within {
  border-color: rgba(var(--primary-rgb), 0.55);
  color: var(--primary);
}

.jf-file-btn input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.jf-options {
  flex-wrap: wrap;
  align-items: end;
}

.jf-options .input-group {
  min-width: 160px;
  margin-bottom: 0;
}

.jf-check {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.jf-check input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary);
}

.jf-editor-label {
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 800;
}

.jf-editor,
.jf-output {
  width: 100%;
  min-height: 460px;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
  line-height: 1.55;
  tab-size: 2;
  resize: vertical;
}

.jf-output {
  min-height: 320px;
}

.jf-editor:focus,
.jf-output:focus,
.jf-tree-head .input-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
  outline: none;
}

.jf-actions {
  flex-wrap: wrap;
}

.jf-actions .btn,
.jf-output-actions .btn {
  min-height: 44px;
}

.jf-status {
  min-height: 1.35rem;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.jf-status.is-success {
  color: var(--success);
}

.jf-status.is-warning {
  color: var(--warning);
}

.jf-status.is-danger {
  color: var(--danger);
}

.jf-copy-fallback {
  position: fixed;
  inset: 0 auto auto 0;
  opacity: 0;
  pointer-events: none;
}

.jf-hero-card {
  position: relative;
  display: grid;
  gap: 0.45rem;
  min-height: 140px;
  padding: 1.25rem;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: rgb(var(--on-primary-rgb));
  overflow: hidden;
}

.jf-hero-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(var(--on-primary-rgb), 0.2), transparent 58%);
  pointer-events: none;
}

.jf-hero-card > * {
  position: relative;
}

.jf-hero-card span {
  color: rgba(var(--on-primary-rgb), 0.78);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.jf-hero-card strong {
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1;
}

.jf-hero-card p {
  margin: 0;
  color: rgba(var(--on-primary-rgb), 0.86);
  line-height: 1.45;
}

.jf-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.jf-stats-grid > div,
.jf-error-card,
.jf-output-card,
.jf-tree-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.jf-stats-grid > div {
  display: grid;
  gap: 0.3rem;
  padding: 0.9rem;
}

.jf-stats-grid span {
  color: var(--text-muted);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.jf-stats-grid strong {
  color: var(--text);
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
}

.jf-error-card {
  overflow: hidden;
  border-color: rgba(var(--danger-rgb), 0.5);
}

.jf-error-head,
.jf-output-head,
.jf-tree-head {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
}

.jf-error-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom-color: rgba(var(--danger-rgb), 0.26);
}

.jf-error-head h2,
.jf-output-head h2,
.jf-tree-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
}

.jf-error-head span {
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 800;
}

.jf-error-card p {
  margin: 0;
  padding: 0.9rem 1rem 0;
  color: var(--danger);
  line-height: 1.45;
}

.jf-error-context {
  display: grid;
  gap: 0.35rem;
  padding: 0.9rem 1rem 1rem;
}

.jf-error-line {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  gap: 0.75rem;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.jf-error-line span:first-child {
  color: var(--text-muted);
  text-align: right;
  user-select: none;
}

.jf-error-line.is-marker span:last-child {
  color: var(--danger);
  font-weight: 800;
}

.jf-output-card,
.jf-tree-card {
  overflow: hidden;
}

.jf-output-head,
.jf-tree-head {
  align-items: center;
}

.jf-output {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.jf-tree-head .input-field {
  max-width: 260px;
  min-height: 44px;
}

.jf-tree-summary {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.86rem;
}

.jf-tree-list {
  max-height: 420px;
  overflow: auto;
}

.jf-tree-row {
  display: grid;
  grid-template-columns: minmax(11rem, 1.2fr) minmax(5.5rem, 0.45fr) minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.58rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
  line-height: 1.35;
}

.jf-tree-row:last-child {
  border-bottom: 0;
}

.jf-tree-row.is-hidden {
  display: none;
}

.jf-tree-path {
  color: var(--primary);
  overflow-wrap: anywhere;
}

.jf-tree-type {
  color: var(--text-muted);
  font-weight: 800;
}

.jf-tree-preview {
  color: var(--text);
  overflow-wrap: anywhere;
}

.jf-tree-depth-0 .jf-tree-path { padding-left: 0; }
.jf-tree-depth-1 .jf-tree-path { padding-left: 0.75rem; }
.jf-tree-depth-2 .jf-tree-path { padding-left: 1.5rem; }
.jf-tree-depth-3 .jf-tree-path { padding-left: 2.25rem; }
.jf-tree-depth-4 .jf-tree-path { padding-left: 3rem; }
.jf-tree-depth-5 .jf-tree-path { padding-left: 3.75rem; }
.jf-tree-depth-6 .jf-tree-path { padding-left: 4.5rem; }
.jf-tree-depth-7 .jf-tree-path { padding-left: 5.25rem; }
.jf-tree-depth-8 .jf-tree-path { padding-left: 6rem; }
.jf-tree-depth-9 .jf-tree-path { padding-left: 6.75rem; }
.jf-tree-depth-10 .jf-tree-path { padding-left: 7.5rem; }
.jf-tree-depth-11 .jf-tree-path { padding-left: 8.25rem; }
.jf-tree-depth-12 .jf-tree-path { padding-left: 9rem; }

@media (max-width: 1040px) {
  .jf-tool {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .jf-input-panel,
  .jf-output-panel {
    padding: 1rem;
  }

  .jf-toolbar,
  .jf-options,
  .jf-actions,
  .jf-output-head,
  .jf-tree-head,
  .jf-output-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .jf-mode-group,
  .jf-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .jf-file-btn,
  .jf-actions .btn,
  .jf-output-actions .btn,
  .jf-tree-head .input-field {
    width: 100%;
    justify-content: center;
    max-width: none;
  }

  .jf-editor,
  .jf-output {
    min-height: 300px;
    font-size: 0.88rem;
  }

  .jf-error-line {
    grid-template-columns: 3.25rem minmax(0, 1fr);
  }

  .jf-tree-row {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .jf-tree-path {
    padding-left: 0 !important;
  }
}
