:root {
  /* Color Palette - Slate & Indigo (Light Mode) */
  --color-bg: #f8fafc;
  --color-bg-subtle: #f1f5f9;
  --color-surface: #ffffff;
  --color-surface-glass: rgba(255, 255, 255, 0.8);

  --color-text-main: #0f172a;
  --color-text-muted: #64748b;
  --color-text-faint: #94a3b8;

  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-primary-subtle: #e0e7ff;
  --color-primary-text: #3730a3;

  --color-border: #e2e8f0;
  --color-border-hover: #cbd5e1;

  --color-success: #10b981;
  --color-success-subtle: #d1fae5;
  --color-warning: #f59e0b;
  --color-error: #ef4444;

  /* Typography */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  /* Spacing & Radius */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Dark Mode */
[data-theme="dark"] {
  --color-bg: #0f172a;
  --color-bg-subtle: #1e293b;
  --color-surface: #1e293b;
  --color-surface-glass: rgba(30, 41, 59, 0.9);

  --color-text-main: #f1f5f9;
  --color-text-muted: #94a3b8;
  --color-text-faint: #64748b;

  --color-primary: #818cf8;
  --color-primary-hover: #a5b4fc;
  --color-primary-subtle: rgba(129, 140, 248, 0.15);
  --color-primary-text: #c7d2fe;

  --color-border: #334155;
  --color-border-hover: #475569;

  --color-success: #34d399;
  --color-success-subtle: rgba(52, 211, 153, 0.15);

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.3);
}

[data-theme="dark"] body {
  background-image: radial-gradient(at 0% 0%, rgba(129, 140, 248, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(52, 211, 153, 0.08) 0px, transparent 50%);
}

[data-theme="dark"] .markdown-rendered {
  background: var(--color-bg-subtle);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  color: var(--color-text-main);
  background-color: var(--color-bg);
  background-image: radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.05) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(16, 185, 129, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

/* --- Layout --- */

.layout {
  display: grid;
  grid-template-columns: 416px 1fr;
  gap: 24px;
  padding: 24px;
  width: 100%;
  align-items: start;
}

/* --- Top Bar --- */

.top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--color-surface-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 0;
}

.heading h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text-main);
}

.eyebrow {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-primary);
  margin-bottom: 2px;
}

.muted {
  color: var(--color-text-muted);
  font-size: 13px;
}

#snapshot-path {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text-faint);
  margin-top: 4px;
}

/* --- Actions & Inputs --- */

.actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.select-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
}

select,
input[type="search"],
input[type="number"],
input[type="text"] {
  appearance: none;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13px;
  color: var(--color-text-main);
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

select {
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
}

select:hover,
input:hover {
  border-color: var(--color-border-hover);
}

select:focus,
input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

.active-switch {
  border-color: var(--color-primary) !important;
  box-shadow: 0 0 0 3px var(--color-primary-subtle) !important;
  transform: scale(1.02);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

button.primary {
  background-color: var(--color-primary);
  color: white;
  box-shadow: var(--shadow-md);
}

button.primary:hover {
  background-color: var(--color-primary-hover);
  transform: translateY(-1px);
}

button.ghost {
  background-color: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text-main);
  box-shadow: var(--shadow-sm);
}

button.ghost:hover {
  background-color: var(--color-bg-subtle);
  border-color: var(--color-border-hover);
}

/* --- Sidebar --- */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.panel {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.session-panel {
  max-height: 80vh;
}

.panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
  flex-shrink: 0;
}

.panel-header h2 {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

/* --- Session Tree --- */

.session-tree {
  padding: 8px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.session-tree::-webkit-scrollbar {
  width: 6px;
}

.session-tree::-webkit-scrollbar-track {
  background: transparent;
}

.session-tree::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
  border-radius: 20px;
}

.session-group {
  margin-bottom: 8px;
}

.session-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-main);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.session-group-header:hover {
  background: var(--color-bg-subtle);
}

.session-group.active .session-group-header {
  color: var(--color-primary);
}

.session-items {
  margin-top: 4px;
  padding-left: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.session-item {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.session-item:hover {
  background: var(--color-bg-subtle);
}

.session-item.active {
  background: var(--color-primary-subtle);
  border-color: rgba(79, 70, 229, 0.2);
}

.session-item-title {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-main);
}

.session-item.active .session-item-title {
  color: var(--color-primary-text);
}

.session-item-meta {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* --- Slice List --- */

.slice-sections {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px;
}

.slice-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slice-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.slice-list {
  list-style: none;
  margin: 0;
  padding: 6px 0 0;
  overflow-y: auto;
  max-height: 36vh;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.slice-list::-webkit-scrollbar {
  width: 6px;
}

.slice-list::-webkit-scrollbar-track {
  background: transparent;
}

.slice-list::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
  border-radius: 20px;
}

.slice-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 4px;
  transition: all 0.15s;
}

.slice-item:hover {
  background: var(--color-bg-subtle);
}

.slice-item.active {
  background: var(--color-primary-subtle);
  border-color: rgba(79, 70, 229, 0.2);
}

.slice-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--color-text-main);
}

