/* ...existing styles... */
:root {
  /* AMOLED dark defaults */
  --bg: #000000;
  --card: #000000;
  --text: #e6eef8;
  --muted: #9aa6b2;
  --border: #0a0a0a;
  --ring: rgba(120,120,255,0.16);
  --accent: linear-gradient(135deg, #4dd0ff, #6a63ff 30%, #ff4fb8 60%, #ff8a3b);
  --accent-strong: linear-gradient(135deg, #26c6ff, #6a63ff 30%, #ff3ca7 60%, #ff7a00);
}

/* Base */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Noto Sans", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* force text color across common elements to avoid any default black text */
input, textarea, select, button, label, h1, h2, h3, h4, h5, h6, table, th, td, pre, code, a, .logo-text, .tool-group-title, .footer-content, .panel-card, .tool-item {
  color: var(--text) !important;
}

/* placeholders should be muted but visible on dark bg */
input::placeholder, textarea::placeholder {
  color: var(--muted) !important;
  opacity: 1;
}

/* ensure table cells and contenteditable cells also use the text color */
table, th, td, [contenteditable="true"] { color: var(--text) !important; }

/* Header */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
  backdrop-filter: saturate(1.1) blur(6px);
}
.logo { display: flex; align-items: center; gap: 12px; font-weight: 700; letter-spacing: 0.2px; }
.logo-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent);
  box-shadow: 0 6px 16px rgba(106,99,255,0.12);
}
.logo-text { font-size: 18px; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-actions [data-lucide] {
  width: 22px; height: 22px; color: var(--text);
}
.github-link, .header .action-btn {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); transition: transform .12s ease, box-shadow .2s ease, border-color .2s ease;
}
.theme-toggle:hover, .github-link:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(0,0,0,.08); border-color: var(--ring); }

/* Layout */
.layout { display: grid; grid-template-columns: 280px 1fr; gap: 0; min-height: calc(100vh - 64px); }
.sidebar { border-right: 1px solid var(--border); padding: 16px; position: sticky; top: 64px; height: calc(100vh - 64px); overflow: auto; }
.main { padding: 28px; }

/* Search */
.search { position: relative; }
.search input {
  width: 100%; padding: 12px 40px 12px 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  outline: none; transition: border-color .15s ease, box-shadow .2s ease;
}
.search input:focus { border-color: var(--ring); box-shadow: 0 0 0 6px color-mix(in oklab, var(--ring) 30%, transparent); }
.search-icon { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }

/* Tool groups */
.tool-groups { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.tool-group { display: flex; flex-direction: column; gap: 8px; }
.tool-group-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; padding: 8px 4px; }
.tool-list { display: grid; grid-template-columns: 1fr; gap: 6px; }
.tool-item {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--card); cursor: pointer; user-select: none;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.tool-item:hover { border-color: var(--ring); background: color-mix(in oklab, var(--card) 85%, white 15%); transform: translateY(-1px); }
.tool-item [data-lucide] { width: 18px; height: 18px; color: var(--muted); }
.tool-item.active { outline: 2px solid transparent; border-color: transparent; box-shadow: 0 0 0 2px rgba(123, 125, 255, .35); }

/* Hero */
.hero { display: grid; gap: 10px; margin-bottom: 20px; }
.hero h1 { font-size: 28px; margin: 0; }
.hero p { margin: 0; color: var(--muted); }
.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.quick-button {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card); cursor: pointer; transition: transform .12s ease, box-shadow .2s ease;
}
.quick-button:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(0,0,0,.06); }
.quick-button .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
}

/* Tool panel */
.tool-panel { display: grid; gap: 16px; }
.panel-card {
  border: 1px solid var(--border); border-radius: 16px; background: var(--card);
  padding: 16px; transition: box-shadow .2s ease, border-color .2s ease;
}
.panel-card:focus-within { border-color: var(--ring); box-shadow: 0 8px 24px rgba(0,0,0,.06); }

.panel-header { display: flex; align-items: center; justify-content: space-between; }
.panel-title { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; }
.panel-title [data-lucide] { width: 20px; height: 20px; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); cursor: pointer; transition: transform .12s ease, box-shadow .2s ease, border-color .2s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(0,0,0,.06); border-color: var(--ring); }
.btn.primary { border: none; color: white; background-image: var(--accent-strong); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.small { padding: 8px 10px; }

.input, textarea, select {
  width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); color: var(--text);
  outline: none; transition: border-color .15s ease, box-shadow .2s ease;
}
textarea { min-height: 160px; resize: vertical; }
.input:focus, textarea:focus, select:focus { border-color: var(--ring); box-shadow: 0 0 0 6px color-mix(in oklab, var(--ring) 30%, transparent); }

.io-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.io-grid .panel-card { min-height: 240px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Empty state */
.tool-empty { display: grid; place-items: center; text-align: center; padding: 60px; border: 1px dashed var(--border); border-radius: 16px; }
.empty-icon [data-lucide] { width: 24px; height: 24px; }
.tool-empty h2 { margin: 12px 0 6px; }

/* Footer */
.footer { border-top: 1px solid var(--border); padding: 16px 24px; }
.footer-content { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; }

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  /* Adjusting background mix based on dark/light theme variables */
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(2px);
  z-index: 100;
  transition: opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

.loading-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.spinner {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--accent);
  background-size: 300% 300%;
  animation: rotateSpinner 1.5s cubic-bezier(0.8, 0.05, 0.2, 0.95) infinite, gradientMove 4s ease-in-out infinite;
}

@keyframes rotateSpinner {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.05); }
  100% { transform: rotate(360deg) scale(1); }
}

@keyframes gradientMove {
  0% { background-position: 0% 0%; }
  50% { background-position: 100% 100%; }
  100% { background-position: 0% 0%; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }
}

/* Responsive improvements for mobile */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  /* Make sidebar collapse into a horizontal, touch-friendly toolbar */
  .sidebar {
    position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 12px; padding: 12px;
  }
  .tool-groups { display: block; }
  .tool-list { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
  .tool-item { min-width: 140px; flex: 0 0 auto; padding: 14px; border-radius: 12px; }
  .search input { padding: 14px 44px 14px 12px; border-radius: 12px; }
  .quick-actions { gap: 12px; }
  .quick-button { padding: 12px 14px; min-width: 120px; }
  .io-grid { grid-template-columns: 1fr; }
  .panel-card { padding: 14px; border-radius: 14px; }
  .btn, .input, textarea { font-size: 16px; padding: 12px; }
}