/* Reusable interface components */

/* Sun/moon theme toggle. Sits in the eyebrow line of every header. */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-raised);
  color: var(--primary-deep);
  /* The eyebrow is uppercase with wide tracking – the glyph must not inherit it. */
  font-size: 1rem;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}
.theme-toggle:hover {
  border-color: var(--primary);
  background: var(--surface-strong);
}

.brand-logo {
  display: block;
  width: min(245px, 30vw);
  height: auto;
  border: 0;
  box-shadow: none;
  /* The logo is dark blue with no light outline – on a dark background it needs
     its own light plate to stay legible. In the light theme all three are no-ops. */
  padding: var(--logo-pad);
  border-radius: var(--logo-radius);
  background: var(--logo-bg);
  filter: drop-shadow(0 5px 10px rgba(16, 41, 104, 0.12));
  object-fit: contain;
}

.brand-logo-large {
  width: 100%;
  justify-self: end;
}
.header-logo {
  position: static;
  width: clamp(128px, 17vw, 176px);
  flex: 0 0 auto;
  align-self: center;
  /* Pushes the logo to the right edge, where it stands on its own. */
  margin-left: auto;
}

/* Carries the save state only. The online indicator was removed: the app works
   fully offline, so the network state told the user nothing. */
.status-group {
  display: flex;
  align-items: center;
  min-width: 0;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.status-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.tab {
  padding: 0.72rem 0.9rem;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}
.tab.is-active {
  border-bottom-color: var(--primary);
  background: transparent;
  color: var(--primary-deep);
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.72rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-raised);
  color: var(--ink);
  box-shadow: 0 6px 16px rgba(35, 48, 61, 0.06);
  font-weight: 700;
}
.button:hover {
  background: var(--surface-soft);
}
.button-primary {
  border-color: var(--primary-deep);
  background: linear-gradient(180deg, var(--primary), var(--primary-deep));
  color: var(--on-primary);
}
.button-primary:hover {
  background: linear-gradient(180deg, var(--primary-hover), var(--primary-deep));
}
.button-danger {
  border-color: var(--danger-line);
  background: var(--danger-soft);
  color: var(--danger);
}
/* Small buttons are used for probe switching and the pump start/stop controls –
   both are pressed in the field, so they keep the 44 px touch-target size. */
.button-small {
  min-height: 44px;
  padding: 0.46rem 0.85rem;
  font-size: 0.88rem;
}
.file-button {
  cursor: pointer;
}

.mode-card {
  min-height: 230px;
  display: grid;
  gap: 0.65rem;
  padding: 1.35rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(160deg, var(--surface), var(--panel-alt));
  color: var(--ink);
  box-shadow: 0 12px 28px rgba(24, 52, 135, 0.08);
  text-align: left;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}
.mode-card:hover,
.mode-card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: 0 18px 34px rgba(24, 52, 135, 0.15);
}
.mode-card-kicker {
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.mode-card strong {
  color: var(--primary-deep);
  font-size: clamp(1.35rem, 3vw, 1.75rem);
}
.mode-card > span:not(.mode-card-kicker):not(.mode-card-action) {
  color: var(--muted);
  line-height: 1.5;
}
.mode-card-action {
  align-self: end;
  width: fit-content;
  padding: 0.55rem 0.8rem;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 800;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--danger-line);
  border-radius: 9px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 1.35rem;
  line-height: 1;
}

input:focus,
textarea:focus,
select:focus,
button:focus-visible,
summary:focus-visible,
a:focus-visible,
label.file-button:focus-within {
  outline: 3px solid rgba(24, 52, 135, 0.28);
  outline: 3px solid color-mix(in srgb, var(--focus) 28%, transparent);
  outline-offset: 2px;
  border-color: var(--focus);
}