.slice-item.active .slice-title {
  color: var(--color-primary-text);
}

.slice-subtitle {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* --- Content Area --- */

.content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
  padding: 24px;
}

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

.card-header p {
  font-weight: 600;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 24px;
}

.label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.meta-grid p:not(.label) {
  font-size: 15px;
  font-weight: 500;
  color: var(--color-text-main);
}

/* --- Tags & Pills --- */

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  background: var(--color-bg-subtle);
  color: var(--color-text-main);
  border: 1px solid var(--color-border);
  white-space: nowrap;
  flex-shrink: 0;
}

.pill-quiet {
  background: transparent;
  border-style: dashed;
  color: var(--color-text-muted);
}

.chip {
  display: inline-flex;
  align-items: center;
  background: var(--color-text-main);
  color: var(--color-bg);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

/* --- JSON Viewer --- */

.viewer {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg);
  margin-top: 16px;
}

.viewer-toolbar {
  padding: 12px;
  background: var(--color-bg-subtle);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.viewer-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.inline-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.button-group {
  display: flex;
  gap: 8px;
}

.items {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.item-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.item-header {
  padding: 10px 16px;
  background: var(--color-bg-subtle);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.item-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.item-body {
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
}

/* --- Tree Nodes --- */

.tree-node {
  margin-left: 12px;
  position: relative;
}

.tree-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  flex-wrap: wrap;
}

.tree-label {
  color: var(--color-primary-text);
  font-weight: 600;
}

.tree-preview {
  color: var(--color-text-muted);
  font-style: italic;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

.tree-children {
  margin-left: 16px;
  border-left: 1px solid var(--color-border);
  padding-left: 12px;
  margin-top: 4px;
}

.tree-leaf {
  color: var(--color-text-main);
  word-break: break-word;
  background: var(--color-surface);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid transparent;
}

.leaf-wrapper {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}

.markdown-toggle {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  align-self: flex-start;
}

.markdown-toggle button {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  border-radius: var(--radius-full);
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.markdown-toggle button:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-subtle);
}

.markdown-toggle button.active {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
}

.markdown-leaf {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 12px;
  background: var(--color-bg-subtle);
}

.markdown-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 0;
}

.markdown-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.markdown-rendered {
  font-family: var(--font-sans);
  color: var(--color-text-main);
  line-height: 1.6;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 12px;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
}

.markdown-rendered code {
  background: var(--color-bg);
  padding: 2px 4px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  word-break: break-all;
}

.markdown-rendered pre {
  background: var(--color-bg);
  padding: 10px;
  border-radius: 6px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  word-break: break-word;
}

.markdown-rendered pre code {
  word-break: break-word;
}

.markdown-raw {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--color-bg);
  border: 1px dashed var(--color-border);
  border-radius: 6px;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

.truncated {
  max-height: 200px;
  overflow-y: auto;
  display: block;
  border: 1px solid var(--color-border);
  padding: 8px;
  border-radius: 4px;
  background: var(--color-bg);
  width: 100%;
}

.tree-toggle,
.leaf-toggle {
  background: transparent;
  border: 1px solid var(--color-border);
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 4px;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.1s;
}

.tree-toggle:hover,
.leaf-toggle:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-subtle);
}

.tree-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
}

.tree-mini {
  background: transparent;
  border: none;
  font-size: 11px;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.tree-mini:hover {
  color: var(--color-primary);
  background: var(--color-bg-subtle);
  text-decoration: none;
}

/* --- Compact Array Visualization --- */

.compact-array {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 0;
  margin: 10px 0 14px;
}

.array-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text-main);
  margin: 6px;
}

