/* =========================================================
   niky.web — styles (matches niky.dev / niky.py design system)
   ========================================================= */
:root {
  --bg: #0d1117;
  --bg-2: #161b22;
  --bg-3: #010409;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.1);
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #38bdf8;
  --accent-2: #818cf8;
  --accent-3: #f472b6;
  --html-color: #e34f26;
  --css-color: #2965f1;
  --js-color: #f7df1e;
  --ok: #3fb950;
  --err: #ff7b72;
  --warn: #d29922;
  --radius: 12px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: "JetBrainsMono NFM", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --top: 56px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f6f8fa;
  --bg-2: #ffffff;
  --bg-3: #ffffff;
  --surface: rgba(0, 0, 0, 0.025);
  --surface-2: rgba(0, 0, 0, 0.055);
  --border: rgba(0, 0, 0, 0.1);
  --text: #1f2328;
  --muted: #59636e;
  --accent: #0284c7;
  --accent-2: #4f46e5;
  --accent-3: #db2777;
  --ok: #1a7f37;
  --err: #cf222e;
  --warn: #9a6700;
  color-scheme: light;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

svg.lucide {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

kbd {
  font-family: var(--font);
  font-size: 0.68rem;
  padding: 0 0.35rem;
  border: 1px solid currentColor;
  border-radius: 4px;
  opacity: 0.6;
}

code {
  font-family: var(--font);
  font-size: 0.92em;
  padding: 0.1rem 0.35rem;
  border-radius: 5px;
  background: var(--surface-2);
}

/* =========================================================
   Top bar
   ========================================================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--top);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1rem;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
}

.brand__icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  color: #0d1117;
  background: linear-gradient(135deg, var(--html-color), var(--css-color) 50%, var(--js-color));
}

.brand__muted {
  color: var(--muted);
  font-weight: 400;
}

.progress {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: auto;
}

.progress__track {
  width: 140px;
  height: 7px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress__fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  transition: width 0.6s var(--ease);
}

.progress__text {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}

.status[data-state="checking"] .status__dot {
  background: var(--accent);
  animation: pulse 1s infinite alternate;
}

.status[data-state="error"] .status__dot {
  background: var(--err);
}

@keyframes pulse {
  0% { transform: scale(0.8); opacity: 0.5; }
  100% { transform: scale(1.2); opacity: 1; }
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--accent);
}

.icon-btn--sm {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  margin-left: auto;
}

.menu-btn {
  display: none;
}

/* =========================================================
   Layout Grid
   ========================================================= */
.app {
  display: grid;
  grid-template-columns: 260px minmax(320px, 440px) minmax(0, 1fr);
  height: calc(100dvh - var(--top));
}

.sidebar,
.task {
  overflow-y: auto;
}

.sidebar {
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.task {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.work {
  display: grid;
  grid-template-rows: 44px 1fr 280px;
  min-width: 0;
  background: var(--bg-3);
  overflow: hidden;
}

/* =========================================================
   Sidebar List
   ========================================================= */
.ex-search {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  z-index: 2;
}

.ex-search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 0.85rem;
}

.track-group {
  margin-bottom: 0.75rem;
}

.track-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.track-header:hover {
  background: var(--surface-2);
}

.track-header .track-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  color: white;
}

.track-badge {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
  margin-left: auto;
}

.track-arrow {
  transition: transform 0.2s var(--ease);
}

.track-group.is-open .track-arrow {
  transform: rotate(90deg);
}

.track-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
  padding-left: 0.5rem;
}

.track-group:not(.is-open) .track-items {
  display: none;
}

.ex-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.82rem;
  color: var(--muted);
  transition: all 0.12s;
}

.ex-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.ex-link.is-active {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  border-left: 2px solid var(--accent);
}

.ex-link .status-icon {
  width: 14px;
  height: 14px;
  color: var(--muted);
}

.ex-link.is-solved .status-icon {
  color: var(--ok);
}

/* =========================================================
   Task Panel
   ========================================================= */
