/* ==========================================================================
   MASTERY.md — App Stylesheet
   Theme system, editor chrome, source view, syntax highlighting, nav tabs,
   status bar, theme switcher. Custom CSS + Tailwind coexistence.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. THEME SYSTEM — CSS Custom Properties
   Light theme is :root default. Dark theme via [data-theme="dark"].
   Inspired by GitHub's light/dark color palette.
   -------------------------------------------------------------------------- */

:root {
  /* Backgrounds */
  --bg-primary: #ffffff;
  --bg-secondary: #f6f8fa;
  --bg-tertiary: #eef1f5;
  --bg-editor: #ffffff;
  --bg-source: #f6f8fa;
  --bg-hover: #f0f3f7;

  /* Text */
  --text-primary: #111827;
  --text-secondary: #374151;
  --text-muted: #4b5563;
  --text-link: #0969da;

  /* Borders */
  --border-primary: #d1d5db;
  --border-subtle: #e5e7eb;

  /* Accents */
  --accent-primary: #4a4ca2;
  --accent-secondary: #0891b2;

  /* Syntax highlighting (source view) */
  --syntax-heading: #1a7f37;
  --syntax-bold: #1f2937;
  --syntax-link: #0550ae;
  --syntax-code: #cf222e;
  --syntax-code-bg: #eff1f3;
  --syntax-blockquote: #57606a;
  --syntax-marker: #0550ae;
  --syntax-table: #57606a;
  --syntax-hr: #d1d5db;

  /* Line numbers */
  --line-number: #a1a9b3;
}

[data-theme="dark"] {
  /* Backgrounds */
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #1c2129;
  --bg-editor: #0d1117;
  --bg-source: #0d1117;
  --bg-hover: #1c2129;

  /* Text */
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --text-link: #58a6ff;

  /* Borders */
  --border-primary: #30363d;
  --border-subtle: #21262d;

  /* Accents */
  --accent-primary: #4a4ca2;
  --accent-secondary: #22d3ee;

  /* Syntax highlighting (source view) */
  --syntax-heading: #7ee787;
  --syntax-bold: #e6edf3;
  --syntax-link: #58a6ff;
  --syntax-code: #ffa198;
  --syntax-code-bg: #1b1f24;
  --syntax-blockquote: #8b949e;
  --syntax-marker: #58a6ff;
  --syntax-table: #6e7681;
  --syntax-hr: #30363d;

  /* Line numbers */
  --line-number: #484f58;
}

/* --------------------------------------------------------------------------
   2. BASE STYLES
   -------------------------------------------------------------------------- */

body {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Source Code Pro', 'Consolas', 'Monaco', monospace;
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text-secondary);
  background-color: var(--bg-primary);
  transition: background-color 0.2s ease, color 0.2s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

