/* DBMS Lab Hub — Duolingo-inspired (design.duolingo.com)
   Matches 19-08-2026 employee directory: bold flat color, chunky shapes, 3D press. */

:root {
  --green: #58CC02;
  --green-dark: #58A700;
  --blue: #1CB0F6;
  --blue-dark: #1899D6;
  --red: #FF4B4B;
  --red-dark: #EA2B2B;
  --gold: #FFC800;
  --gold-dark: #E5A600;
  --purple: #CE82FF;
  --purple-dark: #A568C9;
  --orange: #FF9600;
  --orange-dark: #E08600;
  --navy: #3C3C3C;
  --accent: #2E75B6;
  --accent-dark: #1e5a94;

  --action: var(--green);
  --action-dark: var(--green-dark);
  --info: var(--blue);
  --info-dark: var(--blue-dark);
  --danger: var(--red);
  --danger-dark: var(--red-dark);

  --ink: #3C3C3C;
  --ink-soft: #6B6B6B;
  --ink-faint: #AFAFAF;
  --paper: #FFFFFF;
  --wall: #F7F7F9;
  --wall-strong: #F0EFF4;
  --line: #E5E5E5;
  --line-strong: #D6D6DB;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-2xl: 28px;
  --r-full: 999px;

  --sp-1: .25rem;
  --sp-2: .5rem;
  --sp-3: .75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;

  --ease-out: cubic-bezier(.32, .72, 0, 1);
  --dur-fast: 120ms;
  --dur-base: 180ms;
  --dur-slow: 260ms;

  --font-display: 'Baloo 2', ui-rounded, system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --shell-max: 1200px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  font-synthesis: none;
}

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

html {
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--wall);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: rgba(28, 176, 246, 0.15);
}

h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  text-wrap: balance;
}

a {
  color: var(--blue-dark);
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
}

button, .btn, .chip, .tab, .lab-card {
  user-select: none;
  -webkit-user-select: none;
}

::selection {
  background: color-mix(in oklch, var(--blue), white 65%);
  color: var(--ink);
}

:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.skip-link {
  position: fixed;
  top: calc(-100px + var(--safe-top));
  left: calc(var(--sp-4) + var(--safe-left));
  z-index: 500;
  background: var(--ink);
  color: white;
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-md);
  font-weight: 700;
  font-family: var(--font-display);
  text-decoration: none;
  transition: top var(--dur-base) var(--ease-out);
}
.skip-link:focus-visible { top: calc(var(--sp-4) + var(--safe-top)); }

.icon {
  width: 1.1em;
  height: 1.1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Shell */
.app {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding:
    calc(var(--sp-6) + var(--safe-top))
    calc(var(--sp-5) + var(--safe-right))
    calc(var(--sp-10) + var(--safe-bottom))
    calc(var(--sp-5) + var(--safe-left));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-4);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-right: auto;
  text-decoration: none;
  color: inherit;
  border-radius: var(--r-md);
}
.brand:hover { color: inherit; }

.brand-badge {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--r-md);
  background: var(--green);
  color: white;
  box-shadow: 0 3px 0 var(--green-dark);
  flex: none;
}

.brand-title {
  display: block;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--ink);
}

.brand-text p {
  font-size: .8rem;
  color: var(--ink-soft);
  font-weight: 700;
  margin-top: 2px;
}

.topbar-actions { display: flex; gap: var(--sp-2); }

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

.app-footer {
  text-align: center;
  color: var(--ink-faint);
  font-size: .8rem;
  line-height: 1.7;
  padding-top: var(--sp-4);
}
.footer-meta { display: block; margin-top: 4px; font-weight: 600; }

.loading-shell {
  padding: var(--sp-10);
  text-align: center;
  color: var(--ink-soft);
  font-weight: 700;
}

/* Typography */
.page-title {
  font-size: clamp(1.5rem, 3vw, 1.85rem);
  font-weight: 800;
  color: var(--ink);
}

.panel-title {
  font-size: 1.25rem;
  font-weight: 800;
}

.hero { margin-bottom: var(--sp-2); }
.hero-sub {
  color: var(--ink-soft);
  font-size: .95rem;
  font-weight: 600;
  margin-top: var(--sp-2);
  max-width: 52ch;
}

.home-stats {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-top: var(--sp-4);
}
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--r-full);
  padding: var(--sp-2) var(--sp-4);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: .85rem;
}
.stat-pill strong {
  font-variant-numeric: tabular-nums;
  color: var(--blue-dark);
}

/* Buttons — 3D press */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 44px;
  min-width: 44px;
  padding: var(--sp-3) var(--sp-5);
  border: none;
  border-radius: var(--r-md);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .95rem;
  text-decoration: none;
  color: white;
  background: var(--ink-faint);
  box-shadow: 0 4px 0 color-mix(in oklch, var(--ink-faint), black 25%);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), filter var(--dur-fast);
}
.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none !important;
}
.btn-sm {
  min-height: 44px;
  padding: var(--sp-2) var(--sp-4);
  font-size: .85rem;
}

