:root {
  --bg: #faf9f7;
  --bg-secondary: #f5f3ef;
  --panel: #ffffff;
  --panel-hover: #fefdfb;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --accent: #d97706;
  --accent-bg: #fef3c7;
  --green: #16a34a;
  --red: #dc2626;
  --gold: #ca8a04;
}

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

html { scroll-behavior: smooth; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d6d3d1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a8a29e; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

button, input { font: inherit; }
a { color: inherit; }

.app-shell {
  min-height: 100vh;
  padding: 16px;
}

.workspace {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 32px);
  max-width: 1400px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  overflow: hidden;
}

.main-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar {
  padding: 20px 16px;
  border-right: 1px solid var(--line);
  background: var(--bg-secondary);
}

.content-area {
  min-width: 0;
  padding: 24px 28px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
}

.brand h1 { font-size: 15px; font-weight: 700; }

.brand p {
  margin: 2px 0 0;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.mode-switcher {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  padding: 3px;
  background: var(--line);
  border-radius: 8px;
}

.mode-btn {
  flex: 1;
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mode-btn:hover { color: var(--ink); }

.mode-btn.active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.mode-switcher {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 0;
  padding: 3px;
  background: var(--line);
  border-radius: 8px;
}

.search-inline {
  display: flex;
  gap: 6px;
  align-items: center;
}

.search-inline input {
  width: 200px;
  min-height: 32px;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--panel);
  color: var(--ink);
}

.search-inline input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-inline button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  transition: border-color 0.15s ease;
}

input:focus { outline: none; border-color: var(--accent); }
input::placeholder { color: #a8a29e; }

button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  transition: opacity 0.15s ease;
}

button:hover { opacity: 0.85; }
button:disabled { opacity: 0.4; cursor: progress; }

.nav-stack { display: grid; gap: 2px; }

.nav-stack a {
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.1s ease;
}

.nav-stack a:hover { background: var(--line); color: var(--ink); }

.view-panel { display: none; }
.view-panel.active { display: block; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 2px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
}

.topbar h2 { font-size: 20px; font-weight: 700; }

.actions { display: flex; gap: 6px; }

.actions button:first-child {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
}

.actions button:first-child:hover { background: var(--bg-secondary); }

.btn-analyze {
  background: var(--accent) !important;
  color: #fff !important;
}

.btn-copy {
  background: var(--panel) !important;
  color: var(--ink) !important;
  border: 1px solid var(--line) !important;
}

.btn-copy:hover { background: var(--bg-secondary) !important; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  text-align: center;
}

.empty-icon {
  width: 56px;
  height: 56px;
  margin-bottom: 16px;
  border-radius: 14px;
  background: var(--accent-bg);
  display: grid;
  place-items: center;
  font-size: 24px;
}

.empty-state h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.empty-state p { color: var(--muted); font-size: 13px; max-width: 300px; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.metric {
  padding: 16px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.metric span {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
}

.metric-text { font-size: 13px !important; line-height: 1.4; }

.panel {
  padding: 18px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  margin-bottom: 12px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-heading h3 { font-size: 13px; font-weight: 600; }

.panel-heading span {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--muted);
}

.insight-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.summary-panel p { line-height: 1.8; font-size: 13px; }

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.tag-cloud span {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 4px;
  background: var(--accent-bg);
  color: var(--accent);
}

.pain-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pain-list li {
  padding: 10px 12px;
  border-radius: 6px;
  background: #fef2f2;
  border-left: 2px solid var(--red);
  font-size: 12px;
  line-height: 1.6;
}

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th, td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

td a { color: var(--ink); font-weight: 500; text-decoration: none; }
td a:hover { color: var(--accent); }

td:nth-child(2),
td:nth-child(3) {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 13px;
}

.opportunity {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.opportunity.high { background: var(--accent-bg); color: var(--gold); }
.opportunity.medium { background: #f0fdf4; color: var(--green); }
.opportunity.low { background: var(--bg-secondary); color: var(--muted); }

.idea-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.idea-card {
  padding: 16px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  transition: background 0.15s ease;
}

.idea-card:hover { background: var(--panel-hover); }

.idea-card span {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: #f0fdf4;
  color: var(--green);
}

.idea-card h4 {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

.idea-card p {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
}

.hot-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.hot-filter-row { display: flex; gap: 6px; }

.hot-filter-row input {
  width: 180px;
  min-height: 32px;
  font-size: 12px;
}

.hot-filter-row button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

.col-rank { width: 50px; text-align: center; }

.hot-rank {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.hot-rank.top-3 {
  background: var(--accent);
  color: #fff;
}

.hot-title a { color: var(--ink); font-weight: 500; text-decoration: none; }
.hot-title a:hover { color: var(--accent); }

.hot-title .hot-excerpt {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 500px;
}

.export-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.export-panel h3 { font-size: 13px; font-weight: 600; }
.export-panel p { margin: 2px 0 0; font-size: 11px; color: var(--muted); }

.repo-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 14px;
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--line);
  transition: background 0.15s ease;
}

.repo-link:hover { background: var(--line); }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  transform: translateY(10px);
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 100;
}

.toast.is-visible { transform: translateY(0); opacity: 1; }

.reveal-section {
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.35s ease;
}

.reveal-section.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .app-shell { padding: 0; }

  .workspace {
    grid-template-columns: 1fr;
    min-height: 100vh;
    border-radius: 0;
    border: 0;
  }

  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }

  .content-area { max-height: none; padding: 20px; }

  .metric-grid, .insight-layout, .idea-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .sidebar, .content-area { padding: 14px; }

  .topbar, .export-panel { flex-direction: column; align-items: stretch; }

  .actions { display: grid; grid-template-columns: 1fr 1fr; }

  .input-row { grid-template-columns: 1fr; }

  .metric-grid, .insight-layout, .idea-grid { grid-template-columns: 1fr; }

  .topbar h2 { font-size: 18px; }

  .hot-controls { flex-direction: column; align-items: flex-start; }
  .hot-filter-row { width: 100%; }
  .hot-filter-row input { flex: 1; width: auto; }
  .hot-title .hot-excerpt { max-width: 180px; }
}
