@keyframes wywa-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
#wywa-snap-spinner { position: absolute; left: 6px; opacity: 0; transition: opacity 0.15s; }
#wywa-snap-spinner.spinning { animation: wywa-spin 0.7s linear infinite; opacity: 1; }

/* Global themed tooltip via data-tip */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%) translateY(3px);
  white-space: nowrap;
  max-width: 260px;
  white-space: normal;
  text-align: center;
  background: var(--bg1);
  border: none;
  border-radius: var(--radius);
  color: var(--text2);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.5;
  padding: 5px 8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s 0.7s, transform 0.15s 0.7s;
  z-index: 99999;
}
[data-tip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
[data-tip-down]::after {
  bottom: auto;
  top: calc(100% + 7px);
  transform: translateX(-50%) translateY(-3px);
}
[data-tip-down]:hover::after { transform: translateX(-50%) translateY(0); }
[data-tip-left]::after {
  left: auto;
  right: 0;
  transform: translateX(0) translateY(3px);
}
[data-tip-left]:hover::after { transform: translateX(0) translateY(0); }

/* -- Dark Theme - Flat Terminal -- */

html {
  min-width: var(--app-min-width);
  overflow-x: auto;
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-h);
}

/* -- Flat button style - no bevel, no shadow -- */
button {
  transition: background 0.1s, color 0.1s, border-color 0.1s, filter 0.15s ease;
}
button:active {
  transform: none;
  filter: brightness(0.88);
  transition: filter 0.05s ease;
}

