:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 600px; height: 600px; overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { width: 100%; height: 100%; position: relative; }

.screen {
  width: 100%; height: 100%; position: absolute; top: 0; left: 0;
  display: flex; flex-direction: column;
}
.screen.hidden { display: none; }
.hidden { display: none !important; }

.focusable {
  transition: box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  border: 2px solid transparent; cursor: pointer; outline: none;
}
.focusable:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

/* ---- Top bar ---- */
.topbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 14px;
  padding: 18px 20px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--bg-tertiary);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  flex: 0 0 auto;
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 20px; font-weight: 700;
  color: #001016; background: var(--accent);
  border-radius: var(--radius-md);
}
.brand-text h1 { font-size: 26px; font-weight: 700; line-height: 1.1; }
.brand-text p { font-size: 15px; color: var(--text-secondary); margin-top: 2px; }

.back {
  flex: 0 0 auto;
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; line-height: 1;
  color: var(--text-primary); background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}
#catTitle { font-size: 24px; font-weight: 700; }

/* ---- Scroll region ---- */
.scroll {
  flex: 1 1 auto; overflow-y: auto;
  padding: 16px 20px 24px;
  display: flex; flex-direction: column; gap: 12px;
  scrollbar-width: none;
}
.scroll::-webkit-scrollbar { width: 0; height: 0; }

/* ---- Category cards (home) ---- */
.cat-card {
  display: flex; align-items: center; gap: 16px;
  min-height: 76px; padding: 14px 18px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}
.cat-card .badge {
  flex: 0 0 auto;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 19px; font-weight: 700;
  color: var(--accent-secondary); background: var(--bg-tertiary);
  border-radius: 10px;
}
.cat-card .cat-body { flex: 1 1 auto; min-width: 0; }
.cat-card .cat-name { font-size: 19px; font-weight: 600; }
.cat-card .cat-meta { font-size: 14px; color: var(--text-secondary); margin-top: 2px; }
.cat-card .chev { flex: 0 0 auto; color: var(--text-muted); font-size: 22px; }
.cat-card .pill {
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
  color: #001016; background: var(--accent);
  padding: 3px 8px; border-radius: 999px; margin-left: 8px;
}
.cat-card .seen { color: var(--accent-secondary); }

/* ---- Syntax items (detail) ---- */
.item {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.item-label {
  font-size: 16px; font-weight: 700; color: var(--text-primary);
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.item-label .copy-tag {
  margin-left: auto; font-size: 12px; font-weight: 600;
  color: var(--text-muted);
}
.item-syntax {
  background: var(--bg-tertiary);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.item-syntax::-webkit-scrollbar { width: 0; height: 0; }
.item-syntax pre {
  font-family: var(--mono); font-size: 15px; line-height: 1.5;
  color: var(--accent-secondary);
  white-space: pre; tab-size: 2;
}
.item-preview {
  margin-top: 10px; padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--bg-tertiary);
  border-radius: 8px;
  font-size: 15px; line-height: 1.45; color: var(--text-primary);
}
.preview-tag {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px;
}

/* preview rendered markdown styling */
.item-preview h1, .item-preview h2, .item-preview h3,
.item-preview h4, .item-preview h5, .item-preview h6 {
  line-height: 1.2; margin: 2px 0;
}
.item-preview h1 { font-size: 24px; }
.item-preview h2 { font-size: 21px; }
.item-preview h3 { font-size: 18px; }
.item-preview h4 { font-size: 16px; }
.item-preview h5 { font-size: 14px; }
.item-preview h6 { font-size: 13px; color: var(--text-secondary); }
.item-preview p { margin: 3px 0; }
.item-preview code {
  font-family: var(--mono); font-size: 13px;
  background: var(--bg-tertiary); color: var(--accent-secondary);
  padding: 2px 5px; border-radius: 5px;
}
.item-preview pre {
  font-family: var(--mono); font-size: 13px; line-height: 1.4;
  background: var(--bg-tertiary); color: var(--text-primary);
  padding: 8px 10px; border-radius: 6px; white-space: pre; overflow-x: auto;
}
.item-preview pre code { background: none; padding: 0; color: inherit; }
.item-preview ul, .item-preview ol { padding-left: 22px; margin: 2px 0; }
.item-preview li { margin: 2px 0; }
.item-preview a { color: var(--accent); text-decoration: underline; }
.item-preview blockquote {
  border-left: 3px solid var(--text-muted);
  padding-left: 12px; margin: 3px 0; color: var(--text-secondary);
}
.item-preview blockquote blockquote {
  border-left-color: var(--accent); margin-top: 4px;
}
.item-preview hr {
  border: none; border-top: 2px solid var(--text-muted); margin: 8px 0;
}
.item-preview table { border-collapse: collapse; width: 100%; font-size: 13px; }
.item-preview th, .item-preview td {
  border: 1px solid var(--bg-tertiary); padding: 5px 8px; text-align: left;
}
.item-preview th { background: var(--bg-tertiary); }
.item-preview del { color: var(--text-muted); }
.item-preview .task { list-style: none; }
.item-preview .task input { margin-right: 6px; }
.item-preview sup, .item-preview sub { font-size: 11px; }
.item-preview .fn { color: var(--accent); vertical-align: super; font-size: 11px; }

/* ---- Footer hint ---- */
.hint {
  flex: 0 0 auto;
  display: flex; gap: 20px; justify-content: center;
  padding: 12px; font-size: 14px; color: var(--text-secondary);
  background: var(--bg-primary);
  border-top: 1px solid var(--bg-tertiary);
}

/* ---- Toast ---- */
.toast {
  position: absolute; left: 50%; bottom: 70px; transform: translateX(-50%) translateY(8px);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 15px; font-weight: 600;
  padding: 12px 22px; border-radius: 999px;
  border: 1px solid var(--accent);
  box-shadow: 0 0 24px var(--focus-glow);
  opacity: 0; transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast .tk { color: var(--accent-secondary); margin-right: 8px; }
