
* {
  box-sizing: border-box;
}

/* .wallet/.user-chip etc set their own `display`, which (being an author style) otherwise
   beats the UA stylesheet's [hidden]{display:none} - without this, toggling .hidden via the
   hidden IDL property on those elements would silently do nothing. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
}

.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--ink-soft);
}

h2 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0 0 4px;
  font-size: 20px;
}

/* --- header --- */

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-raised);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rail-toggle-btn {
  display: none;
  width: 30px;
  height: 30px;
  padding: 0;
  align-items: center;
  justify-content: center;
}

.rail-toggle-btn svg {
  width: 16px;
  height: 16px;
}

.brand {
  font-family: var(--font-brand);
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -.02em;
  text-transform: lowercase;
}

.brand:hover {
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-actions > * {
  white-space: nowrap;
}

.header-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 13px;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
}

.header-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  font: inherit;
  color: var(--ink);
  cursor: pointer;
}

.user-menu-divider {
  width: 1px;
  height: 16px;
  background: var(--line);
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 140px;
  padding: 4px;
  border-radius: 10px;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.user-menu-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  text-align: left;
  background: none;
  border: none;
  color: var(--ink);
  cursor: pointer;
}

.user-menu-dropdown-item:hover {
  background: var(--input-tint);
}

/* Sign out set apart from the rest - a misclick reaching for Top up shouldn't be able to land here. */
#logout-btn {
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.dropdown-icon {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--ink-soft);
}

.dropdown-icon svg {
  width: 15px;
  height: 15px;
}

#balance {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--input-accent);
}

/* stands in for the word "token(s)" wherever a price or balance is shown (see
   formatTokens/withTokenIcon in app.js) - sized relative to its context so it reads
   consistently whether it's next to the header balance or a small chip estimate. Fixed
   color (not currentColor). margin (not a space character or flex gap) is the one spacing
   mechanism, so it stays the same whether the parent happens to be flex (#balance) or plain
   inline flow (a chip's estimate text). */
.token-icon {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: .3em;
  position: relative;
  top: 0.05em;
  color: var(--input-accent);
}

.wallet .token-icon svg,
.token-icon svg {
  width: 1.1em;
  height: 1.1em;
  stroke-width: 2.2;
}

.user-chip-name {
  font-size: 13px;
  font-weight: 500;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* sign-in sits where the wallet balance normally does (see #wallet-chip/#signin-link
   toggling in checkAuth()) - the rest of the app stays browsable signed out, so this is a
   small header control, not a wall blocking the page. */

.signin-link {
  padding: 7px 14px;
  font-size: 13px;
  text-decoration: none;
}

/* every number field (top-up amount, extract-patterns top_n, generate-script duration, ...)
   - the native up/down spinner adds width and visual noise these compact inputs don't need */

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

.icon-btn {
  border-radius: 20px;
  font-size: 13px;
}

.icon-btn svg {
  display: block;
  width: 15px;
  height: 15px;
}

.icon-btn--round {
  width: 22px;
  height: 22px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  line-height: 1;
  border-radius: 50%;
}

