/* Classweb — shell stylesheet */

:root {
  color-scheme: dark;
  --bg: #08090c;
  --chrome: #0b0d12;
  --surface: #11141b;
  --surface-2: #161a23;
  --surface-3: #1c212c;
  --line: #1e232e;
  --line-strong: #2a3040;
  --text: #e9ebf1;
  --muted: #8a92a6;
  --muted-2: #5f6678;
  --accent: #7b8cff;
  --accent-2: #b08cff;
  --danger: #ff6b6b;
  --ok: #4ade80;
  --radius-sm: 8px;
  --radius: 12px;
  --tab-h: 34px;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont,
    "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

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

html,
body {
  height: 100%;
}

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

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

button {
  border: 0;
  background: none;
  cursor: pointer;
}

input {
  border: 0;
  background: none;
  outline: none;
}

i.bi {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

kbd {
  padding: 1px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

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

.omnibox input:focus-visible,
.home-search input:focus-visible {
  outline: none;
}

/* ---------------------------------------------------------------- layout */

.app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr);
  height: 100dvh;
  min-height: 0;
}

.chrome {
  position: relative;
  z-index: 20;
  background: var(--chrome);
  border-bottom: 1px solid var(--line);
  user-select: none;
}

/* ------------------------------------------------------------- tab strip */

.tabstrip {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  min-width: 0;
  padding: 8px 8px 0;
  background: var(--chrome);
}

.tabs {
  display: flex;
  flex: 0 1 auto;
  gap: 4px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  padding-bottom: 0;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 220px;
  min-width: 108px;
  max-width: 220px;
  height: var(--tab-h);
  padding: 0 6px 0 10px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 9px 9px 0 0;
  color: var(--muted);
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
}

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

.tab[aria-selected="true"] {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.tab-icon {
  flex: none;
  font-size: 12.5px;
  color: var(--muted-2);
}

.tab[aria-selected="true"] .tab-icon {
  color: var(--accent);
}

.tab-dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(123, 140, 255, 0.16);
}

.tab-dot[hidden] {
  display: none;
}

.tab-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.005em;
}

.tab-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  color: var(--muted-2);
  font-size: 10px;
  opacity: 0;
  transition: opacity 0.12s var(--ease), background 0.12s var(--ease), color 0.12s var(--ease);
}

.tab:hover .tab-close,
.tab[aria-selected="true"] .tab-close,
.tab:focus-within .tab-close {
  opacity: 1;
}

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

.tab-new {
  margin-bottom: 5px;
}

.tabstrip-fill {
  flex: 1;
  min-width: 8px;
}

.tabstrip > .icon-btn {
  margin-bottom: 5px;
}

/* --------------------------------------------------------------- buttons */

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13.5px;
  transition: background 0.12s var(--ease), color 0.12s var(--ease), opacity 0.12s var(--ease);
}

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

.icon-btn:active:not(:disabled) {
  background: var(--surface-3);
}

.icon-btn:disabled {
  opacity: 0.32;
  cursor: default;
}

/* --------------------------------------------------------------- toolbar */

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 50px;
  padding: 0 10px 8px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

.nav .icon-btn {
  width: 32px;
  height: 32px;
}

.nav-end {
  margin-left: 2px;
}

.omnibox {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 6px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--chrome);
  transition: border-color 0.14s var(--ease), box-shadow 0.14s var(--ease),
    background 0.14s var(--ease);
}

.omnibox:hover {
  border-color: #39415a;
}

.omnibox:focus-within {
  border-color: rgba(123, 140, 255, 0.62);
  background: #0d1017;
  box-shadow: 0 0 0 3px rgba(123, 140, 255, 0.09);
}

.omnibox-icon {
  flex: none;
  font-size: 12.5px;
  color: var(--muted-2);
  transition: color 0.14s var(--ease);
}

.omnibox-icon[data-secure="true"] {
  color: var(--ok);
}

.omnibox input {
  flex: 1;
  min-width: 0;
  height: 100%;
  font-size: 13px;
  letter-spacing: 0.005em;
}

