@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap; src: url(/fonts/jetbrains-mono-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-display: swap; src: url(/fonts/jetbrains-mono-latin-500-normal.woff2) format("woff2"); }

:root {
  --paper: #F3F5F7; --ink: #1F2A37; --muted: #5B6675; --cobalt: #2F5BEA; --teal: #1F9D8B; --teal-strong: #0F7A6B; --on-teal: #FFFFFF; --rust: #C2410C;
  --code-bg: #FFFFFF; --border: #D7DDE5; --surface: #FFFFFF; --on-cobalt: #FFFFFF;
  --tok-keyword: #7A3E9D; --tok-string: #0B7A4B; --tok-number: #B45309; --tok-comment: #6B7686; --tok-title: #1D4ED8;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, Segoe UI, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141A24; --ink: #E6EAF0; --muted: #A3AEBD; --cobalt: #7C9CFF; --teal: #4CC9B5; --teal-strong: #4CC9B5; --on-teal: #0B1F1C; --rust: #FB923C;
    --code-bg: #1B2330; --border: #2B3547; --surface: #1B2330; --on-cobalt: #0E1420;
    --tok-keyword: #C4A1F0; --tok-string: #7FD6A8; --tok-number: #F5B26B; --tok-comment: #8C98AB; --tok-title: #8FB0FF;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 400 16px/1.5 var(--sans); }
a { color: var(--cobalt); }
:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; }
button, .btn, input, select, textarea { font: inherit; color: inherit; }
button, .btn { min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--ink); }
.btn-primary { background: var(--cobalt); border-color: var(--cobalt); color: var(--on-cobalt); font-weight: 600; }
.btn-danger { color: var(--rust); border-color: var(--rust); }
input, select, textarea { min-height: 44px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); width: 100%; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 8px 16px; min-height: 52px; border-bottom: 1px solid var(--border); background: var(--surface); }
.brand { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 600; color: var(--ink); text-decoration: none; }
.brand img { display: block; width: 28px; height: 28px; }
.topnav { margin-left: auto; display: flex; gap: 16px; }
.topnav a { display: inline-flex; align-items: center; min-height: 44px; }
.sync-status { font-size: 14px; color: var(--muted); }

#layout { display: block; }
.gate { max-width: 420px; margin: 48px auto; padding: 0 16px; }
.gate h1 { font-size: 24px; margin: 0 0 8px; }
body[data-mode="app"] #gate { display: none; }
body:not([data-mode="app"]) #layout, body:not([data-mode="app"]) #fab, body:not([data-mode="app"]) #sync-status, body:not([data-mode="app"]) #nav-settings { display: none !important; }
#list-pane, #detail-pane { padding: 16px; max-width: 860px; margin: 0 auto; }
#layout[data-view="list"] #detail-pane { display: none; }
#layout[data-view="detail"] #list-pane { display: none; }
.searchbar { position: sticky; top: 0; background: var(--paper); padding-bottom: 8px; z-index: 1; }
#filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
#filters select { width: auto; }
.chip { min-height: 44px; padding: 0 12px; border-radius: 22px; }
.chip[aria-pressed="true"] { background: var(--cobalt); color: var(--on-cobalt); border-color: var(--cobalt); }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.row { display: block; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; text-decoration: none; color: var(--ink); }
.row[aria-current="true"] { border-color: var(--cobalt); box-shadow: inset 3px 0 0 var(--cobalt); }
.row-head { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
.row-title { font-weight: 600; overflow-wrap: anywhere; }
.lang { font-size: 13px; color: var(--cobalt); font-weight: 500; }
.preview { margin: 8px 0 0; font: 400 13px/1.5 var(--mono); white-space: pre; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { font-size: 13px; color: var(--muted); }
.tag::before { content: "#"; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty .btn { margin-top: 12px; }

.fab { position: fixed; right: 16px; bottom: 16px; min-height: 52px; padding: 0 24px; border-radius: 26px; background: var(--cobalt); color: var(--on-cobalt); font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; box-shadow: 0 4px 12px rgba(0,0,0,.25); }

.detail-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.detail-head h1 { font-size: 22px; margin: 0; flex: 1 1 100%; overflow-wrap: anywhere; }
.codeblock { position: relative; background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; margin: 12px 0; overflow: hidden; }
.codeblock-body { display: grid; grid-template-columns: auto 1fr; overflow-x: auto; padding: 20px 0; }
.gutter { padding: 0 12px 0 20px; text-align: right; color: var(--muted); font: 400 14px/1.55 var(--mono); user-select: none; border-right: 1px solid var(--border); white-space: pre; }
.codeblock code { display: block; padding: 0 20px; font: 400 14px/1.55 var(--mono); white-space: pre; }
.copy-btn { position: absolute; top: 8px; right: 8px; min-height: 44px; z-index: 1; }
.copy-btn.copied { background: var(--teal-strong); border-color: var(--teal-strong); color: var(--on-teal); }
.notes { white-space: pre-wrap; max-width: 76ch; }
.meta { color: var(--muted); font-size: 14px; }

.hljs-keyword, .hljs-built_in, .hljs-literal { color: var(--tok-keyword); }
.hljs-string, .hljs-regexp, .hljs-attr, .hljs-symbol { color: var(--tok-string); }
.hljs-number, .hljs-meta { color: var(--tok-number); }
.hljs-comment, .hljs-quote { color: var(--tok-comment); font-style: italic; }
.hljs-title, .hljs-section, .hljs-name, .hljs-tag { color: var(--tok-title); }

.editor { display: grid; gap: 12px; }
.editor label { display: grid; gap: 4px; font-weight: 500; }
.editor textarea.code-input { font: 400 14px/1.55 var(--mono); min-height: 240px; resize: vertical; tab-size: 2; white-space: pre; }
.taglist { display: flex; flex-wrap: wrap; gap: 6px; }
.tagchip { display: inline-flex; align-items: center; gap: 4px; padding: 0 4px 0 12px; min-height: 44px; border: 1px solid var(--border); border-radius: 22px; background: var(--surface); }
.tagchip button { min-height: 44px; min-width: 44px; padding: 0; border: 0; background: none; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.settings section { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.settings h2 { margin: 0 0 8px; font-size: 18px; }
.form-row { display: grid; gap: 8px; max-width: 360px; margin: 8px 0; }

#toasts { position: fixed; left: 16px; right: 16px; bottom: 80px; display: grid; gap: 8px; justify-items: center; pointer-events: none; z-index: 10; }
.toast { pointer-events: auto; display: flex; gap: 12px; align-items: center; padding: 8px 8px 8px 16px; background: var(--ink); color: var(--paper); border-radius: 10px; max-width: 480px; }
.toast button { background: transparent; color: inherit; border-color: currentColor; }

@media (min-width: 900px) {
  #layout { display: grid; grid-template-columns: 360px 1fr; height: calc(100vh - 52px); }
  #layout[data-view] #list-pane, #layout[data-view] #detail-pane { display: block; }
  #list-pane { overflow-y: auto; border-right: 1px solid var(--border); margin: 0; max-width: none; }
  #detail-pane { overflow-y: auto; margin: 0; max-width: none; width: 100%; }
  #detail-pane > * { max-width: 860px; }
  .fab { display: none; }
  #toasts { bottom: 24px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

.toast :focus-visible { outline-color: var(--paper); }