@media (hover: hover) and (pointer: fine) {
  .btn:hover { filter: brightness(1.05); }
}
.btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 color-mix(in oklch, var(--ink-faint), black 25%);
}

.btn-primary {
  background: var(--action);
  color: white;
  box-shadow: 0 4px 0 var(--action-dark);
}
.btn-primary:active { box-shadow: 0 0 0 var(--action-dark); }

.btn-info {
  background: var(--info);
  box-shadow: 0 4px 0 var(--info-dark);
}
.btn-info:active { box-shadow: 0 0 0 var(--info-dark); }

.btn-neutral {
  background: var(--paper);
  color: var(--ink-soft);
  border: 2px solid var(--line-strong);
  box-shadow: 0 4px 0 var(--line-strong);
}
.btn-neutral:hover { color: var(--ink); }
.btn-neutral:active { box-shadow: 0 0 0 var(--line-strong); }

.btn-danger-ghost {
  background: var(--paper);
  color: var(--danger);
  border: 2px solid color-mix(in oklch, var(--danger), white 55%);
  box-shadow: 0 4px 0 color-mix(in oklch, var(--danger), white 55%);
}
.btn-danger-ghost:active {
  box-shadow: 0 0 0 color-mix(in oklch, var(--danger), white 55%);
}

/* Lab cards */
.lab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--sp-5);
}

.lab-card {
  --lab-color: var(--blue);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 2px solid color-mix(in oklch, var(--lab-color), white 55%);
  border-radius: var(--r-xl);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base), border-color var(--dur-base);
}
@media (hover: hover) and (pointer: fine) {
  .lab-card:hover {
    transform: translateY(-3px);
    border-color: var(--lab-color);
    box-shadow: 0 8px 0 -4px color-mix(in oklch, var(--lab-color), white 70%);
  }
}
.lab-card:focus-visible {
  border-color: var(--lab-color);
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}
.lab-card:active { transform: translateY(1px); }

.lab-card-top {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-5) 0;
}
.lab-monogram {
  width: 48px;
  height: 48px;
  border-radius: var(--r-md);
  background: var(--lab-color);
  color: white;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  flex: none;
  box-shadow: 0 3px 0 color-mix(in oklch, var(--lab-color), black 22%);
}
.lab-card-head { flex: 1; min-width: 0; }

.lab-card-body {
  padding: var(--sp-4) var(--sp-5) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  flex: 1;
}
.lab-date {
  font-size: .72rem;
  font-weight: 800;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--lab-color);
}
.lab-card-title { font-size: 1.15rem; font-weight: 800; }
.lab-sub { color: var(--ink-soft); font-size: .88rem; font-weight: 700; }
.lab-topic { color: var(--ink-faint); font-size: .85rem; font-weight: 600; line-height: 1.45; flex: 1; }
.lab-card-cta {
  margin-top: var(--sp-3);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-display);
  font-size: .85rem;
  font-weight: 800;
  color: var(--lab-color);
}

/* Lab detail */
.lab-header { margin-bottom: var(--sp-2); }

.tabbar {
  display: inline-flex;
  gap: 4px;
  flex-wrap: nowrap;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--r-full);
  padding: 4px;
  margin-bottom: var(--sp-5);
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  align-self: flex-start;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-full);
  border: none;
  font-family: var(--font-display);
  font-size: .9rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-decoration: none;
  white-space: nowrap;
  background: transparent;
  transition: background-color var(--dur-base), color var(--dur-base), box-shadow var(--dur-base);
}
@media (hover: hover) and (pointer: fine) {
  .tab:hover { color: var(--ink); background: var(--wall-strong); }
}
.tab.is-active {
  background: var(--info);
  color: white;
  box-shadow: 0 3px 0 var(--info-dark);
}
.tab.is-active .icon { color: white; }

.panel { animation: panel-in var(--dur-slow) var(--ease-out); }
@keyframes panel-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.sub { color: var(--ink-soft); font-size: .9rem; font-weight: 600; }

/* Embeds */
.embed-wrap,
.pdf-frame-wrap {
  border: 2px solid var(--line);
  border-radius: var(--r-xl);
  overflow: hidden;
  background: var(--paper);
  min-height: min(72dvh, 880px);
  box-shadow: 0 4px 0 var(--line);
}

.embed-frame,
.pdf-frame {
  width: 100%;
  height: min(72dvh, 880px);
  border: none;
  display: block;
  background: var(--paper);
}

/* SQL compiler */
.compiler-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-5);
}

.editor-card {
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  box-shadow: 0 4px 0 var(--line);
}

.chip-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.chip {
  min-height: 44px;
  padding: var(--sp-2) var(--sp-4);
  border: 2px solid var(--line-strong);
  border-radius: var(--r-full);
  background: var(--paper);
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--line-strong);
  transition: border-color var(--dur-fast), color var(--dur-fast), transform var(--dur-fast);
}
@media (hover: hover) and (pointer: fine) {
  .chip:hover { border-color: var(--blue); color: var(--blue-dark); }
}
.chip:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 var(--line-strong);
}