.crumb {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.task h1 {
  font-size: 1.45rem;
  line-height: 1.3;
}

.task__meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.dots {
  display: inline-flex;
  gap: 3px;
}

.dots i {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.dots i.on {
  background: var(--warn);
  border-color: var(--warn);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge--solved {
  background: rgba(63, 185, 80, 0.15);
  color: var(--ok);
  border: 1px solid rgba(63, 185, 80, 0.3);
}

.task__body {
  font-size: 0.92rem;
  line-height: 1.65;
}

.task__body h3 {
  font-size: 1rem;
  margin: 1.25rem 0 0.5rem;
  color: var(--text);
}

.task__body ul {
  padding-left: 1.25rem;
  margin-bottom: 1rem;
}

.task__body li {
  margin-bottom: 0.35rem;
}

.notes {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
}

.notes summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  cursor: pointer;
}

.notes pre {
  margin-top: 0.6rem;
  padding: 0.6rem;
  border-radius: 6px;
  background: var(--bg-3);
  overflow-x: auto;
  font-size: 0.8rem;
}

.help {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.hints {
  padding-left: 1.25rem;
  font-size: 0.85rem;
  color: var(--text);
}

.hints li {
  margin-bottom: 0.4rem;
}

.help__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.82rem;
  cursor: pointer;
  align-self: flex-start;
  transition: all 0.15s;
}

.help__btn:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--accent);
}

.solution {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
}

.solution summary {
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.solution pre {
  margin-top: 0.6rem;
  padding: 0.6rem;
  border-radius: 6px;
  background: var(--bg-3);
  overflow-x: auto;
  max-height: 200px;
  font-size: 0.8rem;
}

.solution__actions {
  margin-top: 0.6rem;
  display: flex;
  gap: 0.5rem;
}

/* =========================================================
   Workspace & Tabs Bar
   ========================================================= */
.work__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.75rem;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  gap: 0.5rem;
}

.file-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
}

.file-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.35rem 0.75rem;
  background: transparent;
  border: none;
  border-top: 2px solid transparent;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  transition: all 0.15s;
}

.file-tab:hover {
  background: var(--surface);
  color: var(--text);
}

.file-tab.is-active {
  background: var(--bg-3);
  color: var(--text);
  font-weight: 600;
  border-top-color: var(--accent);
}

.file-tab[data-file="html"].is-active {
  border-top-color: var(--html-color);
}

.file-tab[data-file="css"].is-active {
  border-top-color: var(--css-color);
}

.file-tab[data-file="js"].is-active {
  border-top-color: var(--js-color);
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn--ghost {
  border-color: transparent;
  background: transparent;
}

.btn--ghost:hover {
  background: var(--surface);
}

.btn--ghost.is-armed {
  background: var(--err);
  color: white;
  border-color: var(--err);
}

.btn--primary {
  background: var(--accent);
  color: #0d1117;
  font-weight: 600;
  border-color: var(--accent);
}

.btn--primary:hover:not(:disabled) {
  filter: brightness(1.1);
}

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

.editor {
  position: relative;
  min-height: 0;
  background: var(--bg-3);
}

.editor__loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* =========================================================
   Bottom Panel (Preview / Tests / Console)
   ========================================================= */
.panel {
  display: grid;
  grid-template-rows: 36px 1fr;
  min-height: 0;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
}

.panel__tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 0.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.ptab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.65rem;
  background: transparent;
  border: none;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}

.ptab:hover {
  background: var(--surface);
  color: var(--text);
}

.ptab.is-active {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}

.pill {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--text);
}

.pill--pass {
  background: rgba(63, 185, 80, 0.2);
  color: var(--ok);
}

.pill--fail {
  background: rgba(255, 123, 114, 0.2);
  color: var(--err);
}

.panel__body {
  overflow-y: auto;
  position: relative;
  height: 100%;
}

.preview-wrap {
  width: 100%;
  height: 100%;
  background: #ffffff;
}

#previewFrame {
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
}

.tests-container {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.test-card {
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
  transition: border-color 0.15s;
}

.test-card.pass {
  border-color: rgba(63, 185, 80, 0.4);
  background: rgba(63, 185, 80, 0.05);
}

.test-card.fail {
  border-color: rgba(255, 123, 114, 0.4);
  background: rgba(255, 123, 114, 0.05);
}

.test-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.test-card.pass .test-head {
  color: var(--ok);
}

.test-card.fail .test-head {
  color: var(--err);
}

.test-msg {
  padding-left: 1.55rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.console-body {
  padding: 0.5rem 0.75rem;
  font-family: var(--font);
  font-size: 0.8rem;
}

.console-line {
  padding: 0.2rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.console-line.error {
  color: var(--err);
}

.console-line.warn {
  color: var(--warn);
}

.empty {
  color: var(--muted);
  font-style: italic;
  padding: 1rem;
  text-align: center;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* =========================================================
   Responsive Breakpoints
   ========================================================= */
@media (max-width: 900px) {
  .menu-btn {
    display: grid;
  }

  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    top: var(--top);
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.25s var(--ease);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .overlay {
    position: fixed;
    inset: var(--top) 0 0 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 35;
  }
}
