:root {
  /* Colors - Light Mode (Humane Retro) */
  --bg-color: #f7f5f0;
  --bg-tier-2: #f0ede4;
  /* Subtly darker for sections */
  --text-color: #2a2a2a;
  --text-muted: #8c8c8c;
  --accent-color: #555555;
  /* Monochrome accent */
  --focus-bg: #2a2a2a;
  /* Reverse video background */
  --focus-text: #f7f5f0;
  /* Reverse video text */
  --border-color: #d1cfc8;
  --header-rule: #d1cfc8;

  /* Typography */
  --font-mono: 'Fira Code', 'Courier Prime', 'Courier New', monospace;
  --font-size-base: 14px;
  --line-height: 1.4;
}

[data-theme="dark"] {
  /* Colors - Dark Mode (TRS-80 Dark) */
  --bg-color: #1a1c1e;
  --bg-tier-2: #232629;
  /* Extra tier for hierarchy */
  --text-color: #e0e0e0;
  /* Off-white phosphor */
  --text-muted: #a3a3a3;
  --accent-color: #c0c0c0;
  --focus-bg: #2b2f33;
  /* Reverse video background */
  --focus-text: #eaeaea;
  /* Reverse video text */
  --border-color: #31363a;
  --header-rule: #3a4046;
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-mono);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  padding: 1.5rem;
  max-width: 1300px;
  margin: 0 auto;
}

header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--header-rule);
}

header h1 {
  font-size: 1.4rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 500;
}

header p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Header Controls */
.header-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 2px 8px;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.1s;
}

.header-btn:hover {
  background: var(--text-color);
  color: var(--bg-color);
}

/* Pins Section */
#pins-section {
  margin-bottom: 2.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-tier-2);
  border: 1px solid var(--border-color);
  border-radius: 2px;
}

#pins-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.section-label {
  font-size: 0.7rem;
  font-weight: bold;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
  display: block;
}

/* Grid Layout */
#dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 2.5rem 2rem;
}

.category-block h2 {
  font-size: 0.8rem;
  font-weight: 600;
  padding-bottom: 4px;
  margin-bottom: 1rem;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-color);
  display: block;
  letter-spacing: 0.5px;
  /* Removed background and color overrides to allow calm light mode */
  background: none;
  color: inherit;
}

.link-list {
  list-style: none;
}

.link-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.2rem 0.4rem;
  margin-left: -0.4rem;
  border-radius: 1px;
  cursor: pointer;
  transition: background 0.05s;
}

/* Hover & Focus (Reverse Video) */
.link-item:hover,
.link-item.focused {
  background: var(--focus-bg);
  color: var(--focus-text);
}

.link-item:active {
  background: var(--bg-tier-2);
  color: var(--text-color);
  transition: none;
  /* Instant feedback */
}

.link-content {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
  flex-grow: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-item img {
  width: 16px;
  height: 16px;
  margin-right: 10px;
  filter: grayscale(100%) opacity(0.7);
  transition: filter 0.1s;
}

/* Reverse video icon handling */
.link-item:hover img,
.link-item.focused img {
  filter: grayscale(100%) invert(1) brightness(2);
}

[data-theme="dark"] .link-item:hover img,
[data-theme="dark"] .link-item.focused img {
  filter: grayscale(100%) brightness(0.2);
}

/* Star/Pin Icon */
.pin-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 4px;
  color: var(--text-muted);
  font-size: 0.75rem;
  opacity: 0.4;
  transition: opacity 0.1s, color 0.1s;
}

.link-item:hover .pin-btn,
.link-item.focused .pin-btn {
  opacity: 1;
  color: var(--focus-text);
}

.pin-btn.active {
  opacity: 1 !important;
  color: var(--text-color);
}

.link-item.focused .pin-btn.active {
  color: var(--focus-text);
}

/* Pins shelf chips */
.pin-chip {
  display: flex;
  align-items: center;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  padding: 1px 10px;
  font-size: 0.8rem;
  text-decoration: none;
  color: inherit;
  transition: all 0.1s;
}

.pin-chip:hover {
  background: var(--text-color);
  color: var(--bg-color);
}

.pin-chip img {
  width: 14px;
  height: 14px;
  margin-right: 8px;
  filter: grayscale(100%) opacity(0.7);
}

.pin-chip:hover img {
  filter: grayscale(100%) invert(1);
}

/* Accessibility */
:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* Mobile */
@media (max-width: 600px) {
  #dashboard-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  body {
    padding: 1rem;
  }
}