/* Hyperion Live — Light minimalist theme */

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

:root {
  --bg: #ffffff;
  --bg-page: #f5f7f9;
  --bg-card: #ffffff;
  --border: #e5e8eb;
  --border-light: #f0f1f3;

  --text: #1a1f25;
  --text-dim: #5f6b7a;
  --text-muted: #9ca3ad;

  --accent: #2563eb;
  --accent-light: #eff6ff;
  --accent-hover: #1d4ed8;
  --accent-text: #ffffff;

  --danger: #ef4444;
  --danger-light: #fef2f2;
  --warn: #f59e0b;
  --warn-light: #fffbeb;
  --success: #10b981;
  --success-light: #ecfdf5;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 4px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

  --font-sans: 'Inter', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 150ms;
  --t-mid: 250ms;

  --topbar-h: 48px;
  --tabbar-h: 56px;
  --drawer-w: 300px;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-page);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; }

/* ---- shell ---- */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ---- top bar ---- */
.topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  gap: 10px;
  z-index: 20;
}
.topbar .brand {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}
.topbar .spacer { flex: 1; }
.topbar .btn-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.topbar .btn-icon:hover { background: var(--bg-page); color: var(--text); }
.topbar .btn-icon svg { width: 20px; height: 20px; }

/* ---- pill ---- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
}
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.pill[data-state="disconnected"] { color: var(--text-muted); }
.pill[data-state="connecting"] { color: var(--warn); border-color: var(--warn); background: var(--warn-light); }
.pill[data-state="connecting"] .pill-dot { animation: pulse 1.2s ease-in-out infinite; }
.pill[data-state="idle"] { color: var(--success); border-color: var(--success); background: var(--success-light); }
.pill[data-state="streaming"] { color: var(--accent); border-color: var(--accent); background: var(--accent-light); }
.pill[data-state="streaming"] .pill-dot { animation: pulse 1s ease-in-out infinite; }
.pill[data-state="error"] { color: var(--danger); border-color: var(--danger); background: var(--danger-light); }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.4; } }

/* ---- action bar ---- */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
}
.action-bar .btn { min-height: 36px; font-size: 13px; padding: 0 14px; }

/* ---- device info (in drawer) ---- */
.device-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  color: var(--text-dim);
  padding: 8px 12px;
  background: var(--bg-page);
  border-radius: var(--radius-sm);
  min-height: 20px;
}
.device-info:empty { display: none; }
.device-info .mono { font-family: var(--font-mono); font-size: 11px; }

/* ---- tab content ---- */
.tab-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.tab-panel {
  display: none;
  padding: 20px 16px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}
.tab-panel.active { display: block; }

/* -- luminance tab -- */
.hero-value {
  text-align: center;
  padding: 24px 0 8px;
}
.hero-value .number {
  font-family: var(--font-mono);
  font-size: 48px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.1;
}
.hero-value .unit {
  font-size: 14px;
  color: var(--text-muted);
  margin-left: 4px;
}
.hero-flags {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.y-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 4px 4px;
  height: 300px;
  overflow: hidden;
}

/* -- chroma tab -- */
.cie-container {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  margin-bottom: 16px;
}
.cie-wrap {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
}
.cie-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-xs);
}

.values-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.val-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}
.val-card .val-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.val-card .val-num {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
}

.xy-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.xy-row .val-card { flex: 1; }

.chroma-flags {
  display: flex;
  justify-content: center;
  gap: 8px;
}

/* -- flag tag -- */
.flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-page);
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: all var(--t-fast);
}
.flag[data-on="true"] { color: var(--danger); border-color: var(--danger); background: var(--danger-light); font-weight: 500; }

/* ---- bottom tab bar ---- */
.tabbar {
  height: var(--tabbar-h);
  min-height: var(--tabbar-h);
  padding-bottom: var(--safe-bottom);
  display: flex;
  align-items: stretch;
  background: var(--bg);
  border-top: 1px solid var(--border);
  z-index: 20;
}
.tabbar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.tabbar button svg { width: 22px; height: 22px; stroke-width: 1.75; }
.tabbar button.active { color: var(--accent); }
.tabbar button:not(.active):hover { color: var(--text-dim); }

/* ---- settings drawer ---- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-mid) var(--ease);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: var(--drawer-w);
  max-width: 85vw;
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  transform: translateX(100%);
  transition: transform var(--t-mid) var(--ease);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
}
.drawer-body {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.drawer-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.drawer-footer .mono { font-family: var(--font-mono); font-size: 11px; }

/* ---- form controls in drawer ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.field-label .hint { color: var(--text-muted); font-weight: 400; font-size: 11px; }

.input {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 8px 10px;
  color: var(--text);
  font-family: var(--font-mono);
  min-height: 40px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.input:disabled { opacity: 0.5; cursor: not-allowed; }

.field-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}

/* switch */
.switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: 11px;
  transition: background var(--t-fast);
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: white;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: left var(--t-fast) var(--ease);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { left: 20px; }

/* seg buttons (gain) */
.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  overflow: hidden;
}
.seg button {
  flex: 1;
  min-height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--bg);
  transition: background var(--t-fast), color var(--t-fast);
}
.seg button:not(:last-child) { border-right: 1px solid var(--border); }
.seg button:hover { background: var(--bg-page); }
.seg button[aria-pressed="true"] { background: var(--accent-light); color: var(--accent); }

/* ---- buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost { background: var(--bg); color: var(--accent); border-color: var(--border); }
.btn-ghost:hover { background: var(--accent-light); border-color: var(--accent); }

.btn-danger { background: var(--bg); color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger-light); border-color: var(--danger); }

.btn-block { width: 100%; }

/* ---- toast ---- */
.toast-stack {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 380px;
}
.toast {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: toast-in var(--t-mid) var(--ease);
  text-align: center;
}
.toast[data-tone="error"] { border-color: var(--danger); background: var(--danger-light); }
.toast[data-tone="success"] { border-color: var(--success); background: var(--success-light); }
.toast[data-tone="warn"] { border-color: var(--warn); background: var(--warn-light); }
@keyframes toast-in { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }

/* ---- responsive ---- */
@media (min-width: 768px) {
  .tab-panel { max-width: 640px; padding: 24px 24px; }
  .hero-value .number { font-size: 56px; }
  .y-wrap { height: 360px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