a {
  color: var(--text-link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

::selection {
  background-color: var(--accent-primary);
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   3. SITE NAVIGATION — File Tabs
   -------------------------------------------------------------------------- */

.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-primary);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.nav-inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  height: 3.25rem;
}

.nav-brand {
  flex-shrink: 0;
  margin-right: 1rem;
}

.nav-brand a {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

.nav-brand a:hover {
  color: var(--accent-primary);
  text-decoration: none;
}

.nav-tabs {
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex: 1;
}

.nav-tabs::-webkit-scrollbar {
  display: none;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.nav-tab:hover {
  color: var(--text-primary);
  background-color: var(--bg-hover);
  text-decoration: none;
}

.nav-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent-primary);
}

.nav-tab-icon {
  width: 0.9rem;
  height: 0.9rem;
  flex-shrink: 0;
}

svg.lucide {
  display: inline-block !important;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  flex-shrink: 0;
}

.nav-tab-external svg {
  width: 0.9rem;
  height: 0.9rem;
  fill: currentColor;
}

.nav-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  margin-right: 0.75rem;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 0.25rem;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.nav-hamburger:hover {
  color: var(--text-primary);
  background-color: var(--bg-hover);
}

.nav-hamburger svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* --------------------------------------------------------------------------
   OFFCANVAS SIDEBAR — File explorer (tablet / mobile)
   -------------------------------------------------------------------------- */

.sidebar-overlay {
  position: fixed;
  top: 3.25rem;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 55;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.open {
  opacity: 1;
  visibility: visible;
}

.sidebar {
  position: fixed;
  top: 3.25rem;
  left: 0;
  bottom: 0;
  z-index: 60;
  width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-primary);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar-close {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 0.25rem;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.sidebar-close:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.sidebar-close svg {
  width: 1rem;
  height: 1rem;
}

.sidebar-files {
  padding: 0.5rem 0;
  flex: 1;
}

.sidebar-folder {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-folder-icon {
  width: 0.9rem;
  height: 0.9rem;
  flex-shrink: 0;
}

.sidebar-file {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 1rem 0.35rem 2.25rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.sidebar-file:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  text-decoration: none;
}

.sidebar-file.active {
  color: var(--text-primary);
  background: var(--bg-hover);
  border-left: 2px solid var(--accent-primary);
  padding-left: calc(2.25rem - 2px);
}

.sidebar-file-icon {
  width: 0.85rem;
  height: 0.85rem;
  flex-shrink: 0;
}

.sidebar-github-icon {
  width: 0.85rem;
  height: 0.85rem;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   4. EDITOR CHROME
   -------------------------------------------------------------------------- */

.editor {
  max-width: 72rem;
  width: 100%;
  margin: 0 auto;
  border: 1px solid var(--border-primary);
  border-radius: 0.5rem;
  overflow: hidden;
  background: var(--bg-editor);
  animation: fadeIn 0.3s ease-out;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.editor-topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-primary);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.editor-dots {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
}

.dot-red { background-color: #ff5f57; }
.dot-yellow { background-color: #febc2e; }
.dot-green { background-color: #28c840; }

.editor-tab {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
}

.editor-tab-icon {
  width: 0.85rem;
  height: 0.85rem;
  flex-shrink: 0;
}

.editor-tab-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Toggle button — pill with Source / Preview */
.toggle-btn {
  display: inline-flex;
  align-items: center;
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: 9999px;
  padding: 0.15rem;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.toggle-option {
  padding: 0.2rem 0.65rem;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 9999px;
  color: var(--text-muted);
  transition: all 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
}

.toggle-option.active {
  background: var(--accent-primary);
  color: #ffffff;
}

/* Copy source button */
.copy-source-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  background: none;
  border: 1px solid var(--border-primary);
  border-radius: 0.3rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
  position: relative;
}

.copy-source-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-hover);
}

.copy-source-btn svg {
  width: 0.9rem;
  height: 0.9rem;
}

.copy-source-btn.copied {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.editor-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.editor-body::-webkit-scrollbar {
  width: 0.5rem;
}

.editor-body::-webkit-scrollbar-track {
  background: transparent;
}

.editor-body::-webkit-scrollbar-thumb {
  background: var(--border-primary);
  border-radius: 0.25rem;
}

.editor-body::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* --------------------------------------------------------------------------
   5. SOURCE VIEW — Syntax-highlighted Markdown with line numbers
   -------------------------------------------------------------------------- */

.source-view {
  display: none;
  background: var(--bg-source);
  transition: background-color 0.2s ease;
  height: 100%;
}

.source-content {
  counter-reset: line;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Source Code Pro', 'Consolas', 'Monaco', monospace;
  font-size: 0.875rem;
  line-height: 1.6;
  padding: 1rem 0;
  overflow-x: auto;
  color: var(--text-secondary);
}

.source-line {
  counter-increment: line;
  display: flex;
  padding: 0 1.5rem 0 0;
  min-height: 1.6em;
}

.source-line::before {
  content: counter(line);
  display: inline-block;
  width: 3.5rem;
  padding-right: 1rem;
  text-align: right;
  color: var(--line-number);
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
}

/* Syntax highlighting classes */
.md-h1 { color: var(--syntax-heading); font-weight: 700; font-size: 1.1em; }
.md-h2 { color: var(--syntax-heading); font-weight: 700; }
.md-h3 { color: var(--syntax-heading); font-weight: 600; }
.md-bold { font-weight: 700; color: var(--syntax-bold); }
.md-italic { font-style: italic; }
.md-link { color: var(--syntax-link); text-decoration: underline; }
.md-code {
  color: var(--syntax-code);
  background: var(--syntax-code-bg);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}
.md-code-fence { color: var(--syntax-code); }
.md-code-block {
  background: var(--syntax-code-bg);
  display: block;
  padding: 0.3em 0.6em;
  border-radius: 3px;
}
.md-blockquote {
  color: var(--syntax-blockquote);
  border-left: 3px solid var(--accent-primary);
  padding-left: 0.5em;
}
.md-list-marker { color: var(--syntax-marker); font-weight: 600; }
.md-table-border { color: var(--syntax-table); }
.md-hr { color: var(--syntax-hr); }
.md-comment { color: var(--text-muted); font-style: italic; }

/* Blinking cursor (home page source view only) */
.source-cursor {
  display: inline-block;
  width: 0.5em;
  height: 1.1em;
  background: var(--accent-primary);
  animation: blink 1s step-end infinite;
  vertical-align: text-bottom;
  margin-left: 2px;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* --------------------------------------------------------------------------
   6. PREVIEW VIEW — Rendered Markdown (GitHub-style)
   -------------------------------------------------------------------------- */

.preview-view {
  padding: 2rem 2.5rem;
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text-secondary);
}

.preview-view h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1rem;
  margin-top: 0;
  line-height: 1.3;
}

.preview-view h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border-subtle);
  margin-top: 2rem;
  margin-bottom: 1rem;
  line-height: 1.3;
}

.preview-view h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

.preview-view p {
  margin-bottom: 1rem;
}

.preview-view blockquote {
  border-left: 3px solid var(--accent-primary);
  padding: 0.25rem 1rem;
  margin: 1rem 0;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-radius: 0 0.25rem 0.25rem 0;
}

.preview-view blockquote p {
  margin-bottom: 0;
}

.preview-view code {
  color: var(--syntax-code);
  background: var(--syntax-code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.875em;
  font-family: inherit;
}

.preview-view pre {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 0.375rem;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 1rem 0;
}

.preview-view pre code {
  background: none;
  padding: 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
}

.preview-view table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.875rem;
}

.preview-view th,
.preview-view td {
  border: 1px solid var(--border-primary);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.preview-view th {
  background: var(--bg-secondary);
  font-weight: 600;
  color: var(--text-primary);
}

.preview-view tr:nth-child(even) {
  background: var(--bg-secondary);
}

.preview-view ul,
.preview-view ol {
  padding-left: 1.5rem;
  margin: 0.75rem 0;
}

.preview-view li {
  margin-bottom: 0.35rem;
}

.preview-view li::marker {
  color: var(--text-muted);
}

.preview-view a {
  color: var(--text-link);
  text-decoration: none;
}

.preview-view a:hover {
  text-decoration: underline;
}

.preview-view hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 2rem 0;
}

.preview-view strong {
  font-weight: 700;
  color: var(--text-primary);
}

.preview-view em {
  font-style: italic;
}

.preview-view img {
  max-width: 100%;
  border-radius: 0.375rem;
}

/* Badge/tag style */
.preview-view .badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  background: var(--syntax-code-bg);
  color: var(--accent-primary);
  border: 1px solid var(--border-subtle);
}

/* Feature list grid for home page */
.preview-view .feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.preview-view .feature-card {
  padding: 1.25rem;
  border: 1px solid var(--border-subtle);
  border-radius: 0.375rem;
  background: var(--bg-secondary);
  transition: border-color 0.15s ease;
}

.preview-view .feature-card:hover {
  border-color: var(--accent-primary);
}

.preview-view .feature-card h3 {
  margin-top: 0;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.preview-view .feature-card h3 svg.lucide {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  color: var(--accent-primary);
}

.preview-view .feature-card p {
  font-size: 0.875rem;
  margin-bottom: 0;
  color: var(--text-muted);
}

/* Lifecycle stages for home page */
.preview-view .lifecycle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}

.preview-view .lifecycle-stage {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border-subtle);
  border-radius: 0.375rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  transition: border-color 0.15s ease;
}

.preview-view .lifecycle-stage:hover {
  border-color: var(--accent-primary);
}

.preview-view .lifecycle-arrow {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* CTA buttons */
.preview-view .cta-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.preview-view .cta-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  color: #ffffff;
  background: var(--accent-primary);
  border-radius: 0.375rem;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.preview-view .cta-primary:hover {
  opacity: 0.9;
  text-decoration: none;
}

.preview-view .cta-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 0.375rem;
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.preview-view .cta-secondary:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
  text-decoration: none;
}

.preview-view .cta-secondary svg,
.preview-view .cta-primary svg {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
}

/* Code block with filename header */
.preview-view .code-block-wrapper {
  margin: 1rem 0;
  border: 1px solid var(--border-subtle);
  border-radius: 0.375rem;
  overflow: hidden;
}

.preview-view .code-block-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-subtle);
}

