:root {
  --sidebar-width: 220px;
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-light: #818cf8;
  --border: rgba(255, 255, 255, 0.08);
  --success: #22c55e;
  --error: #ef4444;
  --warning: #64748b;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: hidden;
}

/* Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-dark);
  border-right: 1px solid var(--border);
  position: fixed;
  height: 100vh;
  padding: 1.5rem 0;
  z-index: 100;
}

.sidebar-brand,
.sidebar-logo {
  padding: 0 1.5rem 2rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item {
  padding: 0.75rem 1.5rem;
  text-decoration: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
  color: var(--accent);
  background: rgba(56, 189, 248, 0.1);
  border-left-color: var(--accent);
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 2rem;
  min-width: 0; /* Fix for flex items with overflow */
}

/* Hero Section */
.hero {
  padding: 4rem 0;
  text-align: center;
}

.gradient-text {
  font-size: 3.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 1rem;
}

.subtitle {
  font-size: 1.25rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  background: rgba(34, 197, 94, 0.1);
  color: var(--success);
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
}

/* Grid & Cards */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  align-items: start;
  margin-top: 2rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.card-icon {
  font-size: 1.5rem;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.card-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.card-summary {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.detail-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.8rem;
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
  color: var(--accent);
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.detail-btn:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent);
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.5rem;
}