.omnibox input::placeholder {
  color: var(--muted-2);
}

.omnibox-go {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  color: var(--muted-2);
  font-size: 11px;
  opacity: 0;
  transition: opacity 0.12s var(--ease), background 0.12s var(--ease);
}

.omnibox:focus-within .omnibox-go {
  opacity: 1;
}

.omnibox-go:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* -------------------------------------------------------------- load bar */

.loadbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.25s var(--ease);
  pointer-events: none;
}

.loadbar[data-active="true"] {
  opacity: 1;
}

.loadbar span {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 38%;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), transparent);
  animation: sweep 1.15s var(--ease) infinite;
}

@keyframes sweep {
  from {
    left: -40%;
  }
  to {
    left: 100%;
  }
}

/* --------------------------------------------------------------- viewport */

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

.frames {
  position: absolute;
  inset: 0;
}

.frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--bg);
}

.frame[hidden] {
  display: none;
}

/* ------------------------------------------------------------------ home */

.home {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 32px 24px 56px;
}

.home[hidden] {
  display: none;
}

.home-glow {
  position: absolute;
  top: 34%;
  left: 50%;
  width: min(920px, 120vw);
  height: 460px;
  transform: translate(-50%, -50%);
  background: radial-gradient(
    ellipse at center,
    rgba(123, 140, 255, 0.16) 0%,
    rgba(176, 140, 255, 0.08) 38%,
    transparent 70%
  );
  filter: blur(10px);
  pointer-events: none;
}

.home-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 660px;
  text-align: center;
}

.wordmark {
  margin: 0;
  font-size: clamp(46px, 7.4vw, 78px);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.02;
  background: linear-gradient(180deg, #ffffff 0%, #dfe3ff 52%, #9fabff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 34px rgba(123, 140, 255, 0.32));
}

.tagline {
  margin: 12px 0 32px;
  color: var(--muted);
  font-size: 13.5px;
  letter-spacing: 0.012em;
}

.home-search {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(600px, 100%);
  height: 56px;
  padding: 0 16px 0 20px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: linear-gradient(180deg, #12151d 0%, #0c0f15 100%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.035);
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}

.home-search:hover {
  border-color: #3a4258;
}

.home-search:focus-within {
  border-color: rgba(123, 140, 255, 0.7);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 0 4px rgba(123, 140, 255, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.home-search > i {
  flex: none;
  color: var(--muted-2);
  font-size: 15px;
}

.home-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  font-size: 15px;
}

.home-search input::placeholder {
  color: var(--muted-2);
}

.key-hint {
  flex: none;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.home-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
  color: var(--muted-2);
  font-size: 12px;
  letter-spacing: 0.01em;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted-2);
  transition: background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.status-dot[data-state="connecting"] {
  background: #d6a84c;
  box-shadow: 0 0 0 3px rgba(214, 168, 76, 0.16);
  animation: pulse 1.6s ease-in-out infinite;
}

.status-dot[data-state="ready"] {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.14);
}

.status-dot[data-state="error"] {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.16);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.shortcuts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  margin: 40px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted-2);
  font-size: 11.5px;
}

.shortcuts li {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ------------------------------------------------------------------ boot */

.boot {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity 0.3s var(--ease), visibility 0.3s var(--ease);
}

.boot[hidden] {
  display: grid;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
}

.boot-mark {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: linear-gradient(140deg, var(--accent) 0%, var(--accent-2) 100%);
  box-shadow: 0 12px 40px rgba(123, 140, 255, 0.35);
  animation: breathe 2.4s ease-in-out infinite;
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.94);
    opacity: 0.72;
  }
}

.boot-text {
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: 0.02em;
}

.boot-text[data-state="error"] {
  color: var(--danger);
  max-width: 420px;
}

/* ----------------------------------------------------------------- sheet */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(4, 5, 8, 0.6);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s var(--ease), visibility 0.22s var(--ease);
}

.scrim[data-open="true"] {
  opacity: 1;
  visibility: visible;
}

