:root {
  color-scheme: light;
  --ink: #252923;
  --ink-soft: #60645d;
  --line: #d7d4ca;
  --paper: #f6f5f0;
  --paper-deep: #eae8df;
  --white: #fffefa;
  --accent: #bf5839;
  --accent-dark: #9f452c;
  --green: #54705a;
  --mono: "DM Mono", Consolas, monospace;
  --sans: "DM Sans", "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--paper-deep); color: var(--ink); font-family: var(--sans); font-size: 14px; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.topbar {
  min-height: 70px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; gap: 24px;
  color: #f1f0e9; background: var(--ink); border-bottom: 3px solid #3f4940;
}
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; min-width: max-content; }
.brand-mark { display: flex; align-items: end; gap: 3px; width: 22px; height: 23px; padding: 3px; border: 1px solid #858c7e; }
.brand-mark i { display: block; width: 3px; background: #d17a57; }
.brand-mark i:nth-child(1) { height: 8px; }
.brand-mark i:nth-child(2) { height: 13px; }
.brand-mark i:nth-child(3) { height: 6px; }
.brand-name { font-size: 11px; font-weight: 700; letter-spacing: .11em; }
.brand-name span { color: #a8ad9f; padding: 0 4px; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.api-state { display: inline-flex; align-items: center; gap: 7px; padding-right: 13px; margin-right: 3px; color: #bfc5b8; font: 11px var(--mono); }
.state-dot { width: 7px; height: 7px; border-radius: 50%; background: #c28a46; }
.api-state.is-ready .state-dot { background: #91b48b; }
.api-state.is-offline .state-dot { background: #d77c62; }
.button { min-height: 38px; padding: 0 14px; border: 1px solid transparent; border-radius: 3px; cursor: pointer; font-size: 13px; font-weight: 600; transition: background-color .15s, border-color .15s; }
.button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .tab:focus-visible { outline: 2px solid #d17a57; outline-offset: 2px; }
.button:disabled { cursor: not-allowed; opacity: .48; }
.button-quiet { color: #f1f0e9; background: transparent; border-color: #62675f; }
.button-quiet:hover:not(:disabled) { background: #343a33; border-color: #92978d; }
.button-accent { color: white; background: var(--accent); }
.button-accent:hover:not(:disabled) { background: var(--accent-dark); }
.button-small { min-height: 33px; color: var(--ink-soft); border-color: var(--line); font-size: 12px; }
.button-small:hover:not(:disabled) { color: var(--ink); background: #eeece4; }

.workspace { display: grid; grid-template-columns: 286px minmax(0, 1fr); min-height: calc(100vh - 70px); }
.catalog { display: flex; flex-direction: column; min-width: 0; padding: 25px 15px 13px 21px; background: #eeece4; border-right: 1px solid #d2cfc4; }
.catalog-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 5px 16px 2px; }
.eyebrow { margin: 0 0 6px; color: #777b72; font: 10px var(--mono); letter-spacing: .12em; }
.catalog h1 { margin: 0; font-size: 23px; font-weight: 600; letter-spacing: -.04em; }
.count-pill { color: #65695f; font: 11px var(--mono); }
.search-box { display: flex; align-items: center; height: 39px; padding: 0 8px 0 11px; background: var(--white); border: 1px solid #cbc9bf; border-radius: 3px; }
.search-box:focus-within { border-color: #7c8e78; box-shadow: 0 0 0 2px #7c8e7822; }
.search-icon { width: 13px; height: 13px; margin-right: 9px; border: 1.5px solid #81857b; border-radius: 50%; position: relative; }
.search-icon::after { content: ""; position: absolute; width: 5px; height: 1.5px; right: -4px; bottom: -2px; background: #81857b; transform: rotate(45deg); }
.search-box input { width: 100%; min-width: 0; padding: 0; color: var(--ink); background: transparent; border: 0; outline: 0; font-size: 12px; }
.search-box input::placeholder { color: #898c83; }
kbd { display: inline-block; min-width: 19px; padding: 2px 4px; color: #6d7168; background: #e7e5dc; border: 1px solid #d3d0c5; border-radius: 2px; text-align: center; font: 10px var(--mono); }
.search-box kbd { margin-left: 5px; }
.catalog-meta { min-height: 30px; padding: 10px 2px 5px; color: #797c73; font-size: 11px; }
.item-list { flex: 1; min-height: 100px; overflow: auto; border-top: 1px solid #d8d5cb; border-bottom: 1px solid #d8d5cb; scrollbar-color: #c5c2b7 transparent; scrollbar-width: thin; }
.item-row { width: 100%; height: 35px; display: grid; grid-template-columns: 49px minmax(0, 1fr); gap: 8px; align-items: center; padding: 0 7px 0 4px; color: #393d36; background: transparent; border: 0; border-bottom: 1px solid #e1dfd6; text-align: left; cursor: pointer; }
.item-row:hover { background: #e5e3d9; }
.item-row[aria-selected="true"] { position: relative; color: #fffefa; background: #3b493e; }
.item-id { color: #83867c; font: 10px var(--mono); }
.item-row[aria-selected="true"] .item-id { color: #c2c9bd; }
.item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.empty-list { display: grid; justify-items: center; align-content: center; gap: 10px; height: 100%; min-height: 150px; color: #797c73; text-align: center; }
.empty-list p { max-width: 150px; margin: 0; font-size: 12px; line-height: 1.5; }
.empty-mark { display: grid; place-items: center; width: 34px; height: 28px; color: #74786f; border: 1px solid #c8c6bb; font: 10px var(--mono); }
.catalog-footer { display: flex; justify-content: space-between; gap: 4px; padding-top: 11px; color: #777b72; }
.key-hint { display: flex; align-items: center; gap: 3px; font-size: 10px; }

.editor { min-width: 0; padding: 30px clamp(22px, 4vw, 58px) 26px; background: var(--paper); }
.editor-empty { display: flex; flex-direction: column; align-items: flex-start; max-width: 570px; margin: clamp(40px, 12vh, 120px) auto 0; }
.welcome-rule { width: 48px; height: 3px; margin-bottom: 28px; background: var(--accent); }
.editor-empty h2 { margin: 7px 0 14px; font-size: clamp(34px, 4vw, 50px); font-weight: 500; letter-spacing: -.055em; line-height: 1.06; }
.welcome-copy { max-width: 430px; margin: 0 0 23px; color: #656960; font-size: 15px; line-height: 1.65; }
.welcome-copy code { padding: 1px 4px; color: #373c34; background: #e8e6dc; font: 12px var(--mono); }
.format-note { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-top: 34px; padding-top: 15px; border-top: 1px solid var(--line); color: #757970; font: 10px var(--mono); }
.format-note strong { color: #3d423a; font-weight: 500; }
.note-divider { height: 13px; margin: 0 7px; border-left: 1px solid #c7c4ba; }

.editor-content { max-width: 1120px; margin: 0 auto; }
.item-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; min-height: 85px; padding-bottom: 20px; }
.item-heading .eyebrow { margin-bottom: 7px; }
.item-heading h2 { margin: 0; font-size: clamp(26px, 3vw, 34px); font-weight: 600; letter-spacing: -.045em; line-height: 1.1; overflow-wrap: anywhere; }
.item-pair { margin: 7px 0 0; color: #72766d; font-size: 12px; }
.item-badges { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.data-badge { padding: 5px 7px; color: #666b60; background: #ebe9e0; border: 1px solid #d9d6cb; font: 10px var(--mono); white-space: nowrap; }
.tabs { display: flex; gap: 3px; overflow-x: auto; border-bottom: 1px solid #c9c7bd; scrollbar-width: thin; }
.tab { flex: 0 0 auto; min-height: 42px; padding: 0 13px; color: #686c63; background: transparent; border: 0; border-bottom: 2px solid transparent; cursor: pointer; font-size: 12px; }
.tab:hover { color: var(--ink); background: #eeece4; }
.tab.is-active { color: #873f2d; border-bottom-color: var(--accent); font-weight: 700; }
.tab-content { min-height: 460px; padding: 20px 0 26px; }
.field-section { margin-bottom: 19px; padding: 17px 19px 13px; background: var(--white); border: 1px solid #dedbd1; border-radius: 3px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 0 13px; color: #343a32; font-size: 13px; font-weight: 700; }
.section-note { color: #85887f; font: 10px var(--mono); font-weight: 400; }
.field-row { display: grid; grid-template-columns: minmax(165px, 220px) minmax(0, 1fr); gap: 18px; align-items: start; padding: 9px 0; border-top: 1px solid #efeee9; }
.field-row:first-of-type { border-top: 0; }
.field-label { padding-top: 7px; color: #464b43; font-size: 12px; }
.field-help { display: block; margin-top: 3px; color: #85887f; font-size: 10px; line-height: 1.4; }
.field-control { min-width: 0; }
.field-control input, .field-control select, .field-control textarea { width: 100%; min-height: 34px; padding: 7px 9px; color: #2e332d; background: #fff; border: 1px solid #cbc9bf; border-radius: 2px; outline: none; font-size: 12px; }
.field-control textarea { min-height: 70px; resize: vertical; line-height: 1.45; }
.field-control input:focus, .field-control select:focus, .field-control textarea:focus { border-color: #788d78; box-shadow: 0 0 0 2px #788d7820; }
.field-control input[type="number"] { font-family: var(--mono); font-size: 11px; }
.field-control .mono-input { font-family: var(--mono); font-size: 11px; }
.field-control select { cursor: pointer; }
.field-key { display: block; margin-top: 4px; color: #92948c; font: 9px var(--mono); }
.check-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.check-group { padding: 15px 16px 13px; background: var(--white); border: 1px solid #dedbd1; border-radius: 3px; }
.check-group h3 { margin: 0 0 12px; color: #353a33; font-size: 12px; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px; row-gap: 1px; }
.check-option { display: flex; align-items: flex-start; gap: 8px; min-height: 32px; padding: 6px 2px; color: #53584f; font-size: 11px; line-height: 1.35; cursor: pointer; }
.check-option input { flex: 0 0 auto; width: 14px; height: 14px; margin: 0; accent-color: var(--green); }
.check-option span { overflow-wrap: anywhere; }
.empty-seed { padding: 22px; color: #73776e; background: var(--white); border: 1px dashed #cbc9bf; font-size: 12px; line-height: 1.6; }
.empty-seed strong { display: block; margin-bottom: 3px; color: #43483f; }
.editor-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 13px; border-top: 1px solid var(--line); color: #777b72; font-size: 11px; }
.toast { position: fixed; right: 24px; bottom: 22px; z-index: 5; max-width: min(420px, calc(100vw - 32px)); padding: 11px 14px; color: #fffefa; background: #303a31; border-left: 3px solid #8ca383; border-radius: 2px; box-shadow: 0 5px 18px #1f241f2a; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .18s, transform .18s; font-size: 12px; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 245px minmax(0, 1fr); }
  .catalog { padding-left: 15px; }
  .editor { padding-inline: 24px; }
  .item-heading { align-items: flex-start; flex-direction: column; }
  .item-badges { justify-content: flex-start; }
  .field-row { grid-template-columns: 150px minmax(0, 1fr); gap: 12px; }
}
@media (max-width: 680px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: 12px; padding: 14px 15px; }
  .topbar-actions { width: 100%; flex-wrap: wrap; gap: 7px; }
  .topbar-actions .button { min-height: 44px; }
  .api-state { margin-right: auto; }
  .workspace { display: flex; flex-direction: column; min-height: calc(100vh - 115px); }
  .catalog { width: 100%; height: 250px; padding: 14px 14px 9px; border-right: 0; border-bottom: 1px solid #d2cfc4; }
  .catalog-heading { padding-bottom: 10px; }
  .catalog h1 { font-size: 19px; }
  .catalog-meta { min-height: 25px; padding-top: 6px; }
  .catalog-footer { display: none; }
  .item-list { min-height: 70px; }
  .editor { padding: 23px 14px 18px; }
  .editor-empty { margin-top: 32px; }
  .editor-empty h2 { font-size: 38px; }
  .item-heading { min-height: auto; padding-bottom: 15px; }
  .item-heading h2 { font-size: 26px; }
  .tabs { margin-inline: -14px; padding-inline: 10px; }
  .tab { min-height: 40px; padding-inline: 10px; }
  .tab-content { padding-top: 14px; }
  .field-section { padding: 14px 12px 10px; }
  .field-row { grid-template-columns: 1fr; gap: 4px; padding: 8px 0 10px; }
  .field-label { padding-top: 0; }
  .field-control input, .field-control select, .field-control textarea { min-height: 44px; }
  .check-groups { grid-template-columns: 1fr; }
  .check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor-footer { align-items: flex-start; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
