@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@300;400;500;600&display=swap');

:root {
  --bg: #0d0e11;
  --surface: #13151a;
  --surface2: #1a1d24;
  --border: rgba(255,255,255,0.07);
  --border-bright: rgba(255,255,255,0.13);
  --text: #e8eaf0;
  --muted: rgba(232,234,240,0.45);
  --accent: #00e5a0;
  --accent2: #3b82f6;
  --warn: #f59e0b;
  --danger: #ef4444;
  --ok: #00e5a0;
  --font-sans: 'IBM Plex Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
  --radius: 12px;
  --radius-sm: 8px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 20px;
  font-size: 14px;
  line-height: 1.5;
}

/* subtle grid background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

.wrap {
  max-width: 1600px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* ========================
   HEADER
   ======================== */

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

.header-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

h1 {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

h1 span {
  color: var(--accent);
}

.header-sub {
  font-size: 13px;
  color: var(--muted);
  max-width: 500px;
}

.hint {
  background: rgba(0,229,160,0.06);
  border: 1px solid rgba(0,229,160,0.18);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--accent);
  font-family: var(--font-mono);
  align-self: flex-start;
}

/* ========================
   GRID
   ======================== */

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

@media (min-width: 980px) {
  .grid { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .card--cam   { grid-column: span 6; }
  .card--mic   { grid-column: span 6; }
  .card--kbd   { grid-column: 1 / -1; }
  .card--sound { grid-column: span 6; }
  .card--lcd   { grid-column: span 6; }
  .card--bat   { grid-column: span 6; }
  .card--sys   { grid-column: span 6; }
}

/* ========================
   CARDS
   ======================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 300px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.card:hover {
  border-color: var(--border-bright);
}

/* top-left accent line */
.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 40px;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 2px 0;
}

.card--cam  { min-height: 500px; }
.card--mic  { min-height: 360px; }
.card--kbd  { min-height: 460px; }
.card--sound{ min-height: 340px; }
.card--lcd  { min-height: 340px; }
.card--bat  { min-height: 300px; }
.card--sys  { min-height: 300px; }

/* ========================
   CARD HEADING
   ======================== */

h2 {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

h2 .icon { font-size: 14px; }

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

.mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ========================
   ROW / BUTTONS
   ======================== */

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

button {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-bright);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  transition: all 0.12s ease;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

button:hover:not(:disabled) {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.22);
  color: #fff;
}

button:active:not(:disabled) {
  transform: translateY(1px);
  background: rgba(255,255,255,0.03);
}

button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* primary accent button */
button.primary {
  background: rgba(0,229,160,0.1);
  border-color: rgba(0,229,160,0.35);
  color: var(--accent);
}

button.primary:hover:not(:disabled) {
  background: rgba(0,229,160,0.18);
  border-color: var(--accent);
}

/* ========================
   PILL / STATUS
   ======================== */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-bright);
  background: var(--surface2);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.pill::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
}

.ok   { color: var(--ok);     border-color: rgba(0,229,160,0.3);  background: rgba(0,229,160,0.06); }
.warn { color: var(--warn);   border-color: rgba(245,158,11,0.3);  background: rgba(245,158,11,0.06); }
.bad  { color: var(--danger); border-color: rgba(239,68,68,0.3);   background: rgba(239,68,68,0.06); }

hr {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ========================
   MEDIA
   ======================== */

video {
  width: 100%;
  max-height: 300px;
  background: #000;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.card canvas {
  width: 100%;
  max-height: 220px;
  background: #000;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: block;
}

audio {
  width: 100%;
  filter: invert(1) hue-rotate(180deg) brightness(0.85);
  border-radius: var(--radius-sm);
}

/* ========================
   METER
   ======================== */

.meter {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--surface2);
  overflow: hidden;
  border: 1px solid var(--border);
}

.bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #f59e0b, var(--danger));
  transition: width 60ms linear;
  border-radius: 999px;
}

/* ========================
   TABLE
   ======================== */