/* --- DOCS PAGE --- */
#view-docs.docs-view { max-width: 920px; margin: 0 auto; padding: 36px 36px 84px; }
#view-docs .docs-hero { margin-bottom: 22px; padding-bottom: 22px; border-bottom: 1px solid color-mix(in srgb, var(--border2) 44%, transparent); }
#view-docs .docs-eyebrow { font-family: var(--pixel); font-size: 7px; font-weight: 400; color: var(--accent); letter-spacing: 0; text-transform: uppercase; line-height: 1.35; margin-bottom: 9px; }
#view-docs .docs-title { max-width: 760px; font-family: var(--pixel); font-size: 13px; font-weight: 400; color: var(--text); letter-spacing: 0; line-height: 1.55; margin-bottom: 9px; text-transform: uppercase; }
#view-docs .docs-lead { max-width: 720px; font-family: var(--sans); font-size: 13px; color: var(--text3); line-height: 1.6; margin-bottom: 16px; }
#view-docs .docs-search-wrap { position: relative; max-width: 420px; }
#view-docs .docs-search-input { width: 100%; background: color-mix(in srgb, var(--bg1) 84%, transparent); border: 1px solid color-mix(in srgb, var(--border2) 70%, transparent); border-radius: 0; color: var(--text); font-family: var(--sans); font-size: 12px; padding: 9px 12px 9px 32px; box-sizing: border-box; outline: none; }
#view-docs .docs-search-input:focus { border-color: var(--accent); }
#view-docs .docs-search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; opacity: 0.4; }
#view-docs .docs-search-results { display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--bg1); border: 1px solid var(--border2); z-index: 999; max-height: 320px; overflow-y: auto; box-shadow: 0 18px 36px rgba(0,0,0,0.24); }
#view-docs .docs-search-empty { padding: 10px 14px; font-family: var(--mono); font-size: 10px; color: var(--text3); }
#view-docs .docs-search-row { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); transition: background 0.1s; }
#view-docs .docs-search-row:hover { background: var(--bg2); }
#view-docs .docs-search-row:last-child { border-bottom: none; }
#view-docs .docs-search-title { font-family: var(--sans); font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 3px; }
#view-docs .docs-search-snippet { font-family: var(--sans); font-size: 11px; color: var(--text3); line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#view-docs .docs-section.is-search-hit { background: rgba(var(--accent-rgb),0.07); transition: background 0.15s; }
#view-docs .docs-quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; margin-top: 18px; }
#view-docs .docs-quick-card { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 9px; row-gap: 2px; align-items: center; min-height: 62px; padding: 10px; background: color-mix(in srgb, var(--bg1) 68%, transparent); border: 1px solid color-mix(in srgb, var(--border2) 38%, transparent); box-sizing: border-box; }
#view-docs .docs-quick-card span { grid-row: 1 / span 2; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border: 1px solid color-mix(in srgb, var(--accent) 36%, transparent); color: var(--accent); font-family: var(--pixel); font-size: 7px; font-weight: 400; line-height: 1.2; }
#view-docs .docs-quick-card strong { font-family: var(--pixel); font-size: 7px; font-weight: 400; color: var(--text); letter-spacing: 0; line-height: 1.25; text-transform: uppercase; }
#view-docs .docs-quick-card em { font-family: var(--sans); font-size: 11px; font-style: normal; color: var(--text3); line-height: 1.35; }
#view-docs .docs-section { display: block; border-top: 1px solid color-mix(in srgb, var(--border2) 40%, transparent); padding: 30px 0; }
#view-docs .docs-section:first-child { border-top: none; }
#view-docs .docs-section-intro { border-top: none; padding-top: 0; margin-bottom: 8px; }
#view-docs .docs-section-title { display: inline-flex; align-items: center; font-family: var(--pixel); font-size: 9px; font-weight: 400; color: var(--accent); letter-spacing: 0; line-height: 1.35; text-transform: uppercase; margin-bottom: 8px; }
#view-docs .docs-section-lead { max-width: 760px; font-family: var(--sans); font-size: 13px; color: var(--text3); margin-bottom: 16px; line-height: 1.55; }
#view-docs .docs-subheading { display: inline-flex; align-items: center; min-height: 20px; font-family: var(--pixel); font-size: 7px; font-weight: 400; color: var(--accent); letter-spacing: 0; line-height: 1.3; text-transform: uppercase; margin-top: 22px; margin-bottom: 10px; border-left: 2px solid currentColor; padding: 0 0 0 9px; background: transparent; }
#view-docs .docs-subheading:first-child { margin-top: 0; }
#view-docs .docs-section-body { max-width: 820px; font-family: var(--sans); font-size: 13px; color: var(--text2); line-height: 1.75; }
#view-docs .docs-section-body p { margin: 0 0 12px; }
#view-docs .docs-section-body strong { color: var(--text); font-weight: 700; }
#view-docs .docs-kbd-table { width: 100%; border-collapse: collapse; margin-top: 4px; }
#view-docs .docs-kbd-table tr:hover td { background: transparent; }
#view-docs .docs-kbd-table tr { border-bottom: 1px solid color-mix(in srgb, var(--border2) 55%, transparent); }
#view-docs .docs-kbd-table tr:last-child { border-bottom: none; }
#view-docs .docs-kbd-table td { padding: 8px 4px; font-family: var(--sans); font-size: 12px; color: var(--text2); vertical-align: middle; }
#view-docs .docs-kbd-table td:first-child { width: 120px; padding-right: 12px; }
#view-docs .docs-kbd { display: inline-block; font-family: var(--mono); font-size: 9px; font-weight: 700; color: var(--text); background: var(--bg2); border: 1px solid var(--border2); border-radius: 0; padding: 1px 6px; margin: 0 2px 2px 0; white-space: nowrap; }
#view-docs .docs-note,
#view-docs .docs-callout { background: color-mix(in srgb, var(--bg1) 78%, transparent); border-left: 2px solid color-mix(in srgb, var(--accent) 48%, transparent); padding: 12px 14px; border-radius: 0; font-family: var(--sans); font-size: 12px; color: var(--text3); line-height: 1.7; margin-top: 14px; }
#view-docs .docs-callout { color: var(--text2); border-color: var(--accent); }
#view-docs .docs-step-row { display: flex; align-items: flex-start; gap: 14px; padding: 12px 14px; border-radius: 0; margin-bottom: 8px; background: color-mix(in srgb, var(--bg1) 74%, transparent); border: 1px solid color-mix(in srgb, var(--border2) 38%, transparent); }
#view-docs .docs-step-num { font-family: var(--mono); font-size: 9px; font-weight: 800; letter-spacing: 0.06em; padding: 2px 7px; border-radius: 0; white-space: nowrap; flex-shrink: 0; margin-top: 1px; }
#view-docs .docs-step-sw { color: #fff; background: var(--alert-sw); border: 1px solid var(--alert-sw); }
#view-docs .docs-step-tr { color: #fff; background: var(--alert-tr); border: 1px solid var(--alert-tr); }
#view-docs .docs-step-br { color: #fff; background: var(--alert-br); border: 1px solid var(--alert-br); }
#view-docs .docs-step-en { color: #fff; background: var(--alert-en); border: 1px solid var(--alert-en); }
#view-docs .docs-step-plain { color: var(--text); background: var(--bg3); border: 1px solid var(--border2); }
#view-docs .docs-pill-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
#view-docs .docs-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 22px; padding: 0 9px; box-sizing: border-box; font-family: var(--mono); font-size: 9px; font-weight: 800; letter-spacing: 0.08em; color: #fff; }
#view-docs .docs-pill-sw { background: var(--alert-sw); }
#view-docs .docs-pill-tr { background: var(--alert-tr); }
#view-docs .docs-pill-br { background: var(--alert-br); }
#view-docs .docs-pill-en { background: var(--alert-en); }
#view-docs .docs-static-table,
#view-docs .docs-static-table tr { pointer-events: none; }
#view-docs .docs-structure-bull { color: var(--bull); }
#view-docs .docs-structure-bear { color: var(--bear); }
#view-docs .docs-structure-squeeze { color: var(--text3); }
#view-docs .docs-step-body { font-family: var(--sans); font-size: 12px; color: var(--text2); line-height: 1.7; }
#view-docs .docs-step-body strong { color: var(--text); font-weight: 700; }
@media (max-width: 860px) {
  #view-docs.docs-view { padding: 30px 18px 70px; }
  #view-docs .docs-quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #view-docs .docs-title { font-size: 11px; }
}