.chip-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 6px;
}

/* --- Responsive --- */

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

  .sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }
}

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

  .top-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .viewer-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .keyboard-hints {
    display: none;
  }
}

/* --- Loading Overlay --- */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.2s ease;
}

[data-theme="dark"] .loading-overlay {
  background: rgba(15, 23, 42, 0.8);
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --- Toast Notifications --- */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1001;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-main);
  pointer-events: auto;
  animation: slideIn 0.3s var(--ease-spring);
}

.toast.toast-success {
  background: var(--color-success-subtle);
  border-color: var(--color-success);
  color: var(--color-success);
}

.toast.toast-error {
  background: #fef2f2;
  border-color: var(--color-error);
  color: var(--color-error);
}

[data-theme="dark"] .toast.toast-error {
  background: rgba(239, 68, 68, 0.15);
}

.toast.hiding {
  animation: slideOut 0.2s ease forwards;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* --- Icon Button --- */

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.icon-button:hover {
  background: var(--color-bg-subtle);
  border-color: var(--color-border-hover);
  color: var(--color-text-main);
}

.icon-button:active {
  transform: scale(0.95);
}

.icon-button.spinning svg {
  animation: spin 0.8s linear infinite;
}

/* Theme toggle icons */
#theme-toggle .icon-moon {
  display: none;
}

[data-theme="dark"] #theme-toggle .icon-sun {
  display: none;
}

[data-theme="dark"] #theme-toggle .icon-moon {
  display: block;
}

/* --- Keyboard Hints --- */

.keyboard-hints {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--color-text-faint);
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 2px 6px;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-muted);
  box-shadow: 0 1px 0 var(--color-border);
}

/* --- Empty State --- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--color-text-muted);
}

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-main);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  max-width: 280px;
}

/* --- Slice Content --- */

.slice-content {
  display: block;
}

.slice-content.hidden {
  display: none;
}

/* --- Utility Classes --- */

.hidden {
  display: none !important;
}

/* --- Animations --- */

.fade-in {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Subtle hover animations */
.session-item,
.slice-item {
  transition: all 0.15s ease, transform 0.1s ease;
}

.session-item:active,
.slice-item:active {
  transform: scale(0.98);
}

/* Card entrance animation */
.card {
  animation: cardEnter 0.3s ease;
}

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Item card stagger animation */
.item-card {
  animation: itemEnter 0.25s ease backwards;
}

.item-card:nth-child(1) { animation-delay: 0ms; }
.item-card:nth-child(2) { animation-delay: 30ms; }
.item-card:nth-child(3) { animation-delay: 60ms; }
.item-card:nth-child(4) { animation-delay: 90ms; }
.item-card:nth-child(5) { animation-delay: 120ms; }

@keyframes itemEnter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Focus states for accessibility */
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.session-item:focus-visible,
.slice-item:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

/* --- Type Icons in Tree --- */

.type-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--color-text-faint);
}

