:root {
  color-scheme: light;
  --line: #dfe3e8;
  --muted: #666;
  --mono: Consolas, "SFMono-Regular", "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
body { margin: 0; background: #f7f8fa; color: #222; font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif; }
button, input, textarea, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button, select { border: 1px solid #d4dae1; border-radius: 9px; background: #fff; padding: 7px 12px; }
button:hover:not(:disabled) { background: #f2f2f2; }
button:disabled { opacity: .45; cursor: not-allowed; }
:focus-visible { outline: 2px solid #4778a8; outline-offset: 2px; }
[hidden] { display: none !important; }
.connection { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--muted); font-size: 11px; }
.connection i { width: 6px; height: 6px; background: #56825c; border-radius: 50%; }
.connection.offline { color: #a53830; }
.connection.offline i { background: #a53830; }
.app-shell { --sidebar-width: 240px; display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100vh; }
.app-shell.history-visible { grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100dvh; overflow-y: auto; padding: 18px 12px; border-right: 1px solid var(--line); min-width: 0; background: #fff; }
.sidebar-handle { position: fixed; z-index: 5; left: 0; top: 20dvh; transform: translateY(-50%); width: 18px; height: 36px; min-height: 0; padding: 0; display: grid; place-items: center; border-left: 0; border-radius: 0 7px 7px 0; font-size: 20px; line-height: 1; color: #65758a; }
.history-visible .sidebar-handle { left: var(--sidebar-width); }
.new-button { width: 100%; display: flex; align-items: center; gap: 6px; text-align: left; }
.new-button kbd { margin-left: auto; }
kbd { font: 11px var(--mono); color: var(--muted); }
.sidebar-heading { display: flex; justify-content: space-between; align-items: center; margin: 22px 0 10px; }
.sidebar-heading h2 { margin: 0; font-size: 13px; font-weight: 600; }
#history-count { color: var(--muted); margin-left: 5px; font-weight: 400; }
.icon-button { border: 0; padding: 3px 7px; background: transparent; color: var(--muted); font-size: 18px; }
.search { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); padding: 7px 10px; border-radius: 9px; }
.search input { border: 0; min-width: 0; width: 100%; font-size: 12px; background: transparent; }
.search input:focus { outline: none; }
.search:focus-within { outline: 2px solid #4778a8; }
.history-list { margin-top: 10px; max-height: calc(100vh - 240px); overflow-y: auto; }
.history-empty { font-size: 12px; color: var(--muted); padding: 20px 4px; line-height: 1.8; }
.history-row { display: flex; align-items: center; border-radius: 8px; margin-bottom: 4px; }
.history-row:hover, .history-row.active { background: #f4f4f4; }
.history-open { border: 0; background: transparent; padding: 10px 4px; flex: 1; min-width: 0; text-align: left; }
.history-braces { display: none; }
.history-text { display: block; min-width: 0; }
.history-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font: 12px/1.6 var(--mono); }
.history-meta { display: block; font-size: 11px; margin-top: 4px; color: var(--muted); }
.history-delete { flex-shrink: 0; }
main { padding: 18px 20px 18px 34px; min-width: 0; }
.workspace-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.toolbar-start, .mode-switch, .format-options { display: flex; align-items: center; gap: 8px; }
.format-options { flex-wrap: wrap; }
.selected, .wrap-button.active { background: #edf2f7; border-color: #8a9fb4; color: #254a70; }
.wrap-button { display: inline-flex; align-items: center; gap: 8px; }
.switch-track { position: relative; display: inline-block; flex: 0 0 34px; width: 34px; height: 20px; border-radius: 12px; background: #8d98a5; }
.switch-track::after { content: ''; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; }
.wrap-button[aria-checked="true"] .switch-track { background: #4778a8; }
.wrap-button[aria-checked="true"] .switch-track::after { transform: translateX(14px); }
@media (forced-colors: active) { .switch-track { border: 1px solid ButtonText; } .switch-track::after { background: ButtonText; } }
.editor-panel { min-width: 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.panel-heading { min-height: 48px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: #fafbfc; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-heading h2, .panel-heading label { margin: 0; font-size: 13px; font-weight: 600; }
.panel-actions { display: flex; gap: 6px; min-width: 0; max-width: 100%; }
.text-button { border: 0; background: transparent; padding: 5px 8px; font-size: 13px; border-radius: 7px; }
.input-area { height: calc(100vh - 205px); min-height: 380px; position: relative; }
#json-input { height: 100%; }
.input-area { overflow: hidden; }
.cm-foldGutter .fold-toggle { display: block; border: 0; padding: 0 3px; min-height: 0; width: 22px; height: 24.5px; line-height: 24.5px; border-radius: 0; background: transparent; color: #666; font-size: 15px; }
.panel-heading { flex-wrap: wrap; }
.panel-actions { flex-wrap: wrap; }
@media (forced-colors: active) { .cm-repair { color: HighlightText !important; background: Highlight !important; } }
.repair-notice { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 6px 12px; border-top: 1px solid var(--line); font-size: 12px; color: #246235; }
.panel-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 32px; padding: 7px 12px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.footer-status { min-width: 0; }
#input-meta { text-align: right; white-space: nowrap; }
.status-ok { color: #477346; }
.status-error, .save-warning { color: #a53830; }
.workspace-bottom { margin-top: 10px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 12px; }
.workspace-bottom > span { white-space: nowrap; }
.error-panel { display: flex; align-items: center; gap: 8px; min-width: 0; color: #a53830; }
.error-detail { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#locate-error { flex-shrink: 0; padding: 0; font-size: inherit; text-decoration: underline; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 10px 16px; background: #333; color: #fff; border-radius: 10px; font-size: 13px; z-index: 10; }
@media (max-width: 1000px) {
  .app-shell { --sidebar-width: 210px; }
  main { padding: 16px 12px 16px 32px; }
  .panel-heading { padding: 6px 8px; }
  .panel-actions { gap: 0; }
}
@media (max-width: 760px) {
  .app-shell { --sidebar-width: min(260px, calc(100vw - 44px)); display: flex; flex-direction: column; }
  .sidebar { position: fixed; z-index: 4; left: 0; top: 0; width: var(--sidebar-width); border-right: 1px solid var(--line); padding: 18px 12px; }
  main { order: 1; }
  .new-button { max-width: 220px; }
  .history-list { max-height: 300px; }
  .search input { font-size: 16px; }
  .input-area { height: calc(100dvh - 260px); min-height: 340px; }
  .panel-footer { gap: 8px; }
  .error-panel { flex-wrap: wrap; row-gap: 2px; }
  .cm-foldGutter .fold-toggle { height: 28px; line-height: 28px; }
  #json-input .cm-editor { font-size: 16px; }
  .workspace-bottom > span { display: none; }
  .format-options { font-size: 13px; }
  .panel-actions button { min-height: 36px; }
}
@media (pointer: coarse) {
  button, select { min-height: 44px; }
  .panel-actions button { min-height: 44px; }
  .history-delete { min-width: 44px; }
}