body {
  font-family: var(--sans);
  font-variant-numeric: tabular-nums;
  background: var(--page-bg);
  color: var(--text);
  min-height: 100vh;
  min-width: var(--app-min-width);
  overflow-x: auto;
  padding-top: var(--header-h);
  padding-left: var(--sidebar-w);
  transition: padding-left 0.2s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.6;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background:
    radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--accent) 12%, transparent) 0%, transparent 34%),
    linear-gradient(180deg, color-mix(in srgb, var(--page-bg) 94%, black 6%) 0%, var(--page-bg) 100%);
}

html[data-auth-state="checking"] .auth-gate,
html[data-auth-state="signed-out"] .auth-gate,
html[data-auth-state="offline"] .auth-gate {
  display: flex;
}

html[data-auth-state="checking"] #mainHeader,
html[data-auth-state="checking"] #sidebarToggle,
html[data-auth-state="checking"] #appSidebar,
html[data-auth-state="checking"] #view-apikeys,
html[data-auth-state="checking"] #view-scanner,
html[data-auth-state="checking"] #view-docs,
html[data-auth-state="signed-out"] #mainHeader,
html[data-auth-state="signed-out"] #sidebarToggle,
html[data-auth-state="signed-out"] #appSidebar,
html[data-auth-state="signed-out"] #view-apikeys,
html[data-auth-state="signed-out"] #view-scanner,
html[data-auth-state="signed-out"] #view-docs,
html[data-auth-state="offline"] #mainHeader,
html[data-auth-state="offline"] #sidebarToggle,
html[data-auth-state="offline"] #appSidebar,
html[data-auth-state="offline"] #view-apikeys,
html[data-auth-state="offline"] #view-scanner,
html[data-auth-state="offline"] #view-docs {
  visibility: hidden;
  pointer-events: none;
}

.auth-gate-panel {
  width: min(360px, 100%);
  border: 1px solid color-mix(in srgb, var(--border2) 64%, transparent);
  background: color-mix(in srgb, var(--bg1) 88%, transparent);
  backdrop-filter: blur(18px) saturate(1.25);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
  padding: 26px;
}

.auth-gate-brand {
  color: var(--accent);
  font-size: 34px;
  line-height: 1;
  margin-bottom: 18px;
}

.auth-gate-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 20px;
  margin-bottom: 14px;
  color: var(--text3);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.auth-gate-status .config-status-dot.ready {
  background: var(--bull);
}

.auth-gate-fields {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.auth-gate-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.auth-gate-actions .config-action-btn {
  flex: 1 1 0;
}