.preview-view .code-block-wrapper pre {
  margin: 0;
  border: none;
  border-radius: 0;
}

/* Form styles (feedback/contact pages) */
.preview-view .form-group {
  margin-bottom: 1.25rem;
}

.preview-view .form-label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.preview-view .form-input,
.preview-view .form-textarea,
.preview-view .form-select {
  width: 100%;
  padding: 0.6rem 0.85rem;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: 0.375rem;
  transition: border-color 0.15s ease;
  box-sizing: border-box;
}

.preview-view .form-input:focus,
.preview-view .form-textarea:focus,
.preview-view .form-select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(74, 76, 162, 0.15);
}

.preview-view .form-textarea {
  min-height: 8rem;
  resize: vertical;
}

.preview-view .form-select option {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.preview-view .form-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.5rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--accent-primary);
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.preview-view .form-btn:hover {
  opacity: 0.9;
}

.preview-view .form-error {
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
  color: #dc2626;
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: 0.375rem;
}

.preview-view .form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* --------------------------------------------------------------------------
   7. STATUS BAR FOOTER
   -------------------------------------------------------------------------- */

.status-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  padding: 0.2rem 1rem;
  font-size: 0.72rem;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  background: var(--accent-primary);
  color: #ffffff;
}

.status-bar-inner {
  max-width: 72rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-left,
.status-center,
.status-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.status-separator {
  opacity: 0.5;
}

.status-link {
  color: #ffffff;
  text-decoration: none;
  opacity: 0.85;
  transition: opacity 0.15s ease;
}

.status-link:hover {
  opacity: 1;
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   8. THEME SWITCHER — Floating button
   -------------------------------------------------------------------------- */

.theme-switcher {
  position: fixed;
  bottom: 2.75rem;
  right: 1.5rem;
  z-index: 45;
}

.theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.theme-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.theme-btn.spin {
  transform: rotate(180deg);
}

.theme-btn svg {
  width: 1.15rem;
  height: 1.15rem;
}

.theme-icon {
  display: none;
}

.theme-icon.active {
  display: block;
}

.theme-dropdown {
  display: none;
  position: absolute;
  bottom: calc(100% + 0.5rem);
  right: 0;
  min-width: 9rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 0.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  padding: 0.35rem;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.theme-dropdown.open {
  display: block;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.45rem 0.65rem;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: 0.3rem;
  cursor: pointer;
  transition: background-color 0.1s ease, color 0.1s ease;
}

.theme-option:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.theme-option.active {
  color: var(--accent-primary);
}

.theme-option svg {
  width: 0.9rem;
  height: 0.9rem;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   9. ADMIN PANEL
   -------------------------------------------------------------------------- */

.admin-body {
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

.admin-login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.admin-login-card {
  width: 100%;
  max-width: 28rem;
}

.admin-login-brand {
  text-align: center;
  margin-bottom: 2rem;
}

.admin-login-brand a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
}

.admin-login-brand a:hover {
  color: var(--accent-primary);
  text-decoration: none;
}

.admin-login-brand p {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.admin-panel {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 16rem;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-primary);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.admin-sidebar-brand {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-primary);
}

.admin-sidebar-brand a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
}

.admin-sidebar-brand a:hover {
  color: var(--accent-primary);
  text-decoration: none;
}

.admin-sidebar-brand p {
  margin-top: 0.25rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.admin-sidebar-nav {
  flex: 1;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.admin-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}

.admin-nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}

.admin-nav-link.active {
  background: var(--bg-hover);
  color: var(--accent-primary);
}

.admin-nav-link svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.admin-sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border-primary);
}

.admin-logout-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: none;
  border: none;
  width: 100%;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
  font-family: inherit;
}

