:root {
  --bg: #0c1218;
  --panel: #141c24;
  --line: rgba(45, 212, 191, 0.16);
  --text: #e8f4f2;
  --muted: #7b9aa3;
  --accent: #2dd4bf;
  --accent-dim: #14b8a6;
  --ok: #34d399;
  --sans: "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Mono", "Consolas", monospace;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

html.embed {
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  background: #020608;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

body.embed {
  padding: 0;
  min-height: 100%;
  height: 100%;
  overflow: hidden;
  align-items: stretch;
}

body.embed .shell {
  width: 100%;
  max-width: none;
  border-radius: 0;
  box-shadow: none;
  border: none;
  min-height: 100%;
  height: 100%;
}

.shell {
  width: min(720px, 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #1a2430, #121a22);
  border-bottom: 1px solid var(--line);
}

.titlebar .dots {
  display: flex;
  gap: 6px;
}

.titlebar .dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.titlebar .dots span:nth-child(1) { background: #ef4444; opacity: 0.85; }
.titlebar .dots span:nth-child(2) { background: #f59e0b; opacity: 0.85; }
.titlebar .dots span:nth-child(3) { background: #22c55e; opacity: 0.85; }

.titlebar h1 {
  margin: 0;
  flex: 1;
  font-size: 0.88rem;
  font-weight: 600;
}

.gear {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.gear:hover:not(:disabled) {
  color: var(--text);
  border-color: rgba(45, 212, 191, 0.35);
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.15);
}

.tabs button {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 12px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(45, 212, 191, 0.06);
}

.tabs button:disabled {
  cursor: default;
  opacity: 1;
}

.block-title {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.main {
  padding: 20px 18px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  overflow: hidden;
}

body.embed .main {
  padding: 12px 14px 10px;
  gap: 10px;
}

body.embed .console {
  display: none;
}

body.embed .gear {
  display: none;
}

body.embed #settingsBackdrop {
  display: none !important;
}

body.embed .status-line {
  font-size: 0.78rem;
  padding: 8px 10px;
}

body.embed .hint {
  font-size: 0.76rem;
}

body.embed .btn {
  padding: 11px 14px;
  font-size: 0.84rem;
}

body.embed .titlebar h1 {
  font-size: 0.82rem;
}

.panel {
  display: none;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.panel.active {
  display: flex;
}

.hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}

.btn-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 14px 18px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  color: #042f2e;
  background: linear-gradient(180deg, var(--accent), var(--accent-dim));
  text-align: center;
}

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.on {
  box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.35);
}

.status-line {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.status-line strong {
  color: var(--ok);
}

.console {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #060a0e;
  min-height: 72px;
  max-height: 120px;
  overflow: auto;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.5;
  color: #9cb3c7;
  scrollbar-color: #243038 transparent;
}

.console .ok { color: var(--ok); }

.settings-backdrop {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 20;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.settings-backdrop.open {
  display: flex;
}

.settings-backdrop[hidden] {
  display: none !important;
}

.settings {
  width: min(400px, 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 18px 16px;
}

.settings h2 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.settings label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.settings select {
  width: 100%;
  background: #0a1016;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 10px;
  font-family: inherit;
  font-size: 0.85rem;
  margin-bottom: 14px;
}

.settings .close-row {
  display: flex;
  justify-content: flex-end;
}

.embed-shield {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  cursor: default;
  background: transparent;
}

body.embed .embed-shield {
  display: block;
  z-index: 50;
}

body.embed button,
body.embed select {
  pointer-events: none;
}