/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0d1117;
  --surface:  #161b22;
  --raised:   #21262d;
  --border:   #30363d;
  --border2:  #3d444d;
  --text:     #e6edf3;
  --text2:    #8b949e;
  --text3:    #656d76;
  --cmd:      #79c0ff;
  --accent:   #58a6ff;
  --green:    #3fb950;
  --yellow:   #e3b341;
  --radius:   8px;
  --header-h: 60px;
  --tab-h:    48px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

/* ── Layout ── */
.app { display: flex; flex-direction: column; height: 100vh; }

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-icon { font-size: 20px; }

.search-wrap {
  flex: 1;
  position: relative;
  max-width: 480px;
}
.search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  pointer-events: none;
}
.search {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  padding: 7px 12px 7px 36px;
  outline: none;
  transition: border-color 0.15s;
}
.search:focus { border-color: var(--accent); }
.search::placeholder { color: var(--text3); }


.header-count {
  font-size: 12px;
  color: var(--text3);
  white-space: nowrap;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  align-items: center;
  height: var(--tab-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  padding: 0 12px;
  gap: 2px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  position: relative;
}
.tab:hover { background: var(--raised); color: var(--text); }
.tab.active {
  background: var(--raised);
  color: var(--text);
  border-color: var(--border2);
}
.tab.active::after {
  content: '';
  position: absolute;
  bottom: -9px;
  left: 12px;
  right: 12px;
  height: 2px;
  background: var(--sheet-accent, var(--accent));
  border-radius: 2px 2px 0 0;
}
.tab-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: block;
}

/* ── Main scroll area ── */
.content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 20px 40px;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}
.content::-webkit-scrollbar { width: 6px; }
.content::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── Sheet ── */
.sheet { display: none; }
.sheet.active { display: block; }

.sheet-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.sheet-title-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}
.sheet-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.sheet-count {
  font-size: 12px;
  color: var(--text3);
}

/* ── Categories ── */
.categories { display: flex; flex-direction: column; gap: 24px; }

.category-name {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text3);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.entries { display: flex; flex-direction: column; gap: 1px; }

/* ── Entry cards ── */
.entry {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.12s, background 0.12s;
  margin-bottom: 4px;
}
.entry:hover { background: var(--raised); border-color: var(--border2); }
.entry.hidden { display: none; }
.entry.match { border-color: var(--sheet-accent, var(--accent)); }

.entry-left { min-width: 0; }

.entry-cmd {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 13px;
  color: var(--cmd);
  white-space: pre;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entry-cmd mark {
  background: rgba(88, 166, 255, 0.25);
  color: #fff;
  border-radius: 2px;
  padding: 0 1px;
}
.entry-desc {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px;
}
.entry-desc mark {
  background: rgba(88, 166, 255, 0.2);
  color: var(--text);
  border-radius: 2px;
  padding: 0 1px;
}

.entry-sheet-badge {
  font-size: 10px;
  color: var(--text3);
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  white-space: nowrap;
}

.copy-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text3);
  font-size: 11px;
  padding: 4px 9px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.copy-btn.copied { border-color: var(--green); color: var(--green); }

/* ── Empty state ── */
.empty-state {
  display: none;
  text-align: center;
  padding: 80px 20px;
  color: var(--text3);
}
.empty-state.visible { display: block; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-title { font-size: 18px; color: var(--text2); margin-bottom: 8px; }

/* ── All-sheets search result view ── */
#sheet-all .category { margin-bottom: 28px; }
#sheet-all .result-sheet-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .header { padding: 0 12px; gap: 10px; }
  .header-count { display: none; }
  .scope-btn span { display: none; }
  .content { padding: 16px 12px 40px; }
  .entry { grid-template-columns: 1fr auto; }
  .entry-sheet-badge { display: none; }
  .entry-cmd { font-size: 12px; }
}
@media (max-width: 400px) {
  .logo span { display: none; }
  .search { font-size: 13px; }
}