table {
  width: 100%;
  border-collapse: collapse;
}

td, th {
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  font-size: 13px;
}

th {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  font-weight: 500;
  width: 38%;
}

td {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  word-break: break-all;
}

tr:last-child td,
tr:last-child th {
  border-bottom: none;
}

/* =========================
   KEYBOARD
   ========================= */

.kbdBox{
  border: 1px dashed rgba(255,255,255,0.22);
  border-radius: 16px;
  padding: 16px;
  min-height: 120px;
  outline: none;
  overflow-x: auto;
  overflow-y: hidden;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.025));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

.kbdBox:focus{
  border-color: rgba(90,169,255,0.38);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.03),
    0 0 0 3px rgba(90,169,255,0.10);
}

.kbd{
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  min-width: 1460px;
}

.kbd-row{
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 18px;
  align-items: center;
}

.kbd-section{
  display: flex;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}

.kbd-section--nav{
  min-width: 250px;
  justify-content: flex-start;
}

.kbd-section--numpad{
  min-width: 250px;
  justify-content: flex-start;
}

.k{
  user-select: none;
  text-align: center;
  padding: 10px 6px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.04));
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.15;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 0 0 48px;
  color: #f2f6ff;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.04),
    0 2px 8px rgba(0,0,0,0.14);
  transition:
    transform .12s ease,
    background .12s ease,
    border-color .12s ease,
    box-shadow .12s ease;
}

.k:hover{
  background:
    linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.05));
  border-color: rgba(255,255,255,0.16);
}

.k.small{
  font-size: 11px;
}

.k > div:first-child{
  font-weight: 700;
  letter-spacing: -0.01em;
}

.k > div:last-child{
  opacity: .62;
  font-size: 10px;
  margin-top: 3px;
  white-space: nowrap;
}

.k.w1   { flex-basis: 48px; }
.k.w15  { flex-basis: 72px; }
.k.w2   { flex-basis: 96px; }
.k.w25  { flex-basis: 120px; }
.k.w3   { flex-basis: 144px; }
.k.w4   { flex-basis: 320px; }

.k.enter{ flex-basis: 110px; }
.k.backspace{ flex-basis: 120px; }
.k.shift-left{ flex-basis: 140px; }
.k.shift-right{ flex-basis: 140px; }
.k.space{ flex-basis: 320px; }

.k.active{
  border-color: rgba(34,197,94,.7);
  background:
    linear-gradient(180deg, rgba(34,197,94,.26), rgba(34,197,94,.14));
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 0 0 2px rgba(34,197,94,.22);
}

.k.tested{
  border-color: rgba(90,169,255,.72);
  background:
    linear-gradient(180deg, rgba(90,169,255,.24), rgba(90,169,255,.12));
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 0 0 2px rgba(90,169,255,.18);
}

.k--ghost{
  visibility: hidden;
  pointer-events: none;
}

.k.active.tested{
  border-color: rgba(34,197,94,.85);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 0 0 2px rgba(34,197,94,.28);
}

/* ========================
   OVERLAYS
   ======================== */

#lcdOverlay {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

#lcdHint {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 10000;
  font-family: var(--font-mono);
  font-size: 12px;
}

#touchOverlay {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 9998;
  background: #000;
  overflow: hidden;
}

#touchHint {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 10000;
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: 12px;
}

#touchCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  border-radius: 0;
  display: block;
  touch-action: none;
  background: #000;
}

/* ========================
   INPUT RANGES
   ======================== */

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  vertical-align: middle;
  width: 100px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* label row for sliders */
label.muted {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-family: var(--font-mono);
}

/* ========================
   FOOTER NOTE
   ======================== */

.footer-note {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  opacity: 0.5;
}

/* ========================
   SCROLL
   ======================== */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ========================
   SECTION DIVIDER INSIDE LCD CARD
   ======================== */

.card--lcd h2:nth-of-type(2) {
  margin-top: 4px;
}