.admin-logout-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.admin-logout-btn svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.admin-main {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
}

.admin-card {
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border-primary);
  border-radius: 0.5rem;
  background: var(--bg-secondary);
  transition: border-color 0.15s;
}

.admin-card:hover {
  border-color: var(--accent-primary);
  text-decoration: none;
}

.admin-card-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.admin-card-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
}

.admin-card-value.accent {
  color: var(--accent-primary);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

/* Admin tables */
.admin-table-wrapper {
  border: 1px solid var(--border-primary);
  border-radius: 0.5rem;
  overflow: hidden;
  background: var(--bg-secondary);
}

.admin-table {
  width: 100%;
  font-size: 0.8rem;
  border-collapse: collapse;
}

.admin-table thead tr {
  border-bottom: 1px solid var(--border-primary);
}

.admin-table th {
  padding: 0.65rem 1.25rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-table td {
  padding: 0.75rem 1.25rem;
  color: var(--text-secondary);
}

.admin-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color 0.1s;
}

.admin-table tbody tr:last-child {
  border-bottom: none;
}

.admin-table tbody tr:hover {
  background: var(--bg-hover);
}

.admin-table .truncate {
  max-width: 20rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-table a {
  color: var(--accent-primary);
}

.admin-table a:hover {
  text-decoration: underline;
}

.admin-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.65rem;
  font-weight: 600;
}

.admin-badge.new {
  background: rgba(74, 76, 162, 0.15);
  color: var(--accent-primary);
}

.admin-badge.reviewed {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.admin-badge.resolved {
  background: rgba(107, 114, 128, 0.15);
  color: var(--text-muted);
}

.admin-badge.archived {
  background: rgba(107, 114, 128, 0.1);
  color: var(--text-muted);
}

/* Admin filters */
.admin-filters {
  display: flex;
  gap: 0.35rem;
}

.admin-filter-btn {
  padding: 0.3rem 0.65rem;
  border-radius: 0.375rem;
  font-size: 0.7rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  transition: all 0.15s;
}

.admin-filter-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-primary);
  text-decoration: none;
}

