:root {
  color-scheme: dark;
  --frame: #202124;
  --toolbar: #35363a;
  --omnibox: #202124;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --line: #3c4043;
  --blue: #8ab4f8;
  --amber: #fdd663;
  --amber-bg: #3d3412;
  --green: #81c995;
  --red: #f28b82;
  --panel: #292a2d;
  --card: #35363a;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--frame); color: var(--text); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.gate {
  min-height: 100%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at top, rgba(138, 180, 248, 0.16), transparent 55%),
    var(--frame);
  padding: 24px;
}
.gate-card {
  width: min(420px, 100%);
  background: #292a2d;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.gate-card h1 { margin: 8px 0 8px; font-size: 22px; font-weight: 500; }
.gate-card p { margin: 0 0 18px; color: var(--muted); line-height: 1.45; }
.gate-card label, dialog label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.gate-card input, dialog input[type="text"], dialog input[type="number"], dialog input[type="password"], .gate-card input {
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #202124;
  padding: 0 12px;
  color: var(--text);
}
.gate-card button, dialog button, .empty button, .takeover {
  height: 36px;
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  background: #8ab4f8;
  color: #202124;
  font-weight: 600;
}
.form-error { color: var(--red); min-height: 1.2em; }

.app { height: 100%; display: flex; flex-direction: column; }
.chrome { background: var(--frame); position: relative; }
.tabstrip {
  height: 44px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 6px 8px 0;
}
.brand { width: 40px; height: 34px; display: grid; place-items: center; flex: none; }
.tabs { display: flex; align-items: flex-end; gap: 2px; min-width: 0; overflow: hidden; }
.tab {
  height: 34px;
  max-width: 220px;
  min-width: 40px;
  padding: 0 8px 0 12px;
  border: 0;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.tab.active { background: var(--toolbar); color: var(--text); }
.tab:hover:not(.active) { background: #292a2d; }
.tab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab .close, .new-tab {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  flex: none;
}
.tab .close:hover, .new-tab:hover, .icon-btn:hover { background: rgba(255, 255, 255, 0.08); }
.new-tab { margin: 0 0 6px 2px; font-size: 18px; line-height: 1; }
.strip-spacer { flex: 1; }
.session-chip {
  margin-bottom: 6px;
  max-width: 220px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: #292a2d;
  color: var(--text);
  padding: 0 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icon-btn {
  width: 32px;
  height: 32px;
  margin-bottom: 4px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
}
.menu {
  position: absolute;
  top: 42px;
  right: 12px;
  z-index: 5;
  background: #2d2e31;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-width: 200px;
  padding: 6px;
  box-shadow: var(--shadow);
}
.menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: 0;
  border-radius: 8px;
  height: 36px;
  padding: 0 10px;
  font-weight: 500;
}
.menu button:hover { background: rgba(255, 255, 255, 0.08); }

.toolbar {
  height: 48px;
  background: var(--toolbar);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px 8px;
}
.toolbar .icon-btn { margin: 0; }
.omnibox {
  flex: 1;
  height: 34px;
  background: var(--omnibox);
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 14px;
  border: 1px solid transparent;
  min-width: 0;
}
.omnibox:focus-within { border-color: var(--blue); }
.omnibox input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
}
.lock { font-size: 12px; width: 16px; text-align: center; }
.star { border: 0; background: transparent; color: var(--muted); font-size: 16px; width: 28px; height: 28px; border-radius: 50%; }
.star.on { color: var(--amber); }
.takeover {
  background: transparent;
  color: var(--blue);
  border: 1px solid var(--blue);
  margin-left: 6px;
  white-space: nowrap;
}
.takeover.on { background: var(--amber); color: #202124; border-color: var(--amber); }
.bookmarks-bar {
  background: var(--toolbar);
  display: flex;
  gap: 6px;
  padding: 0 12px 8px;
  overflow: auto;
}
.bookmarks-bar button {
  border: 0;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 999px;
  height: 26px;
  padding: 0 10px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.infobar {
  background: var(--amber-bg);
  color: var(--amber);
  text-align: center;
  font-size: 13px;
  padding: 7px 16px;
}

.workspace { flex: 1; min-height: 0; display: flex; }
.stage-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #111214; position: relative; }
.stage { flex: 1; min-height: 0; display: grid; place-items: center; position: relative; outline: none; }
.stage.takeover { box-shadow: inset 0 0 0 3px var(--amber); }
.stage img { max-width: 100%; max-height: 100%; background: white; box-shadow: var(--shadow); }
.stage.takeover img { cursor: crosshair; }
.empty { text-align: center; max-width: 420px; padding: 24px; color: var(--muted); }
.empty h2 { color: var(--text); font-weight: 500; margin-bottom: 8px; }
.confirm {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  width: min(460px, calc(100% - 32px));
  background: #fff;
  color: #202124;
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.confirm p { margin: 0 0 12px; }
.confirm .dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.confirm .ghost { background: #e8eaed; color: #202124; }

.panel {
  width: 340px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.panel.hidden-panel { display: none; }
.panel-tabs { display: flex; gap: 2px; padding: 8px; border-bottom: 1px solid var(--line); }
.panel-tabs button {
  flex: 1;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.panel-tabs button.active { background: var(--card); color: var(--text); }
.pane { overflow: auto; padding: 8px; display: grid; gap: 8px; align-content: start; }
.card {
  background: var(--card);
  border-radius: 10px;
  padding: 10px 12px;
  display: grid;
  gap: 4px;
}
.card button.linkish, button.linkish {
  background: transparent;
  border: 0;
  color: var(--blue);
  text-align: left;
  padding: 0;
  height: auto;
  font-weight: 500;
}
.meta { color: var(--muted); font-size: 12px; }
.thumb { width: 100%; border-radius: 6px; margin-top: 6px; background: white; }
.row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.badge { font-size: 11px; border-radius: 999px; padding: 2px 8px; background: #202124; color: var(--muted); }
.badge.live { color: var(--green); }
.badge.warn { color: var(--amber); }
.danger { background: transparent; color: var(--red); border: 0; height: auto; padding: 0; }

dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #292a2d;
  color: var(--text);
  width: min(460px, calc(100% - 24px));
  padding: 20px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog h2 { margin: 0 0 8px; font-weight: 500; }
.hint { color: var(--muted); margin-top: 0; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex !important; align-items: center; gap: 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.ghost { background: transparent !important; color: var(--blue) !important; }
#key-value {
  background: #202124;
  border-radius: 8px;
  padding: 12px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #e8eaed;
  color: #202124;
  border-radius: 999px;
  padding: 10px 16px;
  z-index: 20;
  box-shadow: var(--shadow);
  max-width: min(560px, calc(100% - 24px));
}

@media (max-width: 980px) {
  .panel { position: absolute; right: 0; top: 92px; bottom: 0; z-index: 4; }
  .session-chip { display: none; }
}