.type-icon.type-string { color: #059669; }
.type-icon.type-number { color: #0284c7; }
.type-icon.type-boolean { color: #dc2626; }
.type-icon.type-null { color: #64748b; }
.type-icon.type-array { color: #7c3aed; }
.type-icon.type-object { color: #ea580c; }
.type-icon.type-markdown { color: #0d9488; }

[data-theme="dark"] .type-icon.type-string { color: #34d399; }
[data-theme="dark"] .type-icon.type-number { color: #38bdf8; }
[data-theme="dark"] .type-icon.type-boolean { color: #f87171; }
[data-theme="dark"] .type-icon.type-array { color: #a78bfa; }
[data-theme="dark"] .type-icon.type-object { color: #fb923c; }
[data-theme="dark"] .type-icon.type-markdown { color: #2dd4bf; }

/* --- Scrollbar styling for dark mode --- */

[data-theme="dark"] .session-tree::-webkit-scrollbar-thumb,
[data-theme="dark"] .slice-list::-webkit-scrollbar-thumb {
  background-color: var(--color-border-hover);
}

[data-theme="dark"] .session-tree,
[data-theme="dark"] .slice-list {
  scrollbar-color: var(--color-border-hover) transparent;
}

/* --- Command Palette --- */

.command-palette {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}

.command-palette.hidden {
  display: none;
}

.command-palette-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

[data-theme="dark"] .command-palette-backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.command-palette-container {
  position: relative;
  width: 100%;
  max-width: 560px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  animation: paletteEnter 0.15s ease;
}

@keyframes paletteEnter {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(-8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.command-palette-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
}

.command-palette-header svg {
  flex-shrink: 0;
  color: var(--color-text-muted);
}

.command-palette-header input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 16px;
  color: var(--color-text-main);
  outline: none;
  padding: 0;
  box-shadow: none;
}

.command-palette-header input::placeholder {
  color: var(--color-text-faint);
}

.command-palette-header kbd {
  flex-shrink: 0;
}

.command-results {
  max-height: 360px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.command-results::-webkit-scrollbar {
  width: 6px;
}

.command-results::-webkit-scrollbar-track {
  background: transparent;
}

.command-results::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
  border-radius: 20px;
}

.command-group {
  padding: 8px;
}

.command-group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  padding: 8px 12px 4px;
}

.command-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s ease;
}

.command-item:hover,
.command-item.selected {
  background: var(--color-bg-subtle);
}

.command-item.selected {
  background: var(--color-primary-subtle);
}

.command-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.command-item.selected .command-item-icon {
  background: var(--color-primary);
  color: white;
}

.command-item-content {
  flex: 1;
  min-width: 0;
}

.command-item-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.command-item-subtitle {
  font-size: 12px;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.command-item-shortcut {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.command-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--color-text-muted);
}

.command-empty svg {
  margin-bottom: 12px;
  opacity: 0.5;
}

.command-footer {
  display: flex;
  gap: 16px;
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
  font-size: 12px;
  color: var(--color-text-muted);
}

.command-footer span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.command-footer kbd {
  font-size: 10px;
  padding: 2px 4px;
  min-width: 16px;
}

/* --- Keyboard Shortcuts Overlay --- */

.shortcuts-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.shortcuts-overlay.hidden {
  display: none;
}

.shortcuts-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

[data-theme="dark"] .shortcuts-backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.shortcuts-container {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: paletteEnter 0.15s ease;
}

.shortcuts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
}

.shortcuts-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-main);
}

.shortcuts-body {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
  max-height: 60vh;
  overflow-y: auto;
}

.shortcuts-section h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
}

.shortcut-row:last-child {
  border-bottom: none;
}

.shortcut-row kbd {
  margin-right: 4px;
}

.shortcut-row span {
  color: var(--color-text-main);
}

/* --- Hint Button --- */

.hint-button {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.hint-button:hover kbd {
  background: var(--color-primary-subtle);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* --- Sidebar Collapsed State --- */

.layout.sidebar-collapsed .sidebar {
  display: none;
}

.layout.sidebar-collapsed {
  grid-template-columns: 1fr;
}

/* --- Item Focus State --- */

.item-card.focused {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

/* --- Highlight matching text in command palette --- */

.command-highlight {
  background: var(--color-warning);
  color: var(--color-text-main);
  border-radius: 2px;
  padding: 0 2px;
}

[data-theme="dark"] .command-highlight {
  background: rgba(245, 158, 11, 0.3);
}

/* --- Filter Match Highlighting --- */

.tree-label.filter-match {
  background: var(--color-primary-subtle);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--color-primary);
}

.tree-label .command-highlight {
  background: var(--color-warning);
  font-weight: 600;
}

[data-theme="dark"] .tree-label .command-highlight {
  background: rgba(245, 158, 11, 0.4);
}

/* --- Markdown Constrained Height --- */

.markdown-rendered {
  max-height: 300px;
  overflow-y: auto;
}

.markdown-rendered.expanded {
  max-height: none;
}

.markdown-controls {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.markdown-expand-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: 11px;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.markdown-expand-btn:hover {
  background: var(--color-primary-subtle);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* --- Markdown Pop-out Modal --- */

.markdown-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.markdown-modal.hidden {
  display: none;
}

.markdown-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

[data-theme="dark"] .markdown-modal-backdrop {
  background: rgba(0, 0, 0, 0.8);
}

.markdown-modal-container {
  position: relative;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: paletteEnter 0.15s ease;
  display: flex;
  flex-direction: column;
}

.markdown-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
  flex-shrink: 0;
}

.markdown-modal-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.markdown-modal-header h2 svg {
  color: var(--color-text-muted);
}

.markdown-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.markdown-modal-body .markdown-rendered {
  max-height: none;
  background: transparent;
  border: none;
  padding: 0;
}
