:root[data-theme="light"] {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;

  --c1: #ea580c;
  --c2: #0891b2;
  --c3: #7c3aed;
  --c4: #059669;
  --c5: #e11d48;
  --c6: #d97706;
  --c7: #2563eb;
  --c8: #c026d3;

  --text-strong: #0f172a;
  --tag-bg: rgba(0, 0, 0, 0.04);
  --tag-hover-bg: rgba(0, 0, 0, 0.08);
  --lens-bg: #f1f5f9;
  --footer-text: #94a3b8;
  --modal-select-bg: #f1f5f9;
}

:root {
  --bg: #0e0f11;
  --surface: #16181c;
  --border: #2a2d34;
  --text: #e8eaf0;
  --muted: #6b7280;

  --c1: #f97316;
  /* DDD – orange */
  --c2: #22d3ee;
  /* High-Load – cyan */
  --c3: #a78bfa;
  /* Event Sourcing – violet */
  --c4: #34d399;
  /* Architecture – green */
  --c5: #fb7185;
  /* Testing – rose */
  --c6: #fbbf24;
  /* Soft Skills – amber */
  --c7: #60a5fa;
  /* Ownership – blue */
  --c8: #e879f9;
  /* Pressure – fuchsia */

  --col-w: 320px;
  --gap: 18px;

  --text-strong: #fff;
  --tag-bg: rgba(255, 255, 255, 0.04);
  --tag-hover-bg: rgba(255, 255, 255, 0.08);
  --lens-bg: #1a1c21;
  --footer-text: #5a5e6a;
  --modal-select-bg: #1a1c21;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 12.5px;
  line-height: 1.65;
  min-height: 100vh;
  padding: 40px 32px 60px;
}

header {
  margin-bottom: 36px;
  border-left: 3px solid var(--c1);
  padding-left: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-right: 0;
}

header h1 {
  font-family: 'Syne', sans-serif;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-strong);
  line-height: 1.15;
}

