/* ==========================================================================
   Go Exercise Tester - Developer Design System
   Clean, compact, practical developer interface. No AI fluff, no neon glow.
   ========================================================================== */

:root {
  --bg: #0d1117;
  --bg-dark: #080c12;
  --panel: #161b22;
  --panel-muted: #131820;
  --panel-hover: #1c2128;
  --border: #30363d;
  --border-muted: #21262d;
  --border-light: #484f58;

  --fg: #e6edf3;
  --fg-muted: #8b949e;
  --fg-subtle: #6e7681;
  --fg-white: #ffffff;

  --accent: #388bfd;
  --accent-hover: #58a6ff;
  --accent-bg: rgba(56, 139, 253, 0.1);
  --accent-border: rgba(56, 139, 253, 0.35);

  --success: #3fb950;
  --success-bg: rgba(63, 185, 80, 0.12);
  --success-border: rgba(63, 185, 80, 0.3);

  --error: #f85149;
  --error-bg: rgba(248, 81, 73, 0.12);
  --error-border: rgba(248, 81, 73, 0.3);

  --warning: #d29922;
  --warning-bg: rgba(210, 153, 34, 0.12);
  --warning-border: rgba(210, 153, 34, 0.3);

  --radius-xs: 3px;
  --radius-sm: 4px;
  --radius: 6px;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
  background-color: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Utility Containers */
.app-container {
  max-width: 1240px;
  margin-left: auto;
  margin-right: auto;
}

/* Developer Panels */
.panel {
  background-color: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border-muted);
  background-color: var(--panel-muted);
}

.panel-header h2, .panel-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.01em;
}

.panel-body {
  padding: 0.85rem;
}

/* Top Navigation Bar */
.topbar {
  background-color: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1rem;
}

.topbar-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1400px;
  margin: 0 auto;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
}

.brand-badge .brand-tag {
  background-color: var(--accent-bg);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  font-weight: 500;
  font-family: var(--font-mono);
}

/* Typography */
.text-muted { color: var(--fg-muted) !important; }
.text-subtle { color: var(--fg-subtle) !important; }
.text-accent { color: var(--accent) !important; }
.text-success { color: var(--success) !important; }
.text-error { color: var(--error) !important; }
.text-warning { color: var(--warning) !important; }
.font-mono { font-family: var(--font-mono) !important; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-ui);
  line-height: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background-color: var(--panel-hover);
  color: var(--fg);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}

.btn:hover {
  background-color: #262c36;
  border-color: var(--border-light);
  color: var(--fg-white);
}

.btn:active {
  background-color: #21262d;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn-primary {
  background-color: #1f6feb;
  border-color: rgba(240, 246, 252, 0.1);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: #388bfd;
  border-color: rgba(240, 246, 252, 0.15);
  color: #ffffff;
}

.btn-success {
  background-color: #238636;
  border-color: rgba(240, 246, 252, 0.1);
  color: #ffffff;
}

.btn-success:hover {
  background-color: #2ea043;
  border-color: rgba(240, 246, 252, 0.15);
  color: #ffffff;
}

.btn-secondary {
  background-color: #21262d;
  border-color: var(--border);
  color: var(--fg);
}

.btn-secondary:hover {
  background-color: #30363d;
  border-color: var(--border-light);
}

.btn-ghost {
  background-color: transparent;
  border-color: transparent;
  color: var(--fg-muted);
}

.btn-ghost:hover {
  background-color: rgba(240, 246, 252, 0.08);
  color: var(--fg);
  border-color: transparent;
}

.btn-small {
  padding: 3px 8px;
  font-size: 12px;
  line-height: 18px;
  border-radius: var(--radius-sm);
}

.btn-danger {
  background-color: #21262d;
  border-color: var(--error-border);
  color: var(--error);
}

.btn-danger:hover {
  background-color: #b62324;
  border-color: #f85149;
  color: #ffffff;
}

/* Badges & Chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background-color: var(--panel-muted);
  color: var(--fg-muted);
}

.badge-accent {
  background-color: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent);
}

.badge-success {
  background-color: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success);
}

.badge-warning {
  background-color: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning);
}

/* Stat Cards */
.stat-card {
  background-color: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  margin-bottom: 0.25rem;
}

.stat-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--fg);
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.stat-sub {
  font-size: 12px;
  color: var(--fg-muted);
  margin-top: 0.25rem;
}

