:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #d9dce1;
  --text: #1b1e24;
  --muted: #6b7280;
  --accent: #2563eb;
  /* Only the modal's own buttons use this — everything else (menu hover,
     navbar toggle, etc.) keeps --accent, so this stays scoped rather than
     recoloring the whole UI. */
  --modal-accent: #ffa500;
  --modal-accent-hover: #e69500;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

.topbar {
  position: relative;
  /* Higher than .post-login-wait's z-index: a static element (the default)
     always paints below any positioned element with a z-index, regardless
     of DOM order, so without this the overlay would cover the header. */
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 52px;
  padding: 0 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  white-space: nowrap;
}

.brand-logo {
  height: 24px;
  width: auto;
}

.dropdown {
  position: relative;
}

.dropdown-toggle {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.dropdown-toggle:hover { border-color: var(--accent); color: var(--accent); }
.dropdown-toggle[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.dropdown-toggle .caret { font-size: 0.7em; }

.dropdown-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 260px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 10;
}

/* See the note on .modal-backdrop[hidden] below — same fix needed here. */
.dropdown-list[hidden] {
  display: none;
}

.dropdown-item {
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-radius: 5px;
  font-size: 0.85rem;
  cursor: pointer;
}

.dropdown-item:hover:not(:disabled) { background: var(--bg); color: var(--accent); }

.dropdown-item:disabled {
  color: var(--muted);
  cursor: default;
}

.dropdown-item.placeholder::after {
  content: 'Soon';
  float: right;
  font-size: 0.7rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 0.3rem;
  margin-left: 0.5rem;
}

.dropdown-divider {
  padding: 0.35rem 0.6rem 0.15rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

/* Only sections after the first get a rule above them, so the menu doesn't
   start with a redundant line right under its own top border. */
.dropdown-divider:not(:first-child) {
  margin-top: 0.25rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.toggle-navbar {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.toggle-navbar:hover { border-color: var(--accent); color: var(--accent); }

/* Highlighted only while the app's navbar is hidden (the non-default
   state), as a reminder that something is currently tucked away. */
.toggle-navbar.collapsed {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.layout {
  position: relative;
  height: calc(100% - 52px);
  display: flex;
}

/* Before login: header hidden, framed app gets the full window instead of
   leaving a 52px gap for a header that isn't there. See the "pre-login"
   class comment in index.html and its removal in app.js. */
body.pre-login .topbar {
  display: none;
}

body.pre-login .layout {
  height: 100%;
}

.framed-site {
  flex: 1;
  border: 0;
  height: 100%;
  width: 100%;
  background: white;
}

.post-login-wait {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.95rem;
}

/* Author rules override the browser's default [hidden]{display:none} at
   equal specificity, so it must be restated here or the attribute above
   would otherwise be ignored and the overlay would never actually hide. */
.post-login-wait[hidden] {
  display: none;
}

.post-login-wait p {
  margin: 0;
}

/* Indeterminate progress bar — there's no real percentage to report (login
   duration is unknown), just a moving indicator so it's clear something is
   actively happening rather than the page being stuck. */
.loading-bar {
  width: min(220px, 60vw);
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
  position: relative;
}

.loading-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 40%;
  border-radius: 2px;
  background: var(--accent);
  animation: loading-bar-slide 1.2s ease-in-out infinite;
}

@keyframes loading-bar-slide {
  0% { left: -40%; }
  100% { left: 100%; }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
}

/* Author rules override the browser's default [hidden]{display:none} at
   equal specificity, so it must be restated here or the attribute above
   would otherwise be ignored and the modal would never actually hide. */
.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(560px, 90vw);
  max-height: min(70vh, 640px);
  background: var(--panel);
  border-radius: 10px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.modal-logo {
  height: 28px;
  width: auto;
}

.modal-title {
  padding: 0.7rem 0.9rem 0;
  font-weight: 600;
  text-align: center;
}

#result-modal-body {
  margin: 0;
  padding: 0.6rem 0.9rem 0.9rem;
  overflow: auto;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-footer {
  display: flex;
  justify-content: center;
  padding: 0.9rem;
  border-top: 1px solid var(--border);
}

.modal-ok-button {
  border: 1px solid var(--modal-accent);
  background: var(--modal-accent);
  color: #fff;
  padding: 0.5rem 1.8rem;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}

.modal-ok-button:hover {
  background: var(--modal-accent-hover);
  border-color: var(--modal-accent-hover);
}

.modal-cancel-button {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 0.5rem 1.8rem;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}

.modal-cancel-button:hover {
  border-color: var(--muted);
}

.credentials-form {
  display: flex;
  flex-direction: column;
  padding: 0 0.9rem;
}

.credentials-hint {
  margin: 0.2rem 0 0.8rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

.credentials-label {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.credentials-input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  font-size: 0.9rem;
  margin-bottom: 0.8rem;
}

.credentials-input:focus {
  outline: none;
  border-color: var(--accent);
}

.credentials-error {
  margin: 0 0 0.6rem;
  min-height: 1em;
  font-size: 0.8rem;
  color: #c0392b;
}

.credentials-error:empty {
  display: none;
}

.modal-footer:has(.modal-cancel-button) {
  justify-content: center;
  gap: 0.8rem;
}