header p {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lens {
  display: inline-block;
  margin-top: 12px;
  background: var(--lens-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.lens span {
  color: var(--text-strong);
  font-weight: 500;
}

.grid {
  position: relative;
  width: 100%;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 20px 18px;
  position: absolute;
  overflow: hidden;
  width: var(--col-w);
  transition: top 0.25s ease, left 0.25s ease;
  cursor: grab;
  user-select: none;
}

.card:active:not(.resizing) {
  cursor: grabbing;
}

.card.resizing {
  cursor: ew-resize;
  transition: none;
}


.card.no-transition {
  transition: none;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
}

/* Resize handle indicator on right edge */
.card::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 2px;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  border-radius: 2px;
  background: var(--border);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.card:hover::after {
  opacity: 1;
}

.card h2 {
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tag {
  background: var(--tag-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 9px;
  font-size: 11.5px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.tag:hover {
  background: var(--tag-hover-bg);
  border-color: var(--accent);
  color: var(--text-strong);
}

.tag:focus-visible {
  outline: 2px solid var(--accent, var(--c1));
  outline-offset: 2px;
}

.tag.strong {
  color: var(--text-strong);
  font-weight: 500;
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.tag.strong:hover {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

/* per-category accent */
.c1 {
  --accent: var(--c1);
}

.c2 {
  --accent: var(--c2);
}

.c3 {
  --accent: var(--c3);
}

.c4 {
  --accent: var(--c4);
}

.c5 {
  --accent: var(--c5);
}

.c6 {
  --accent: var(--c6);
}

.c7 {
  --accent: var(--c7);
}

.c8 {
  --accent: var(--c8);
}


.db-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media (max-width: 700px) {
  .db-grid {
    grid-template-columns: 1fr;
  }
}

.db-section h3 {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

footer {
  margin-top: 36px;
  font-size: 10px;
  color: var(--footer-text);
  text-align: center;
  letter-spacing: 0.06em;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 20px;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: 600px;
  padding: 24px;
  position: relative;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(20px);
  transition: transform 0.2s;
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}

/* Chat modal uses the default modal base width */

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 24px;
  cursor: pointer;
  color: var(--muted);
  background: none;
  border: none;
}

.modal-close:hover {
  color: var(--text-strong);
}

.modal-close:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 2px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}

.modal-title {
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-strong);
}

.modal-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.modal-select {
  background: var(--modal-select-bg);
  border: 1px solid var(--border);
  color: var(--text-strong);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-family: 'DM Mono', monospace;
  cursor: pointer;
  outline: none;
}

.modal-btn {
  background: var(--c1);
  color: #000;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  font-family: 'DM Mono', monospace;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.modal-btn:hover {
  opacity: 0.8;
}

.modal-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.modal-body {
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.6;
  padding-right: 10px;
}

.modal-body p,
.modal-body ul,
.modal-body ol,
.modal-body table,
.modal-body pre {
  margin-bottom: 14px;
}

.modal-body h1,
.modal-body h2,
.modal-body h3,
.modal-body h4 {
  font-family: 'Syne', sans-serif;
  color: var(--text-strong);
  margin-top: 24px;
  margin-bottom: 10px;
}

.modal-body h1 {
  font-size: 18px;
}

.modal-body h2 {
  font-size: 16px;
}

.modal-body h3 {
  font-size: 14px;
}

.modal-body ul,
.modal-body ol {
  margin-left: 24px;
}

.modal-body li {
  margin-bottom: 6px;
}

.modal-body code {
  font-family: 'DM Mono', monospace;
  background: var(--tag-bg);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--c1);
}

.modal-body pre {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
}

.modal-body pre code {
  background: transparent;
  padding: 0;
  color: var(--text);
}

.modal-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.modal-body th,
.modal-body td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.modal-body th {
  background: var(--lens-bg);
  color: var(--text-strong);
  font-weight: 600;
}

.modal-body blockquote {
  border-left: 3px solid var(--c1);
  padding-left: 14px;
  color: var(--muted);
  margin-left: 0;
  font-style: italic;
}

.loader {
  display: none;
  width: 24px;
  height: 24px;
  border: 2px solid var(--muted);
  border-bottom-color: var(--c1);
  border-radius: 50%;
  animation: rotation 1s linear infinite;
  margin: 20px auto;
}

@keyframes rotation {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.theme-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.theme-toggle:hover {
  background: var(--tag-hover-bg);
  color: var(--text-strong);
}

.sortable-ghost {
  opacity: 0.4;
}

.card:active:not(.resizing) {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Chat Input Area */
.chat-input-area {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

#chatInput {
  flex-grow: 1;
  background: var(--modal-select-bg);
  border: 1px solid var(--border);
  color: var(--text-strong);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

#chatInput:focus {
  border-color: var(--c1);
}

/* Chat History elements */
.chat-history {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-message {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.5;
  width: fit-content;
  max-width: 90%;
}

.chat-message.user {
  background: color-mix(in srgb, var(--c1) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--c1) 30%, transparent);
  align-self: flex-end;
  color: var(--text-strong);
  border-bottom-right-radius: 2px;
}

.chat-message.ai {
  background: var(--tag-bg);
  border: 1px solid var(--border);
  align-self: flex-start;
  color: var(--text);
  border-bottom-left-radius: 2px;
}

.chat-message.ai p:last-child {
  margin-bottom: 0;
}

/* Boss Key Styles */
#bossScreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #ffffff;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: arial, sans-serif;
  color: #202124;
}

[data-theme="dark"] #bossScreen {
  background: #202124;
  color: #e8eaed;
}

.boss-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: -10vh;
  width: 100%;
}

.boss-logo {
  font-size: 88px;
  font-weight: 500;
  letter-spacing: -3px;
  margin-bottom: 25px;
  user-select: none;
  font-family: 'Product Sans', sans-serif;
}

.boss-search {
  width: 100%;
  max-width: 584px;
  margin-bottom: 30px;
  position: relative;
  display: flex;
  align-items: center;
}

.boss-search .search-icon {
  position: absolute;
  left: 14px;
  width: 20px;
  height: 20px;
  fill: #9aa0a6;
}

.boss-search input {
  width: 100%;
  padding: 12px 20px 12px 40px;
  font-size: 16px;
  border: 1px solid #dfe1e5;
  border-radius: 24px;
  outline: none;
  background: transparent;
  color: inherit;
}

.boss-search input:hover,
.boss-search input:focus {
  box-shadow: 0 1px 6px rgba(32, 33, 36, .28);
  border-color: rgba(223, 225, 229, 0);
}

[data-theme="dark"] .boss-search input {
  border-color: #5f6368;
}

[data-theme="dark"] .boss-search input:focus,
[data-theme="dark"] .boss-search input:hover {
  box-shadow: 0 1px 6px rgba(23, 23, 23, 0.9);
  background: #303134;
  border-color: #303134;
}

.boss-buttons {
  display: flex;
  gap: 12px;
}

.boss-buttons button {
  background-color: #f8f9fa;
  border: 1px solid #f8f9fa;
  border-radius: 4px;
  color: #3c4043;
  font-family: inherit;
  font-size: 14px;
  margin: 11px 4px;
  padding: 0 16px;
  line-height: 27px;
  height: 36px;
  min-width: 54px;
  text-align: center;
  cursor: pointer;
  user-select: none;
}

.boss-buttons button:hover {
  box-shadow: 0 1px 1px rgba(0, 0, 0, .1);
  background-color: #f8f9fa;
  border: 1px solid #dadce0;
  color: #202124;
}

[data-theme="dark"] .boss-buttons button {
  background-color: #303134;
  border: 1px solid #303134;
  color: #e8eaed;
}

[data-theme="dark"] .boss-buttons button:hover {
  background-color: #444746;
  border: 1px solid #444746;
}

/* Focus-visible for toolbar buttons */
.theme-toggle:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .card,
  .modal,
  .modal-overlay,
  .tag,
  .theme-toggle,
  .modal-close {
    transition: none !important;
  }
}

/* Responsive: mobile single column */
@media (max-width: 700px) {
  body {
    padding: 20px 12px 40px;
  }

  header {
    flex-direction: column;
    gap: 12px;
  }

  header h1 {
    font-size: 20px;
  }

  .card {
    position: relative !important;
    width: 100% !important;
    left: auto !important;
    top: auto !important;
  }

  .grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
    height: auto !important;
  }
}

/* Print stylesheet */
@media print {
  body {
    background: #fff !important;
    color: #1e293b !important;
    padding: 10px;
    font-size: 11px;
  }

  header {
    border-left-color: #e2e8f0;
  }

  header h1 {
    color: #0f172a;
    font-size: 20px;
  }

  .theme-toggle,
  #bossScreen,
  #undoSequenceBtn,
  .modal-overlay,
  footer {
    display: none !important;
  }

  .card {
    background: #fff !important;
    border: 1px solid #d1d5db !important;
    break-inside: avoid;
    page-break-inside: avoid;
    position: relative !important;
    left: auto !important;
    top: auto !important;
    width: auto !important;
  }

  .grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    height: auto !important;
  }

  .card h2 {
    color: var(--accent) !important;
  }

  .tag {
    border-color: #d1d5db !important;
    background: #f9fafb !important;
    color: #1e293b !important;
  }

  .tag.strong {
    border-color: #9ca3af !important;
    font-weight: 600;
  }

  .lens {
    background: #f1f5f9;
    border-color: #e2e8f0;
  }
}