/* Expandable Card */
.card-detail {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.card.expanded .card-detail {
  max-height: 1000px; /* Large enough to accommodate content */
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.detail-content {
font-size: 0.9rem;
color: var(--text-muted);
}

/* ============== Detail Modal ============== */
.modal-overlay {
display: none;
position: fixed;
inset: 0;
background: rgba(15, 23, 42, 0.85);
backdrop-filter: blur(4px);
z-index: 1000;
justify-content: center;
align-items: center;
}
.modal-overlay.active {
display: flex;
}

.modal-wrapper {
position: relative;
width: 88%;
max-width: 1100px;
height: 88vh;
max-height: 90vh;
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: 16px;
display: flex;
flex-direction: column;
overflow: hidden;
box-shadow: 0 25px 50px rgba(0,0,0,0.5);
}

.modal-close-btn {
position: absolute;
top: 1rem;
right: 1rem;
z-index: 1001;
width: 2.2rem;
height: 2.2rem;
border-radius: 50%;
border: none;
background: rgba(255,255,255,0.08);
color: var(--text-muted);
font-size: 1.2rem;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s;
}
.modal-close-btn:hover {
background: rgba(255,255,255,0.15);
color: var(--text-main);
}

.modal-layout {
display: flex;
height: 100%;
overflow: hidden;
}

/* Left nav */
.modal-nav {
width: 200px;
min-width: 200px;
padding: 1.2rem 0;
border-right: 1px solid var(--border);
overflow-y: auto;
background: rgba(0,0,0,0.15);
font-size: 0.85rem;
}
.modal-nav a {
display: block;
padding: 0.35rem 1rem;
color: var(--text-muted);
text-decoration: none;
transition: all 0.15s;
border-left: 2px solid transparent;
}
.modal-nav a:hover {
color: var(--accent);
background: rgba(56,189,248,0.05);
}
.modal-nav a.active {
color: var(--accent);
border-left-color: var(--accent);
background: rgba(56,189,248,0.08);
}
.modal-nav a.h2 {
font-weight: 600;
padding-top: 0.5rem;
}
.modal-nav a.h3 {
padding-left: 1.5rem;
font-size: 0.8rem;
opacity: 0.8;
}

/* Right content area */
.modal-body {
flex: 1;
overflow-y: auto;
padding: 2rem;
}
.modal-body h2 {
font-size: 1.5rem;
color: var(--text-main);
margin: 0 0 0.25rem;
}
.modal-subtitle {
font-size: 0.9rem;
color: var(--text-muted);
margin-bottom: 1.5rem;
}
.modal-content {
line-height: 1.8;
}
.modal-content h3 {
font-size: 1.1rem;
color: var(--text-main);
margin: 1.5rem 0 0.8rem;
padding-bottom: 0.3rem;
border-bottom: 1px solid var(--border);
}
.modal-content h4 {
font-size: 1rem;
color: var(--accent);
margin: 1rem 0 0.5rem;
}
.modal-content table {
width: 100%;
border-collapse: collapse;
font-size: 0.9rem;
margin: 0.5rem 0 1.5rem;
}
.modal-content th {
background: rgba(255,255,255,0.06);
color: var(--accent);
padding: 0.5rem 0.7rem;
text-align: left;
font-weight: 600;
border-bottom: 2px solid var(--border);
}
.modal-content td {
padding: 0.4rem 0.7rem;
border-bottom: 1px solid rgba(255,255,255,0.04);
}
.modal-content code {
background: rgba(244,114,182,0.12);
padding: 0.1rem 0.3rem;
border-radius: 3px;
font-family: 'JetBrains Mono', monospace;
font-size: 0.85em;
color: #f472b6;
}
.modal-content pre {
background: rgba(0,0,0,0.3);
padding: 0.8rem 1rem;
border-radius: 8px;
overflow-x: auto;
font-size: 0.85rem;
border: 1px solid var(--border);
}
.modal-content pre code {
background: none;
padding: 0;
color: inherit;
}

/* Nav highlight on scroll — handled by JS IntersectionObserver */

@media (max-width: 768px) {
.modal-layout { flex-direction: column; }
.modal-nav {
  width: 100%;
  min-width: unset;
  max-height: 120px;
  border-right: none;
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0;
}
.modal-nav a { padding: 0.25rem 0.8rem; }
.modal-close-btn { top: 0.5rem; right: 0.5rem; }
}

/* Markdown-rendered detail tables and code */
.detail-markdown h3 {
  font-size: 1rem;
  color: var(--accent);
  margin: 1.2rem 0 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}
.detail-markdown h4 {
  font-size: 0.9rem;
  color: var(--text-main);
  margin: 0.8rem 0 0.3rem;
}
.detail-markdown table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 0.5rem 0 1rem;
}
.detail-markdown th {
  background: rgba(255,255,255,0.05);
  color: var(--accent);
  padding: 0.4rem 0.6rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
}
.detail-markdown td {
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  vertical-align: top;
}
.detail-markdown code {
  background: rgba(255,255,255,0.08);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-family: 'JetBrains Mono', 'Cascadia Code', monospace;
  font-size: 0.85em;
  color: #f472b6;
}
.detail-markdown ul {
  margin: 0.3rem 0;
  padding-left: 1.2rem;
}
.detail-markdown li {
  margin: 0.2rem 0;
}

.related-skills {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.related-link {
  font-size: 0.75rem;
  color: var(--accent);
  text-decoration: none;
  padding: 0.1rem 0.4rem;
  background: rgba(56, 189, 248, 0.1);
  border-radius: 4px;
}

/* Search & Filters */
.controls {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.search-bar {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 1rem;
}

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

.filter-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 0.4rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}

.filter-tab.active {
  background: var(--accent);
  color: var(--bg-dark);
  border-color: var(--accent);
}

/* Status Indicators */
.status-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.status-dot.green { background-color: var(--success); }
.status-dot.red { background-color: var(--error); }
.status-dot.gray { background-color: var(--warning); }

/* Categories */
.category-section {
  margin-top: 3rem;
}

.category-header {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* ──────────────────────────────────────
   Daily Report specific styles
   ────────────────────────────────────── */

/* Entry header: stars + title + tag on one row */
.entry-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: nowrap;
}

.entry-header .stars {
  flex-shrink: 0;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  color: #fbbf24;
  min-width: 4.5em;
  text-align: right;
}

.entry-header h3 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-header h3 a {
  color: #e2e8f0;
  text-decoration: none;
}

.entry-header h3 a:hover {
  color: #38bdf8;
}

.entry-header .tag {
  flex-shrink: 0;
  background: #2d3748;
  color: #38bdf8;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 3px;
  white-space: nowrap;
  margin-left: auto;
}

/* Summary line below entry header */
.entry-summary {
  margin: 0.25rem 0 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Card-content separator between entries */
.card-content + .card-content {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  margin-top: 0.75rem;
}

.meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
}

.tag {
  background: #2d3748;
  color: #38bdf8;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
}

.source a {
  color: #38bdf8;
  text-decoration: underline;
}

.source a:hover {
  color: #7dd3fc;
}

/* Footer */
footer {
  margin-top: 4rem;
  padding: 2rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  border-top: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    padding: 1rem;
  }
  .sidebar-nav {
    flex-direction: row;
    justify-content: center;
    overflow-x: auto;
  }
  .nav-item {
    padding: 0.5rem 0.75rem;
    border-left: none;
    border-bottom: 2px solid transparent;
  }
  .nav-item.active {
    border-left: none;
    border-bottom-color: var(--accent);
  }
  .main-content {
    margin-left: 0;
    padding: 1rem;
  }
  .gradient-text {
    font-size: 2.5rem;
  }
}