/* Clean Progress Bar */
.progress-track {
  width: 100%;
  height: 5px;
  background-color: var(--border-muted);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.progress-fill {
  height: 100%;
  background-color: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Level Masonry — layout is built by JS into flex columns; this is the shell */
.level-masonry {
  display: block; /* neutral; JS replaces content with flex wrapper */
}

/* These classes are injected by the masonry JS — not used globally */
.lm-columns {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.lm-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Tier Section & Compact Rows */
.tier-card {
  background-color: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.tier-card-header {
  padding: 0.65rem 0.85rem;
  background-color: var(--panel-muted);
  border-bottom: 1px solid var(--border-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tier-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
}

.tier-score {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--fg-muted);
}

.exercise-list {
  display: flex;
  flex-direction: column;
  padding: 0.25rem 0.35rem;
}

.exercise-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.55rem;
  border-radius: var(--radius-sm);
  transition: background-color 0.1s ease;
  border-bottom: 1px solid rgba(255,255,255,0.02);
}

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

.exercise-row:hover {
  background-color: var(--panel-hover);
}

.exercise-row-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1;
}

.exercise-status-icon {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 11px;
}

.status-completed {
  color: var(--success);
}

.status-pending {
  color: var(--fg-subtle);
}

.exercise-name {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exercise-fn-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-subtle);
  background-color: var(--panel-muted);
  border: 1px solid var(--border-muted);
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  white-space: nowrap;
}

.tier-footer {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border-muted);
  background-color: var(--panel-muted);
}

/* Developer Console Box */
.terminal-container {
  background-color: #070a0f;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.75rem;
  background-color: #0d1117;
  border-bottom: 1px solid var(--border-muted);
}

.terminal-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.terminal-body {
  padding: 0.75rem 0.9rem;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: #cbd5e1;
  overflow-y: auto;
  min-height: 120px;
  max-height: 220px;
  white-space: pre-wrap;
  word-break: break-word;
}

.terminal-prompt {
  color: var(--fg-subtle);
  user-select: none;
}

.terminal-success-banner {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--success);
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.terminal-error-banner {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--error);
  font-weight: 600;
  margin-bottom: 0.4rem;
}

/* Markdown Subject Instructions */
.markdown-subject {
  font-size: 13.5px;
  line-height: 1.65;
  color: #c9d1d9;
}

.markdown-subject h1, .markdown-subject h2, .markdown-subject h3, .markdown-subject h4 {
  color: var(--fg);
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.markdown-subject h1 {
  font-size: 1.25rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border-muted);
  margin-top: 0.5rem;
}

.markdown-subject h2 {
  font-size: 1.1rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid var(--border-muted);
}

.markdown-subject h3 {
  font-size: 0.95rem;
}

.markdown-subject p {
  margin-bottom: 0.75rem;
}

.markdown-subject ul, .markdown-subject ol {
  margin-left: 1.25rem;
  margin-bottom: 0.75rem;
}

.markdown-subject li {
  margin-bottom: 0.25rem;
}

.markdown-subject code {
  font-family: var(--font-mono);
  font-size: 12px;
  background-color: var(--border-muted);
  color: #e6edf3;
  padding: 2px 5px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
}

.markdown-subject pre {
  background-color: #080c12;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.85rem;
  overflow-x: auto;
}

.markdown-subject pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: #e6edf3;
  font-size: 12.5px;
}

.markdown-subject blockquote {
  border-left: 3px solid var(--border-light);
  padding-left: 0.75rem;
  color: var(--fg-muted);
  margin: 0.75rem 0;
}

.markdown-subject table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 13px;
}

.markdown-subject th, .markdown-subject td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  text-align: left;
}

.markdown-subject th {
  background-color: var(--panel-muted);
  font-weight: 600;
}

/* Scrollbars */
.scrollbar-custom {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.scrollbar-custom::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.scrollbar-custom::-webkit-scrollbar-track {
  background: transparent;
}

.scrollbar-custom::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.scrollbar-custom::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* Form Inputs */
.form-input {
  width: 100%;
  background-color: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  padding: 6px 10px;
  font-size: 13px;
  font-family: var(--font-ui);
  transition: border-color 0.12s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-input::placeholder {
  color: var(--fg-subtle);
}

/* Table styling for history */
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.history-table th {
  text-align: left;
  font-weight: 600;
  color: var(--fg-muted);
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid var(--border-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.history-table td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid rgba(255,255,255,0.02);
  color: var(--fg);
}

.history-table tr:hover td {
  background-color: var(--panel-hover);
}

/* Responsive Overrides */
@media (max-width: 768px) {
  .app-container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}