.cm-shell {
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-3);
}

.kbd-hint { font-size: .78rem; color: var(--ink-faint); font-weight: 600; }
kbd {
  font-family: var(--font-mono);
  font-size: .75rem;
  background: var(--wall);
  border: 2px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  font-weight: 600;
}

.results-card {
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
  min-height: 180px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  box-shadow: 0 4px 0 var(--line);
}

.result-meta {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
  font-size: .85rem;
  color: var(--ink-soft);
  font-weight: 700;
  font-family: var(--font-display);
}
.result-meta .ok { color: var(--green-dark); display: flex; align-items: center; gap: 5px; }
.result-meta .metric { font-variant-numeric: tabular-nums; }

.source-details summary {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  padding: var(--sp-2) 0;
}
.source-pre {
  background: var(--wall);
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  font-family: var(--font-mono);
  font-size: .75rem;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
  margin-top: var(--sp-3);
}
.source-pre-sm { font-size: .7rem; margin-top: var(--sp-2); }

/* Tables */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.data-table-wrap {
  border: 2px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--paper);
}
table.data-table { border-collapse: collapse; width: 100%; min-width: max-content; font-size: .88rem; }
table.data-table th {
  background: var(--wall-strong);
  text-align: left;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-weight: 800;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 2px solid var(--line);
}
table.data-table td {
  padding: var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
table.data-table tbody tr:last-child td { border-bottom: none; }
.null-value { color: var(--ink-faint); font-style: italic; font-weight: 600; }

/* Schema */
.schema-stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.card {
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
  box-shadow: 0 4px 0 var(--line);
}
.schema-card-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.schema-name { font-family: var(--font-mono); font-size: .95rem; font-weight: 700; }
.schema-count {
  margin-left: auto;
  font-size: .8rem;
  color: var(--blue-dark);
  font-family: var(--font-display);
  font-weight: 800;
  background: color-mix(in oklch, var(--blue), white 88%);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-full);
}
.schema-cols { font-family: var(--font-mono); font-size: .78rem; color: var(--ink-soft); margin-bottom: var(--sp-2); font-weight: 600; }

/* Banners */
.banner {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  padding: var(--sp-4);
  border-radius: var(--r-md);
  border: 2px solid;
  font-size: .9rem;
  font-weight: 600;
}
.banner-error { background: color-mix(in oklch, var(--red), white 92%); border-color: color-mix(in oklch, var(--red), white 70%); color: #991b1b; }
.banner-success { background: color-mix(in oklch, var(--green), white 92%); border-color: color-mix(in oklch, var(--green), white 70%); color: #166534; }
.banner-empty { background: var(--wall); border-color: var(--line); color: var(--ink-soft); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-2);
  padding: var(--sp-10);
  color: var(--ink-soft);
  font-weight: 600;
}
.empty-state .icon { width: 44px; height: 44px; color: var(--ink-faint); }

/* Toasts */
.toast-stack {
  position: fixed;
  right: calc(var(--sp-5) + var(--safe-right));
  bottom: calc(var(--sp-5) + var(--safe-bottom));
  display: flex;
  flex-direction: column-reverse;
  gap: var(--sp-2);
  z-index: 200;
  width: min(320px, calc(100vw - 2rem));
}
.toast {
  background: var(--ink);
  color: white;
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: .88rem;
  font-weight: 700;
  font-family: var(--font-display);
  box-shadow: 0 4px 0 color-mix(in oklch, var(--ink), black 20%);
}
.toast-success { background: var(--green-dark); box-shadow: 0 4px 0 color-mix(in oklch, var(--green-dark), black 15%); }
.toast-error { background: var(--red-dark); box-shadow: 0 4px 0 color-mix(in oklch, var(--red-dark), black 15%); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity 200ms, transform 200ms; }

/* CodeMirror */
.CodeMirror {
  height: min(42dvh, 320px);
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.6;
}
.cm-s-default .cm-keyword { color: var(--blue-dark); font-weight: 700; }
.cm-s-default .cm-string { color: var(--green-dark); }
.cm-s-default .cm-comment { color: var(--ink-faint); font-style: italic; }

@media (min-width: 900px) {
  .compiler-layout { grid-template-columns: 1.1fr .9fr; align-items: start; }
}

@media (max-width: 640px) {
  .app {
    padding-left: calc(var(--sp-3) + var(--safe-left));
    padding-right: calc(var(--sp-3) + var(--safe-right));
  }
  .tabbar { align-self: stretch; width: 100%; }
  .tab .tab-label { font-size: .8rem; }
  .embed-frame, .pdf-frame { height: min(65dvh, 680px); }
  .lab-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
  .panel { animation: none; }
  .btn:active, .lab-card:hover, .lab-card:active { transform: none; }
  .toast.leaving { transform: none; }
}
