/* Keuvel -- components: the chrome every page wears, plus the controls
   (buttons, fields, tables, chips) the pages compose from.

   Structure is flieks': a paper band constrained to --container-max, ink
   borders, pill chips, uppercase micro-labels. Register is keuvel's: one
   header band rather than flieks' three, because the calm end of the
   house style does not want an editorial masthead over a settings page. */

/* --- header ------------------------------------------------------- */
/* A single paper band: wordmark left, nav right. The band's background
   bleeds full width; the container inside it re-centres at the same
   max-width as the page below. */
header { background: var(--bg-surface); border-bottom: 1px solid var(--border-subtle); }
header > .container { padding-block: var(--space-xs); justify-content: space-between; }
.logo {
  font-weight: 700;
  font-size: var(--font-lg);
  letter-spacing: -0.4px;
  color: var(--text);
}
.logo:hover { color: var(--text); text-decoration: none; }
header nav ul { gap: var(--space-s); }
header nav a { color: var(--text-muted); font-size: var(--font-sm); }
header nav a:hover { color: var(--text); text-decoration: none; }
header nav a[aria-current="page"] { color: var(--text); }
/* The signed-in address is nav furniture, not a link: it takes the nav
   links' colour and size, and clips rather than wraps so a long address
   cannot push the header onto a second line. The 33vw share keeps the
   nav on one row at 390px -- the narrowest phone we target -- where the
   other three items plus their gaps take the remaining 230px; 12rem caps
   it once the container stops growing. */
.signed-in {
  color: var(--text-muted);
  font-size: var(--font-sm);
  max-width: min(12rem, 33vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- admin sub-nav ------------------------------------------------ */
/* Sunk one step below the header band so the two read as a hierarchy
   rather than two equal rows. The active tab is underscored in accent,
   which is the same marker the tab bar on /configure uses. */
.admin-nav { background: var(--bg-sunken); border-bottom: 1px solid var(--border-subtle); }
.admin-nav > .container { padding-block: var(--space-3xs); }
.admin-nav ul { gap: var(--space-s); }
.admin-nav a {
  color: var(--text-muted);
  font-size: var(--font-sm);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.admin-nav a:hover { color: var(--text); text-decoration: none; }
.admin-nav a[aria-current="page"] {
  color: var(--text);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 2px;
}

/* --- main and footer ---------------------------------------------- */
/* flex-grow makes main, not the footer, absorb the leftover page height
   under the body's column flex shell. */
main { flex-grow: 1; padding-block: var(--space-m) var(--space-l); }
footer { color: var(--text-muted); font-size: var(--font-sm); }
footer > .container { border-top: 1px solid var(--border-subtle); padding-block: var(--space-s); text-align: center; }

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-xs);
  padding: var(--space-2xs) var(--space-s);
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: var(--radius);
  z-index: 100;
  font-weight: 600;
}
.skip-link:focus { top: var(--space-xs); }

/* --- forms -------------------------------------------------------- */
input, select, textarea {
  display: block;
  width: 100%;
  padding: var(--space-2xs) var(--space-xs);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--text-muted);
  border-radius: var(--radius);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="search"] { -webkit-appearance: none; appearance: none; }
/* Uppercase micro-label, the house style's field marker. */
label {
  display: block;
  margin-bottom: var(--space-3xs);
  font-size: var(--font-sm);
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-muted);
}
form > * + * { margin-top: var(--space-xs); }
form > button { display: flex; width: 100%; }

/* --- buttons ------------------------------------------------------ */
/* The `.button` class carries the same shape onto an anchor, for an
   action that navigates rather than submits. */
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3xs);
  padding: var(--space-2xs) var(--space-s);
  font-weight: 600;
  color: var(--accent-fg);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s, opacity 0.15s;
}
button:hover, .button:hover { background: var(--accent-hover); color: var(--accent-fg); text-decoration: none; }
button:focus-visible, .button:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button[aria-busy="true"] { opacity: 0.7; cursor: wait; }
/* The quiet alternative: ink outline on paper, the house style's pill
   register squared off to match the fields it sits beside. */
button.secondary, .button.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--text-muted);
}
button.secondary:hover, .button.secondary:hover { background: var(--bg-surface); color: var(--text); }
/* A button that reads as one of the nav links beside it. Both the base
   `button` fill and the `form > button` full-width rule are wrong for a
   control sitting in the header's link row. */
.link-button {
  display: inline-flex;
  width: auto;
  padding: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: var(--font-sm);
  font-weight: 400;
}
.link-button:hover { background: none; color: var(--text); }
/* Destructive row actions are glyphs, not filled buttons: a table of
   rows each ending in a filled red button is a wall of alarm. */
.delete-btn, .preset-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.delete-btn:hover, .preset-remove:hover { background: none; opacity: 0.7; }

/* --- tables ------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: var(--space-2xs) var(--space-xs); text-align: left; border-bottom: 1px solid var(--border-subtle); }
th {
  font-size: var(--font-sm);
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-muted);
}
/* Action columns come last and must not wrap onto a second line. */
td:last-child { white-space: nowrap; }
/* Horizontal scroll on narrow screens, inside the table's own box so the
   page itself never scrolls sideways. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

/* --- pill chips --------------------------------------------------- */
/* The house style's chip: ink outline, 999px radius, filled when it is
   the one that matters. */
.dup-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  font-size: var(--font-sm);
  border: 1px solid var(--text-muted);
  border-radius: 999px;
  color: var(--text-muted);
}
.dup-badge.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }

/* --- tab bar (configure) ------------------------------------------ */
.tab-bar {
  display: flex;
  margin-bottom: var(--space-s);
  border-bottom: 2px solid var(--border-subtle);
}
.tab-bar button {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: var(--space-2xs) var(--space-s);
  border-radius: 0;
  color: var(--text-muted);
}
.tab-bar button:hover { background: none; color: var(--text); }
.tab-bar button.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* --- search dropdown ---------------------------------------------- */
.search-wrapper { position: relative; }
.search-dropdown {
  position: absolute;
  z-index: 10;
  width: 100%;
  max-height: 320px;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--text-muted);
  border-radius: var(--radius);
}
.search-dropdown li {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-2xs) var(--space-xs);
  cursor: pointer;
}
.search-dropdown li:hover, .search-dropdown li.highlighted { background: var(--bg-sunken); }
.search-dropdown img { width: 40px; height: 40px; border-radius: var(--radius); object-fit: cover; flex-shrink: 0; }
.search-dropdown .info { overflow: hidden; }
.search-dropdown .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-dropdown .author,
.search-dropdown .subtitle { font-size: var(--font-sm); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- messages ----------------------------------------------------- */
/* Rendered by the server on the failing response, so -- unlike the
   script-toggled `.error-message` below -- they start visible. */
.form-error, .error { color: var(--danger); }
.error-message, #error-msg { color: var(--danger); display: none; margin-top: var(--space-2xs); font-size: var(--font-sm); }
.success-message, #success-msg { color: var(--success); display: none; margin-top: var(--space-2xs); font-size: var(--font-sm); }
.loading-placeholder { color: var(--text-muted); font-style: italic; padding: var(--space-s) 0; }

/* --- text utilities ----------------------------------------------- */
.text-muted { color: var(--text-muted); }
.text-small { font-size: var(--font-sm); }
