/* ── RunTK Shared Components ── */

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* App-switcher */
.app-switcher { position: relative; display: flex; align-items: center; min-width: 0; }

.app-switcher-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font: inherit;
  text-align: left;
  appearance: none;
  -webkit-appearance: none;
}

.app-switcher-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 10px;
}

.app-switcher-caret {
  margin-left: 4px;
  color: var(--muted2);
  transition: transform 0.15s ease;
  flex: 0 0 auto;
}

.app-switcher.open .app-switcher-caret { transform: rotate(180deg); }

/* App menu dropdown */
.app-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  min-width: 210px;
  max-width: min(260px, 90vw);
  padding: 6px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 12px 26px rgba(0,0,0,0.35);
  display: none;
  z-index: 20;
}

.app-switcher.open .app-menu { display: block; }

.app-menu a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.app-menu a:hover { background: var(--btn); color: var(--text); }

.app-menu a[aria-current="page"] {
  background: rgba(88,166,255,0.18);
  color: var(--accent);
}

.app-menu .menu-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.app-menu .menu-icon svg { width: 16px; height: 16px; display: block; }

/* App logo */
.app-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.12);
  flex: 0 0 auto;
}

.app-logo svg { display: block; }

.logo-yellow {
  background: rgba(210,153,34,0.12);
  color: var(--warn);
  border-color: rgba(210,153,34,0.3);
}

.logo-blue {
  background: rgba(31,111,235,0.15);
  color: var(--accent);
  border-color: rgba(31,111,235,0.3);
}

.logo-green {
  background: rgba(63,185,80,0.12);
  color: var(--success);
  border-color: rgba(63,185,80,0.3);
}

.logo-purple {
  background: rgba(163,113,247,0.12);
  color: var(--purple);
  border-color: rgba(163,113,247,0.3);
}

/* App text */
.app-text { min-width: 0; }

.app-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.15;
}

.app-sub {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 56vw;
}

/* Spacer */
.spacer { flex: 1; }

/* Help button */
.help-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--btn);
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.help-btn:hover { background: var(--btnHover); color: var(--text); }

/* Help modal */
.help-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0,0,0,0.55);
  z-index: 50;
}

.help-modal.open { display: flex; }

.help-dialog {
  width: min(560px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.45);
  overflow: hidden;
}

.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.help-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.help-close {
  border: none;
  background: var(--btn);
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.help-close:hover { background: var(--btnHover); color: var(--text); }

.help-body {
  padding: 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  max-height: 65vh;
  overflow: auto;
}

.help-body h1 { font-size: 16px; margin: 0 0 8px; color: var(--text); }
.help-body h2 { font-size: 14px; margin: 12px 0 6px; color: var(--text); }
.help-body h3 { font-size: 13px; margin: 10px 0 6px; color: var(--text); }
.help-body p { margin: 0 0 8px; }
.help-body ul, .help-body ol { margin: 0 0 8px 18px; padding: 0; }
.help-body li { margin: 0 0 4px; }
.help-body code { font-family: var(--mono); background: var(--surface2); padding: 2px 4px; border-radius: 4px; }
.help-body pre { background: var(--surface2); border: 1px solid var(--border); padding: 10px; border-radius: 10px; overflow: auto; margin: 0 0 10px; }
.help-body pre code { background: none; padding: 0; }
.help-body a { color: var(--accent); text-decoration: none; }
.help-body a:hover { text-decoration: underline; }

.help-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.help-footer a { color: var(--accent); text-decoration: none; }
.help-footer a:hover { text-decoration: underline; }

/* Header badge (root page) */
.header-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: var(--btn);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 8px;
  letter-spacing: 0.02em;
}

/* Footer */
.footer {
  text-align: center;
  padding: 24px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted2);
}

.footer a {
  color: var(--muted);
  text-decoration: none;
}

.footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Utilities */
.hide { display: none !important; }
.hidden { display: none !important; }
