:root {
  color-scheme: light;
  --canvas: #f6f8fc;
  --white: #fff;
  --ink: #17213a;
  --muted: #586681;
  --subtle: #66748e;
  --line: #dce3ee;
  --soft-line: #e7ecf4;
  --accent: #334fdb;
  --accent-soft: #e9edff;
  --mono: "IBM Plex Mono", "Cascadia Mono", Consolas, monospace;
  --sans: Inter, "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  --good: #116a4f;
  --bad: #ae343e;
  --changed: #885619;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; background: var(--canvas); color: var(--ink); font: 14px/1.5 var(--sans); }
button, select, textarea { font: inherit; }
button, select, summary { cursor: pointer; }
a { color: inherit; text-decoration: none; }
button, a, select, textarea, summary, [tabindex="0"] { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { display: inline-block; width: 17px; height: 17px; vertical-align: middle; flex: none; }

.layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--white); border-right: 1px solid var(--line); min-width: 0; height: 100dvh; position: sticky; top: 0; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 11px; padding: 20px 18px; font-size: 16px; font-weight: 750; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; flex: none; border-radius: 9px; width: 35px; height: 35px; color: white; background: var(--accent); font: 700 14px var(--mono); }
html[lang="en"] .brand { font-size: 14px; white-space: normal; }
.sidebar nav { flex: 1; overflow: auto; padding: 11px 13px 15px; }
.nav-group + .nav-group { margin-top: 25px; }
.nav-group h2 { margin: 0 9px 9px; color: var(--subtle); font-size: 11px; font-weight: 700; letter-spacing: .065em; }
.nav-link { display: flex; align-items: center; gap: 10px; min-height: 39px; margin-bottom: 3px; padding: 7px 10px; border-radius: 7px; color: #485674; font-size: 13px; white-space: nowrap; }
.nav-link:hover { background: var(--canvas); color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: #283eb4; font-weight: 700; }
.nav-link > span:first-child { display: flex; }
.sidebar-footer { padding: 15px 15px 17px; margin: 0 12px; border-top: 1px solid var(--soft-line); display: flex; align-items: center; gap: 8px; color: var(--subtle); font-size: 11px; }
.sidebar-footer .icon { width: 14px; height: 14px; }
.guide-link { align-self: flex-start; margin: 0 27px 17px; color: var(--subtle); font-size: 12px; text-underline-offset: 3px; }
.guide-link:hover { color: var(--ink); }

.topbar { display: flex; align-items: center; gap: 12px; height: 61px; padding: 0 30px; background: var(--white); border-bottom: 1px solid var(--line); }
.language-select { margin-left: auto; flex: none; min-height: 30px; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); color: var(--ink); font-size: 12px; }
.topbar .privacy + .language-select { margin-left: 0; }
.breadcrumb { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.breadcrumb .icon { width: 13px; height: 13px; }
#breadcrumb { color: var(--ink); font-weight: 650; }
.privacy { display: flex; align-items: center; gap: 7px; margin-left: auto; font-size: 12px; color: var(--good); white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #28a67a; }
.main { max-width: 1600px; padding: 32px 30px 26px; margin: 0 auto; }
.home-ad { width: 100%; max-width: 728px; margin-inline: auto; }
.home-ad-meta { display: none; }
.home-ad:has(.adsbygoogle[data-ad-status="filled"], .adsbygoogle[data-ad-status="unfill-optimized"]) { margin-top: 28px; }
.home-ad:has(.adsbygoogle[data-ad-status="filled"], .adsbygoogle[data-ad-status="unfill-optimized"]) .home-ad-meta { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--subtle); font-size: 12px; }
.home-ad-meta a { color: inherit; text-underline-offset: 3px; }
.home-ad:has(.adsbygoogle[data-ad-status="unfilled"]) { display: none; }
.page-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.heading-icon { display: grid; place-items: center; color: #324bbd; background: var(--accent-soft); border: 1px solid #dce3ff; width: 49px; height: 49px; border-radius: 11px; flex: none; }
.heading-icon .icon { width: 23px; height: 23px; }
h1 { margin: 0; font-size: clamp(23px, 2.2vw, 30px); line-height: 1.25; letter-spacing: -.025em; }
.page-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.button, .icon-button, .quiet-button, .segmented button { border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; line-height: 1.25; }
.button { min-height: 37px; padding: 0 12px; background: var(--white); border: 1px solid var(--line); color: var(--ink); font-size: 13px; font-weight: 600; }
.button:hover { background: #eef2fa; }
.button .icon { width: 15px; height: 15px; }
.icon-button, .quiet-button { border: 1px solid transparent; background: transparent; color: var(--muted); min-height: 30px; padding: 0 7px; font-size: 12px; }
.icon-button { width: 31px; padding: 0; }
.icon-button:hover, .quiet-button:hover { background: #eef2fa; color: var(--ink); }
.quiet-button .icon, .icon-button .icon { width: 15px; height: 15px; }
.copy-button { color: #3048c4; background: #edf0ff; font-weight: 650; }
.copy-button:hover { color: #263ab0; background: #e0e6ff; }
button:disabled { cursor: default; opacity: .48; }
button:disabled:hover { background: transparent; color: var(--muted); }
.indent-control { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.indent-control select { min-height: 27px; padding: 0 6px; background: var(--white); border: 1px solid var(--line); color: var(--ink); border-radius: 6px; }

.panels { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.panel { min-width: 0; background: var(--white); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 2px 4px #13265207; overflow: hidden; display: flex; flex-direction: column; }
.panel-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px; min-height: 48px; padding: 8px 12px; border-bottom: 1px solid var(--soft-line); }
.panel-header h2 { display: flex; align-items: center; gap: 7px; margin: 0; font-size: 13px; font-weight: 700; }
.panel-header h2 .icon { width: 16px; height: 16px; color: #61708e; }
.panel-actions { display: flex; gap: 2px; align-items: center; }
.editor-header { justify-content: flex-start; column-gap: 10px; }
.editor-header h2 { white-space: nowrap; }
.editor-header > .panel-actions { margin-left: auto; }
.editor-operations { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding-left: 10px; border-left: 1px solid var(--soft-line); }
.editor-view-options { display: flex; align-items: center; gap: 8px; }
.editor { display: flex; position: relative; }
#source-editor, #sql-editor, #tree { height: clamp(320px, calc(100dvh - 338px), 680px); }
.editor:focus-within { box-shadow: inset 0 0 0 2px #adb9fc; }
.editor textarea, .gutter, #tree { font: 13px/23px var(--mono); tab-size: 4; }
.editor textarea { position: relative; background: transparent; color: var(--ink); min-width: 0; flex: 1; border: 0; resize: none; outline: none; padding: 12px 12px 22px; }
.editor textarea::placeholder { color: #68758e; }
.gutter { flex: 0 0 39px; text-align: right; background: #f9faff; color: #67758e; border-right: 1px solid #edf0f7; overflow: hidden; white-space: pre; padding: 12px 7px 42px 1px; user-select: none; }
.sql-edit-area { position: relative; display: flex; flex: 1; min-width: 0; }
.sql-highlight-viewport { position: absolute; inset: 0; overflow: hidden; pointer-events: none; user-select: none; }
.sql-highlight, .sql-edit-area textarea { font: 13px/23px var(--mono); font-kerning: none; font-variant-ligatures: none; tab-size: 4; white-space: pre; }
.sql-highlight { margin: 0; padding: 12px 12px 22px; }
.sql-edit-area textarea { color: transparent; caret-color: var(--ink); }
.sql-token-comment { color: var(--muted); }
.sql-token-identifier { color: #375578; }
.sql-token-parameter { color: #8b3c94; }
@media (forced-colors: active) {
  .sql-highlight-viewport { display: none; }
  .sql-edit-area textarea { color: CanvasText; caret-color: CanvasText; }
}
.panel-footer { display: flex; align-items: center; justify-content: space-between; gap: 5px; padding: 6px 12px; min-height: 35px; border-top: 1px solid var(--soft-line); font-size: 12px; color: var(--subtle); }
.editor-views { height: 43px; padding: 6px 12px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--soft-line); }
.editor-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#source-info { white-space: nowrap; }
.segmented { display: flex; gap: 2px; background: #f0f3fa; padding: 3px; border-radius: 7px; }
.segmented button { color: var(--muted); background: transparent; border: 0; min-height: 24px; padding: 0 8px; font-size: 12px; }
.segmented .icon { width: 14px; height: 14px; }
.segmented button[aria-pressed="true"] { color: #2d44b8; background: var(--white); font-weight: 650; box-shadow: 0 1px 3px #2339651a; }
#tree { margin: 0; padding: 12px 14px 22px; overflow: auto; color: var(--ink); outline-offset: -2px; }
.token-key { color: #3846a8; }
.token-string { color: #126b51; }
.token-number { color: #925017; }
.token-literal { color: #8b3c94; }
.tree-type { color: var(--subtle); font-size: 11px; margin-left: 7px; }
.tree-leaf { padding-left: 13px; }
.tree-children { border-left: 1px solid var(--soft-line); margin-left: 5px; padding-left: 13px; }
#tree { white-space: pre; }
#tree summary { width: max-content; }
.message-good { color: var(--good); }
.message-bad { color: var(--bad); }
.error-location { border: 0; padding: 1px; background: transparent; color: var(--bad); text-decoration: underline; white-space: nowrap; }
.shortcut { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 14px; font-size: 11px; color: var(--muted); }
.shortcut > span:last-child { margin-left: 4px; }
.shortcut .icon { margin-right: 3px; width: 15px; height: 15px; }
kbd { background: var(--white); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font: 11px/16px var(--mono); }

.diff-workspace { --diff-height: clamp(245px, calc(100dvh - 335px), 650px); }
.diff-column-headers, .diff-panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.diff-column-headers > :last-child, .diff-input + .diff-input { border-left: 1px solid var(--line); }
.diff-column-headers .panel-header { align-content: center; }
.diff-panels .editor { height: var(--diff-height); }
.diff-input-info { padding: 4px 10px; font-size: 11px; color: var(--subtle); }
.diff-input textarea[aria-invalid="true"] { box-shadow: inset 0 0 0 1px #d99299; }
.diff-footer { flex-wrap: wrap; min-height: 39px; }
.diff-options { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.diff-counts { display: flex; gap: 6px; }
.diff-filter { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); cursor: pointer; }
.diff-filter input { accent-color: var(--accent); }
.diff-tag { padding: 2px 7px; border-radius: 5px; background: #edf2fa; font-size: 11px; font-weight: 650; white-space: nowrap; }
.diff-tag.added { color: var(--good); background: #e6f5ef; }
.diff-tag.removed { color: var(--bad); background: #fdecee; }
.diff-tag.changed { color: var(--changed); background: #fff2de; }
.diff-feedback { color: var(--muted); }
.diff-feedback.message-good { color: var(--good); }
.diff-feedback.message-bad { color: var(--bad); }
.diff-scroll { height: var(--diff-height); overflow: auto; outline-offset: -2px; cursor: text; }
.split-diff { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; }
.split-diff td + td { border-left: 1px solid var(--line); }
.diff-cell { width: 50%; padding: 0; vertical-align: top; font: 12px/22px var(--mono); }
.diff-line { display: grid; grid-template-columns: 5ch 2ch minmax(0, 1fr); min-height: 22px; }
.diff-number { text-align: right; padding-right: 5px; background: #f4f6fa; color: var(--subtle); user-select: none; }
.diff-marker { text-align: center; font-weight: 700; user-select: none; }
.diff-code { min-width: 0; padding: 0 7px 0 2px; font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff-cell.removed { background: #ffe9eb; }
.diff-cell.removed .diff-number { background: #ffd8dd; }
.diff-cell.removed .diff-marker { color: var(--bad); }
.diff-cell.added { background: #e4f6ec; }
.diff-cell.added .diff-number { background: #cdeedc; }
.diff-cell.added .diff-marker { color: var(--good); }
.diff-cell.changed { background: #fff2de; }
.diff-cell.changed .diff-number { background: #fbe4bf; }
.diff-cell.changed .diff-marker { color: var(--changed); }
.diff-empty { background: repeating-linear-gradient(135deg, #f9fafd 0 5px, #f1f4f9 5px 6px); }
.diff-gap { padding: 3px 10px; text-align: center; background: #eef2ff; color: #435588; font-size: 12px; cursor: default; }
.tool-panel .panel-actions { flex-wrap: wrap; }
.tool-settings { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 16px; padding: 12px 14px; background: #f8faff; border-bottom: 1px solid var(--soft-line); }
.tool-fields { display: grid; gap: 14px; min-width: 0; padding: 14px; }
.tool-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.tool-field { display: grid; gap: 5px; min-width: 0; color: var(--muted); font-size: 12px; font-weight: 650; }
.tool-field :is(input, select, textarea) { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; background: var(--white); color: var(--ink); font: 13px/1.55 var(--mono); }
.tool-field select { font-family: var(--sans); }
.tool-field :is(input, textarea)[readonly] { background: #f8faff; }
.timestamp-fields { gap: 16px; padding: 16px; }
.timestamp-inputs { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px 16px; }
.timestamp-options { display: flex; gap: 10px; }
.timestamp-options select { white-space: nowrap; }
.timestamp-results { gap: 12px; }
.timestamp-result { position: relative; min-width: 0; padding: 8px 10px 10px; border: 1px solid var(--soft-line); border-radius: 8px; background: #f8faff; }
.timestamp-result .tool-field { grid-template-rows: 26px auto; align-items: center; }
.timestamp-result input[readonly] { background: var(--white); }
.timestamp-result > button { position: absolute; top: 8px; right: 10px; min-height: 26px; }
.tool-field textarea { min-height: 154px; resize: vertical; }
.tool-panel[data-tool="jwt"] .tool-field textarea[data-field="input"] { min-height: 108px; }
.tool-status { justify-content: flex-start; min-height: 34px; overflow-wrap: anywhere; }
.tool-status:empty { display: none; }
.tool-more { padding: 0 10px; }
.tool-more:has(button:not([hidden])) { padding-block: 5px; }
.tool-pattern { grid-template-columns: minmax(0, 1fr) minmax(5rem, 9rem); }
.tool-cron-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(95px, 1fr)); gap: 10px; }
.tool-hint { margin: 0; color: var(--muted); font-size: 12px; }
.tool-link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.token-metrics { display: flex; align-items: baseline; gap: 7px; color: var(--muted); }
.token-metrics output { color: var(--accent); font: 650 26px/1.2 var(--mono); }
.tool-next h3, .tool-match-results h3 { margin: 0 0 6px; font-size: 13px; }
.tool-next ol, .tool-match-results ol { margin: 0; padding-inline-start: 22px; color: var(--muted); }
.tool-next li { padding-block: 3px; }
.tool-match-results li { padding: 6px 0; border-bottom: 1px solid var(--soft-line); overflow-wrap: anywhere; }
.tool-match-results code { color: var(--ink); font-family: var(--mono); white-space: pre-wrap; }
.tool-match-offset { margin-left: 10px; color: var(--subtle); font-size: 11px; }
.tool-match-results p { margin: 3px 0 0; font-size: 12px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 10; max-width: calc(100% - 40px); background: #222e4b; color: white; padding: 9px 14px; border-radius: 7px; box-shadow: 0 3px 12px #17213a31; }
.menu-toggle { display: none; }

@media (max-width: 1000px) {
  .layout { grid-template-columns: 197px minmax(0, 1fr); }
  .main, .topbar { padding-inline: 20px; }
  .brand { padding-inline: 14px; }
}
@media (max-width: 760px) {
  .layout { display: block; }
  .sidebar { display: none; position: fixed; z-index: 5; top: 52px; left: 0; width: 228px; max-width: 85vw; height: calc(100dvh - 52px); box-shadow: 8px 0 24px #17213a25; }
  .sidebar.open { display: flex; }
  .menu-toggle { display: inline-flex; }
  .topbar { height: 52px; }
  .main { padding-top: 22px; }
  .panels { grid-template-columns: minmax(0, 1fr); }
  .tool-columns:not(.tool-pattern) { grid-template-columns: minmax(0, 1fr); }
  .timestamp-inputs { grid-template-columns: minmax(0, 1fr); }
  .timestamp-options > .tool-field { flex: 1; }
  #source-editor, #sql-editor, #tree { height: 330px; }
}
@media (max-width: 430px) {
  .topbar .privacy { display: none; }
  .topbar .privacy + .language-select { margin-left: auto; }
  .breadcrumb { min-width: 0; }
  #breadcrumb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .main, .topbar { padding-inline: 12px; }
  .page-heading { gap: 10px; margin-bottom: 18px; }
  .heading-icon { width: 43px; height: 43px; }
  .button { padding-inline: 9px; }
  .editor-operations { flex-basis: 100%; order: 1; padding-left: 0; border-left: 0; }
  .diff-column-headers .panel-header { padding-inline: 6px; }
  .diff-column-headers .icon-button { width: 25px; }
  .diff-line { grid-template-columns: 4ch 2ch minmax(0, 1fr); }
}