.sheet {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  width: min(392px, 100vw);
  background: var(--chrome);
  border-left: 1px solid var(--line);
  box-shadow: -30px 0 80px rgba(0, 0, 0, 0.55);
  transform: translateX(102%);
  visibility: hidden;
  transition: transform 0.26s var(--ease), visibility 0.26s var(--ease);
}

.sheet[data-open="true"] {
  transform: none;
  visibility: visible;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 16px 22px;
  border-bottom: 1px solid var(--line);
}

.sheet-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px 22px 28px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.field {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.field-end {
  border-bottom: 0;
}

.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.field-note {
  color: var(--muted-2);
  font-size: 11px;
}

.field-help {
  margin: 10px 0 0;
  color: var(--muted-2);
  font-size: 11.5px;
  line-height: 1.5;
}

.field-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.select,
.input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  transition: border-color 0.14s var(--ease), box-shadow 0.14s var(--ease);
}

.select {
  appearance: none;
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.select:focus,
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(123, 140, 255, 0.14);
  outline: none;
}

.btn {
  flex: none;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  transition: background 0.12s var(--ease), border-color 0.12s var(--ease), opacity 0.12s var(--ease);
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: #3a4258;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-accent {
  border-color: rgba(123, 140, 255, 0.5);
  background: rgba(123, 140, 255, 0.14);
  color: #c6ceff;
}

.btn-accent:hover:not(:disabled) {
  background: rgba(123, 140, 255, 0.22);
  border-color: rgba(123, 140, 255, 0.7);
}

.btn-danger {
  width: 100%;
  border-color: rgba(255, 107, 107, 0.32);
  color: #ffb4b4;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(255, 107, 107, 0.1);
  border-color: rgba(255, 107, 107, 0.5);
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  flex: none;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease);
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.18s var(--ease), background 0.16s var(--ease);
}

.switch input:checked + .switch-track {
  background: rgba(123, 140, 255, 0.28);
  border-color: rgba(123, 140, 255, 0.6);
}

.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(14px);
  background: #cdd4ff;
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.switch-text {
  color: var(--muted);
  font-size: 12.5px;
}

.meta {
  margin: 0;
  display: grid;
  gap: 8px;
}

.meta div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
}

.meta dt {
  color: var(--muted-2);
}

.meta dd {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
}

/* ---------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: rgba(17, 20, 27, 0.96);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
  color: var(--text);
  font-size: 12.5px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
  pointer-events: auto;
}

.toast[data-visible="true"] {
  opacity: 1;
  transform: none;
}

.toast i {
  color: var(--muted);
  font-size: 12.5px;
}

.toast[data-kind="error"] i {
  color: var(--danger);
}

.toast[data-kind="ok"] i {
  color: var(--ok);
}

/* ------------------------------------------------------------- fallbacks */

.noscript {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  color: var(--muted);
  text-align: center;
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 720px) {
  .tabstrip {
    padding: 6px 6px 0;
  }

  .tab {
    flex-basis: 168px;
    min-width: 92px;
  }

  .toolbar {
    gap: 4px;
    padding: 0 6px 6px;
    height: 46px;
  }

  .nav .icon-btn {
    width: 30px;
    height: 30px;
  }

  .omnibox {
    height: 32px;
    padding-left: 10px;
    gap: 7px;
  }

  .omnibox input {
    font-size: 12.5px;
  }

  .home {
    padding: 24px 18px 60px;
  }

  .tagline {
    margin-bottom: 26px;
  }

  .home-search {
    height: 50px;
  }

  .key-hint,
  .shortcuts {
    display: none;
  }

  .sheet {
    top: auto;
    left: 0;
    width: auto;
    max-height: 78dvh;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    transform: translateY(102%);
  }

  .sheet[data-open="true"] {
    transform: none;
  }
}

@media (max-width: 460px) {
  .tab {
    flex-basis: 140px;
  }

  .tabstrip > #fullscreen-toggle {
    display: none;
  }
}

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