/* Mobile-safe PDF export dialog */
.pdf-dialog {
  width: min(560px, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 22px;
  background: transparent;
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(16, 41, 104, 0.3);
}

.pdf-dialog::backdrop {
  background: rgba(22, 31, 44, 0.56);
  backdrop-filter: blur(4px);
}

.pdf-dialog-card {
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-top: 5px solid var(--primary);
  border-radius: 22px;
  background: linear-gradient(145deg, var(--surface), var(--bg-accent));
}

.pdf-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.pdf-dialog-header h2 {
  margin: 0.2rem 0 0;
  color: var(--primary-deep);
}

.pdf-close-button {
  flex: 0 0 auto;
  border-color: var(--line-strong);
  background: var(--surface-raised);
  color: var(--ink);
}

.pdf-dialog-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.7rem;
  margin: 1rem 0;
}

.pdf-dialog-actions .button {
  width: 100%;
  text-decoration: none;
}

.selector-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.selector-footer .mode-privacy {
  margin: 0;
}

/* Compact document actions */
.toolbar-primary {
  width: 100%;
  min-height: 44px;
  border-radius: 10px;
  background: var(--primary);
  box-shadow: none;
}

.toolbar-primary:hover {
  background: var(--primary-deep);
}

/* Probe switcher: reaching the probe list meant scrolling to the very bottom of
   the form, so switching/adding a probe lives in the toolbar as well. */
.toolbar-probe {
  flex: 1 1 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toolbar-probe-select {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  font-weight: 750;
}

.toolbar-add-probe {
  flex: 0 0 auto;
  min-height: 44px;
  white-space: nowrap;
}

/* Equal columns. Each button used to size itself (narrow / wide / medium),
   which read as a ragged row. */
.toolbar-actions {
  flex: 1 1 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  /* stretch: otherwise each button sizes its own height (44/50/50 px). */
  align-items: stretch;
  gap: 0.5rem;
}

/* Equal columns only look calm when no label wraps. Restricted to the direct
   toolbar buttons: the menu panel is a descendant of .toolbar-actions as well,
   and its longer labels must be allowed to wrap. */
.toolbar-actions > .button,
.toolbar-actions > .toolbar-menu > summary {
  padding-inline: 0.5rem;
  white-space: nowrap;
  font-size: 0.94rem;
}

/* Anchored to .toolbar (not to the toggle) so the panel stays on screen. */
.toolbar-menu {
  position: static;
}

.toolbar-menu > summary {
  list-style: none;
}

.toolbar-menu > summary::-webkit-details-marker {
  display: none;
}

.toolbar-menu-toggle {
  width: 100%;
  min-height: 44px;
  gap: 0.45rem;
  border-radius: 10px;
  box-shadow: none;
  user-select: none;
}

.toolbar-menu-toggle::after {
  content: "⌄";
  color: var(--primary);
  font-size: 1rem;
  line-height: 1;
  transition: transform 0.18s ease;
}

.toolbar-menu[open] .toolbar-menu-toggle::after {
  transform: rotate(180deg);
}

.toolbar-menu-panel {
  width: min(360px, calc(100vw - 1.5rem));
  display: grid;
  gap: 0.75rem;
  position: absolute;
  top: calc(100% - 0.35rem);
  right: clamp(0.75rem, 3vw, 2.5rem);
  z-index: 40;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--chrome-bg-solid);
  box-shadow: 0 20px 46px rgba(16, 41, 104, 0.2);
  backdrop-filter: blur(14px);
}

.toolbar-action-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.toolbar-action-group p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Full width inside the two-column grid of the group. */
.toolbar-menu-field {
  grid-column: 1 / -1;
  display: grid;
  gap: 0.3rem;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 750;
}

.toolbar-menu-field input {
  min-height: 42px;
  font-weight: 400;
}

/* Long label; needs the full width of the group. */
.toolbar-action-group .button-danger {
  grid-column: 1 / -1;
}

.toolbar-menu-panel > .button,
.toolbar-action-group .button,
.toolbar-action-group .file-button {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0.6rem 0.7rem;
  box-shadow: none;
  font-size: 0.88rem;
  line-height: 1.2;
  text-align: center;
}