.admin-filter-btn.active {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}

/* Admin detail */
.admin-detail {
  max-width: 48rem;
}

.admin-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.admin-detail-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.admin-dl {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.admin-dl dt {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.admin-dl dd {
  color: var(--text-primary);
  font-size: 0.875rem;
  white-space: pre-wrap;
}

.admin-status-form {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-select {
  padding: 0.4rem 0.75rem;
  border-radius: 0.375rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-family: inherit;
}

.admin-select:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.admin-btn {
  padding: 0.4rem 1rem;
  border-radius: 0.375rem;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid var(--accent-primary);
  background: var(--accent-primary);
  color: #ffffff;
  cursor: pointer;
  transition: opacity 0.15s;
}

.admin-btn:hover {
  opacity: 0.85;
}

.admin-btn-secondary {
  padding: 0.4rem 1rem;
  border-radius: 0.375rem;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid var(--border-primary);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}

.admin-btn-secondary:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
  text-decoration: none;
}

.admin-back-link {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 1.5rem;
  display: inline-block;
}

.admin-back-link:hover {
  color: var(--text-primary);
  text-decoration: none;
}

.admin-empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Admin form inputs */
.admin-input {
  width: 100%;
  padding: 0.6rem 1rem;
  border-radius: 0.5rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

.admin-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(74, 76, 162, 0.15);
}

.admin-input::placeholder {
  color: var(--text-muted);
}

.admin-input.code-input {
  font-size: 1.5rem;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.5em;
}

.admin-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.admin-error {
  margin-bottom: 1.5rem;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #ef4444;
  font-size: 0.8rem;
}

.admin-form-card {
  padding: 2rem;
  border: 1px solid var(--border-primary);
  border-radius: 0.5rem;
  background: var(--bg-secondary);
}

.admin-form-group {
  margin-bottom: 1.25rem;
}

.admin-login-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.admin-login-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.admin-login-footer a:hover {
  color: var(--text-primary);
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   10. PAGE LAYOUT HELPERS
   -------------------------------------------------------------------------- */

.page-container {
  padding-top: 4.25rem;   /* Below fixed nav */
  padding-bottom: 2.5rem; /* Above fixed status bar */
  padding-left: 1rem;
  padding-right: 1rem;
  height: 100vh;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------------------
   10. RESPONSIVE
   -------------------------------------------------------------------------- */

/* Tablet + Mobile (< 1024px): offcanvas sidebar navigation */
@media (max-width: 1023px) {
  .nav-tabs {
    display: none;
  }

  .nav-hamburger {
    display: flex;
  }
}

/* Mobile (< 768px): compact layout */
@media (max-width: 767px) {
  .editor-dots {
    display: none;
  }

  .editor-topbar {
    padding: 0.4rem 0.75rem;
  }

  .editor {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .source-line::before {
    width: 2.5rem;
    padding-right: 0.5rem;
    font-size: 0.75rem;
  }

  .source-line {
    padding-right: 1rem;
  }

  .preview-view {
    padding: 1.25rem 1rem;
  }

  .preview-view h1 {
    font-size: 1.5rem;
  }

  .preview-view h2 {
    font-size: 1.25rem;
  }

  .status-center {
    display: none;
  }

  .status-bar-inner {
    justify-content: space-between;
  }

  .toggle-option {
    font-size: 0.65rem;
    padding: 0.15rem 0.5rem;
  }

  .page-container {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .preview-view .feature-grid {
    grid-template-columns: 1fr;
  }

  .theme-switcher {
    bottom: 2.5rem;
    right: 1rem;
  }

  .theme-btn {
    width: 2.25rem;
    height: 2.25rem;
  }
}
