/* ============================================================
   TeleBox Panel — Material Design 3 Stylesheet
   Full MD3 redesign with proper tonal elevation, state layers,
   and refined typography / spacing.
   ============================================================ */

:root {
  /* MD3 Tonal Palette — Sky Blue (primary) */
  --md-sys-color-primary: #0ea5e9;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #d1eaff;
  --md-sys-color-on-primary-container: #003355;
  --md-sys-color-secondary: #0284c7;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #cee8fb;
  --md-sys-color-on-secondary-container: #043861;
  --md-sys-color-tertiary: #06b6d4;
  --md-sys-color-on-tertiary: #ffffff;
  --md-sys-color-tertiary-container: #b8edf6;
  --md-sys-color-on-tertiary-container: #00222b;
  --md-sys-color-error: #d92d20;
  --md-sys-color-on-error: #ffffff;
  --md-sys-color-error-container: #ffdad6;
  --md-sys-color-on-error-container: #410002;
  --md-sys-color-success: #0a7e3c;
  --md-sys-color-on-success: #ffffff;
  --md-sys-color-success-container: #b8f0c8;
  --md-sys-color-on-success-container: #00210d;
  --md-sys-color-warning: #b85c00;
  --md-sys-color-on-warning: #ffffff;
  --md-sys-color-warning-container: #ffdcbe;
  --md-sys-color-on-warning-container: #3d1d00;

  /* Surfaces — MD3 tonal elevation */
  --md-sys-color-surface: #f7fbff;
  --md-sys-color-surface-dim: #d7dbe0;
  --md-sys-color-surface-bright: #f7fbff;
  --md-sys-color-surface-container-lowest: #ffffff;
  --md-sys-color-surface-container-low: #f1f5fa;
  --md-sys-color-surface-container: #ebf0f5;
  --md-sys-color-surface-container-high: #e5eaf0;
  --md-sys-color-surface-container-highest: #dfe4ea;
  --md-sys-color-on-surface: #1a1c1e;
  --md-sys-color-on-surface-variant: #41484d;
  --md-sys-color-outline: #72787d;
  --md-sys-color-outline-variant: #c2c7cc;

  /* Misc */
  --md-sys-color-scrim: rgba(0,0,0,0.4);
  --md-sys-color-inverse-surface: #2f3033;
  --md-sys-color-inverse-on-surface: #f0f1f4;

  /* Shape scale */
  --md-radius-xs: 4px;
  --md-radius-sm: 8px;
  --md-radius-md: 12px;
  --md-radius-lg: 16px;
  --md-radius-xl: 28px;
  --md-radius-full: 999px;

  /* Layout */
  --nav-h: 80px;
  --bar-h: 64px;
  --content-max: 720px;
  --font: "Roboto", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  --font-mono: "Roboto Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  /* Elevation (MD3 spec) */
  --elev-1: 0 1px 3px 1px rgba(0,0,0,0.15), 0 1px 2px rgba(0,0,0,0.3);
  --elev-2: 0 2px 6px 2px rgba(0,0,0,0.15), 0 1px 2px rgba(0,0,0,0.3);
  --elev-3: 0 4px 8px 3px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.3);

  /* State layer opacity */
  --state-hover: 0.08;
  --state-focus: 0.10;
  --state-pressed: 0.10;

  color-scheme: light;
}

/* ========== Dark Theme (Telegram / system) ========== */
body.tg-dark {
  --md-sys-color-primary: #6ec6ff;
  --md-sys-color-on-primary: #003355;
  --md-sys-color-primary-container: #004b76;
  --md-sys-color-on-primary-container: #d1eaff;
  --md-sys-color-secondary: #a3c9e0;
  --md-sys-color-on-secondary: #06334e;
  --md-sys-color-secondary-container: #1d4966;
  --md-sys-color-on-secondary-container: #cee8fb;
  --md-sys-color-tertiary: #5bd3e8;
  --md-sys-color-on-tertiary: #00222b;
  --md-sys-color-tertiary-container: #003744;
  --md-sys-color-on-tertiary-container: #b8edf6;
  --md-sys-color-error: #ff9c8f;
  --md-sys-color-on-error: #5f0d06;
  --md-sys-color-error-container: #7e1e16;
  --md-sys-color-on-error-container: #ffdad6;
  --md-sys-color-success: #6dd58c;
  --md-sys-color-on-success: #003916;
  --md-sys-color-success-container: #005224;
  --md-sys-color-on-success-container: #b8f0c8;
  --md-sys-color-warning: #ffb680;
  --md-sys-color-on-warning: #4b2600;
  --md-sys-color-warning-container: #693800;
  --md-sys-color-on-warning-container: #ffdcbe;

  --md-sys-color-surface: #1a1c1e;
  --md-sys-color-surface-dim: #1a1c1e;
  --md-sys-color-surface-bright: #313033;
  --md-sys-color-surface-container-lowest: #0c0e10;
  --md-sys-color-surface-container-low: #1e2022;
  --md-sys-color-surface-container: #222629;
  --md-sys-color-surface-container-high: #2d3032;
  --md-sys-color-surface-container-highest: #383a3c;
  --md-sys-color-on-surface: #e2e2e6;
  --md-sys-color-on-surface-variant: #c2c7cc;
  --md-sys-color-outline: #8c9296;
  --md-sys-color-outline-variant: #41484d;

  --md-sys-color-scrim: rgba(0,0,0,0.6);
  --md-sys-color-inverse-surface: #dfe4ea;
  --md-sys-color-inverse-on-surface: #1a1c1e;

  --elev-1: 0 1px 3px 1px rgba(0,0,0,0.20), 0 1px 2px rgba(0,0,0,0.40);
  --elev-2: 0 2px 6px 2px rgba(0,0,0,0.20), 0 1px 2px rgba(0,0,0,0.40);
  --elev-3: 0 4px 8px 3px rgba(0,0,0,0.20), 0 1px 3px rgba(0,0,0,0.40);

  color-scheme: dark;
}

/* ========== Base ========== */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  line-height: 1.5;
}
button, input, textarea, select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  border: none;
  background: none;
}
a { color: var(--md-sys-color-primary); text-decoration: none; }

#app { min-height: 100%; }

.view { display: none; min-height: 100%; }
.view.active { display: block; }
.hidden { display: none !important; }

/* ========== Boot ========== */
#view-boot {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  min-height: 100%;
  background: var(--md-sys-color-surface);
}
#view-boot.active { display: flex; }

.boot-card {
  width: min(380px, 100%);
  background: var(--md-sys-color-surface-container);
  border-radius: var(--md-radius-xl);
  padding: 40px 28px;
  text-align: center;
  box-shadow: var(--elev-2);
}
.logo-wrap { display: flex; justify-content: center; margin-bottom: 20px; }
.logo-circle {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 8px 32px rgba(14, 165, 233, 0.30);
  background: var(--md-sys-color-surface-container-lowest);
}
.brand {
  margin: 0 0 8px;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--md-sys-color-on-surface);
}
.muted {
  color: var(--md-sys-color-on-surface-variant);
  margin: 0;
  font-size: 0.9rem;
}
.muted.small { font-size: 0.8rem; }

.spinner {
  width: 36px;
  height: 36px;
  margin: 24px auto 0;
  border-radius: 50%;
  border: 3px solid var(--md-sys-color-outline-variant);
  border-top-color: var(--md-sys-color-primary);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== Elevation ========== */
.elevation-1 { box-shadow: var(--elev-1); }
.elevation-2 { box-shadow: var(--elev-2); }
.elevation-3 { box-shadow: var(--elev-3); }

/* ========== App Bar ========== */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 16px;
  background: var(--md-sys-color-surface-container);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--elev-1);
}
.app-bar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo-mini {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--md-sys-color-surface-container-lowest);
  flex-shrink: 0;
}
.app-title {
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.2;
}
.app-sub {
  font-size: 0.75rem;
  color: var(--md-sys-color-on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60vw;
}
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--md-sys-color-on-surface-variant);
  transition: background 0.15s;
}
.icon-btn:hover { background: color-mix(in srgb, var(--md-sys-color-on-surface) var(--state-hover), transparent); }
.icon-btn:active { background: color-mix(in srgb, var(--md-sys-color-on-surface) var(--state-pressed), transparent); }

/* ========== Content ========== */
.content {
  padding: 16px 16px calc(var(--nav-h) + 24px);
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
}

/* ========== Cards ========== */
.card {
  background: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-radius-lg);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--elev-1);
}
.card-title {
  font-weight: 700;
  margin-bottom: 12px;
  font-size: 1rem;
  color: var(--md-sys-color-on-surface);
}

/* ========== Stat Cards ========== */
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.stat {
  background: var(--md-sys-color-surface-container);
  border-radius: var(--md-radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat .label {
  font-size: 0.75rem;
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.stat .value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
}

/* ========== Home — Hero Card ========== */
.hero-card {
  background: linear-gradient(135deg, var(--md-sys-color-primary-container), var(--md-sys-color-tertiary-container));
  border-radius: var(--md-radius-xl);
  padding: 24px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.hero-row {
  display: flex;
  align-items: center;
  gap: 16px;
}
.hero-logo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--md-sys-color-surface-container-lowest);
  flex-shrink: 0;
  box-shadow: var(--elev-1);
}
.hero-info { flex: 1; min-width: 0; }
.hero-title {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--md-sys-color-on-primary-container);
}
.hero-sub {
  font-size: 0.85rem;
  color: var(--md-sys-color-on-primary-container);
  opacity: 0.8;
  margin-top: 2px;
}
.hero-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--md-radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
  align-self: flex-start;
}
.hero-status .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.hero-status .status-dot.ok { background: var(--md-sys-color-success); }
.hero-status .status-dot.warn { background: var(--md-sys-color-warning); }
.hero-status .status-dot.err { background: var(--md-sys-color-error); }

/* ========== Home — Info Rows ========== */
.info-card { margin-bottom: 12px; }
.info-section-title {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.info-rows { display: flex; flex-direction: column; gap: 0; }
.info-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.info-row:last-child { border-bottom: none; }
.info-row .info-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--md-radius-sm);
  display: grid;
  place-items: center;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  flex-shrink: 0;
  font-size: 1rem;
}
.info-row .info-icon .material-icons-round { font-size: 18px; }
.info-row .info-label {
  font-size: 0.82rem;
  color: var(--md-sys-color-on-surface-variant);
  width: 70px;
  flex-shrink: 0;
}
.info-row .info-value {
  flex: 1;
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
  word-break: break-word;
}
.info-row .info-value.mono {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 400;
}
.info-row .info-badge {
  flex-shrink: 0;
}

/* ========== Mono text ========== */
.mono {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.6;
}

/* ========== List ========== */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-radius-lg);
  padding: 14px 16px;
  box-shadow: var(--elev-1);
  transition: box-shadow 0.15s, transform 0.1s;
}
.list-item:active { transform: scale(0.99); }
.list-item .leading {
  width: 44px;
  height: 44px;
  border-radius: var(--md-radius-md);
  display: grid;
  place-items: center;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  flex-shrink: 0;
  font-size: 1.2rem;
}
.list-item .body { flex: 1; min-width: 0; }
.list-item .title {
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.list-item .desc {
  font-size: 0.82rem;
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.list-item .trailing {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
  flex-shrink: 0;
}

/* ========== Badges ========== */
.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  border-radius: var(--md-radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}
.badge.ok {
  background: var(--md-sys-color-success-container);
  color: var(--md-sys-color-on-success-container);
}
.badge.warn {
  background: var(--md-sys-color-warning-container);
  color: var(--md-sys-color-on-warning-container);
}
.badge.err {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 24px;
  border-radius: var(--md-radius-full);
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: 0.01em;
  transition: opacity 0.15s, transform 0.1s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
}
.btn:hover::before {
  content: "";
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, currentColor var(--state-hover), transparent);
  pointer-events: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.38; pointer-events: none; }

.btn.filled {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  box-shadow: var(--elev-1);
}
.btn.tonal {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}
.btn.outlined {
  border: 1px solid var(--md-sys-color-outline);
  color: var(--md-sys-color-primary);
}
.btn.text {
  color: var(--md-sys-color-primary);
  padding: 0 12px;
}
.btn.danger {
  background: var(--md-sys-color-error);
  color: var(--md-sys-color-on-error);
  box-shadow: var(--elev-1);
}
.btn.sm {
  min-height: 34px;
  padding: 0 16px;
  font-size: 0.8rem;
}

/* ========== Chips ========== */
.chip-row { display: flex; gap: 8px; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
.chip-row.wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  flex-shrink: 0;
  height: 34px;
  padding: 0 16px;
  border-radius: var(--md-radius-full);
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.82rem;
  font-weight: 500;
  transition: background 0.15s;
}
.chip:hover { background: var(--md-sys-color-surface-container-highest); }
.chip.outlined {
  background: transparent;
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface-variant);
}
.chip.active {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-color: transparent;
}

/* ========== Toolbar / Search ========== */
.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}
.search-field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-radius-full);
  padding: 0 16px;
  min-height: 48px;
  color: var(--md-sys-color-on-surface-variant);
}
.search-field input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  min-width: 0;
  color: var(--md-sys-color-on-surface);
}
.stats-inline {
  font-size: 0.82rem;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 12px;
  padding: 12px 16px;
}

/* ========== Forms ========== */
.form { display: flex; flex-direction: column; gap: 16px; }
.field-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}
.field, .field-group input, .field-group textarea, .field-group select {
  width: 100%;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--md-radius-sm);
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s;
}
.field:focus, .field-group input:focus, .field-group textarea:focus, .field-group select:focus {
  border-color: var(--md-sys-color-primary);
  border-width: 2px;
  padding: 11px 13px;
}
.field-group textarea { min-height: 120px; resize: vertical; font-family: var(--font-mono); }
.field-group .hint {
  font-size: 0.75rem;
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 6px;
}
.form-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.form-actions { margin-top: 20px; display: flex; justify-content: flex-end; }

/* ========== Switch (MD3) ========== */
.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
}
.switch input {
  width: 52px;
  height: 32px;
  appearance: none;
  background: var(--md-sys-color-surface-container-highest);
  border-radius: 999px;
  position: relative;
  transition: 0.2s;
  border: 2px solid var(--md-sys-color-outline);
}
.switch input::after {
  content: "";
  position: absolute;
  top: 4px; left: 4px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--md-sys-color-outline);
  transition: 0.2s;
}
.switch input:checked {
  background: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
}
.switch input:checked::after {
  left: 24px;
  width: 24px;
  height: 24px;
  background: var(--md-sys-color-on-primary);
}

/* ========== Back Button ========== */
.back-btn {
  margin-bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--md-sys-color-primary);
  font-weight: 500;
}
.back-btn .material-icons-round { font-size: 20px; }

/* ========== Plugin Cards (collapsible help) ========== */
.plugin-card { overflow: hidden; }
.plugin-header { cursor: pointer; }
.plugin-header:active { opacity: 0.7; }
.plugin-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.plugin-icon { font-size: 1.3rem; }
.plugin-name { font-weight: 700; font-size: 1rem; }
.plugin-arrow {
  margin-left: auto;
  color: var(--md-sys-color-on-surface-variant);
  transition: transform 0.2s;
}
.plugin-desc {
  font-size: 0.82rem;
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 4px;
}
.plugin-cmds {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.plugin-cmds code {
  font-size: 0.74rem;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  padding: 2px 8px;
  border-radius: var(--md-radius-sm);
  font-family: var(--font-mono);
}
.plugin-body {
  border-top: 1px solid var(--md-sys-color-outline-variant);
  margin-top: 12px;
  padding-top: 12px;
}
.plugin-helptext {
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.6;
}

/* ========== Settings Tabs ========== */
.settings-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.tab-btn {
  padding: 8px 16px;
  border-radius: var(--md-radius-full);
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--md-sys-color-on-surface-variant);
  background: transparent;
  white-space: nowrap;
  transition: background 0.15s;
}
.tab-btn:hover { background: var(--md-sys-color-surface-container-high); }
.tab-btn.active {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}
.tab-panel { animation: fade 0.2s ease; }
@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ========== Settings Groups ========== */
.settings-group { margin-bottom: 20px; }
.settings-group-title {
  padding: 8px 4px;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--md-sys-color-on-surface-variant);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* ========== Admin card embedded in settings ========== */
#settings-admin-card { margin-top: 16px; }
#settings-admin-card .card-title { margin-bottom: 8px; }
#settings-admin-card .form-row { gap: 8px; flex-wrap: wrap; }
#settings-admin-card .field { flex: 1; min-width: 120px; }
#settings-admin-card .muted.small { font-size: 0.75rem; margin-top: 4px; margin-bottom: 8px; }

/* ========== Alias editor ========== */
.alias-editor { display: flex; flex-direction: column; gap: 12px; }
.alias-entry { display: flex; gap: 8px; align-items: center; }
.alias-entry input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-radius-sm);
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
}
.alias-entry .btn { white-space: nowrap; }
.alias-empty {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.85rem;
  text-align: center;
  padding: 16px;
}
.alias-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

/* ========== Prefix editor ========== */
.prefix-editor { display: flex; flex-direction: column; gap: 12px; }
.prefix-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.prefix-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border-radius: var(--md-radius-full);
  font-size: 0.85rem;
  font-weight: 500;
}
.prefix-tag .material-icons-round { font-size: 16px; cursor: pointer; }
.prefix-input-row { display: flex; gap: 8px; }
.prefix-input-row input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-radius-sm);
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
}

/* ========== Sudo editor ========== */
.sudo-editor { display: flex; flex-direction: column; gap: 16px; }
.sudo-section { display: flex; flex-direction: column; gap: 8px; }
.sudo-section-title { font-weight: 600; color: var(--md-sys-color-on-surface); font-size: 0.9rem; }
.sudo-entry { display: flex; gap: 8px; align-items: center; }
.sudo-entry input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-color-sm);
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
}
.sudo-entry input[placeholder*="用户名"] { width: 120px; }
.sudo-empty {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.85rem;
  text-align: center;
  padding: 16px;
}
.sudo-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

/* ========== Status tags list ========== */
.status-tags { margin-top: 16px; }
.status-tags-title { font-weight: 600; color: var(--md-sys-color-on-surface); margin-bottom: 8px; font-size: 0.85rem; }
.status-tag {
  display: inline-block;
  padding: 4px 10px;
  margin: 3px 4px 3px 0;
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-primary);
  border-radius: var(--md-radius-sm);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  cursor: copy;
  transition: background 0.15s;
}
.status-tag:hover {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

/* ========== Plugins overview ========== */
.plugins-overview { padding: 16px; }
.plugins-overview .stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.plugins-overview .stat-item {
  flex: 1;
  min-width: 130px;
  padding: 12px 16px;
  background: var(--md-sys-color-surface-container);
  border-radius: var(--md-radius-md);
}
.plugins-overview .stat-label {
  font-size: 0.75rem;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 4px;
}
.plugins-overview .stat-value { font-weight: 700; font-size: 1.1rem; }

/* ========== Navigation Bar (MD3 Bottom Nav) ========== */
.nav-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: var(--nav-h);
  display: flex;
  background: var(--md-sys-color-surface-container);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 30;
  box-shadow: var(--elev-2);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.68rem;
  font-weight: 600;
  border-radius: var(--md-radius-lg);
  transition: color 0.15s;
}
.nav-item .material-icons-round { font-size: 24px; transition: all 0.2s; }
.nav-item.active {
  color: var(--md-sys-color-on-secondary-container);
}
.nav-item.active .material-icons-round {
  background: var(--md-sys-color-secondary-container);
  border-radius: var(--md-radius-lg);
  padding: 4px 20px;
  width: auto;
}

/* ========== Toast ========== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 16px);
  transform: translateX(-50%);
  background: var(--md-sys-color-inverse-surface);
  color: var(--md-sys-color-inverse-on-surface);
  padding: 14px 22px;
  border-radius: var(--md-radius-md);
  font-size: 0.875rem;
  z-index: 50;
  max-width: min(92vw, 420px);
  box-shadow: var(--elev-3);
  animation: toastIn 0.2s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ========== Modal ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--md-sys-color-scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 60;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-overlay .modal {
  width: min(420px, 100%);
  max-height: 80vh;
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-radius-xl);
  padding: 24px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--elev-3);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: none; }
}
.modal {
  position: fixed;
  inset: 0;
  background: var(--md-sys-color-scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 60;
}
.modal-card {
  width: min(420px, 100%);
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-radius-xl);
  padding: 24px;
  box-shadow: var(--elev-3);
}
.modal-title { font-weight: 700; font-size: 1.15rem; margin-bottom: 12px; }
.modal-body {
  font-size: 0.9rem;
  color: var(--md-sys-color-on-surface-variant);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 50vh;
  overflow: auto;
  line-height: 1.6;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ========== Empty state ========== */
.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.9rem;
}

/* ========== Custom field type editors ========== */

/* Provider list editor */
.provider-list-editor { display: flex; flex-direction: column; gap: 8px; }
.provider-list-header {
  font-size: 0.75rem;
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 600;
  padding: 4px 0;
}
.provider-list-textarea {
  width: 100%;
  min-height: 120px;
  padding: 10px 14px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-radius-sm);
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  resize: vertical;
  outline: none;
}
.provider-list-hint {
  font-size: 0.72rem;
  color: var(--md-sys-color-on-surface-variant);
}

/* Prompt map editor */
.prompt-map-editor { display: flex; flex-direction: column; gap: 10px; }
.prompt-map-empty {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.85rem;
  text-align: center;
  padding: 12px;
}
.prompt-map-entry { display: flex; gap: 8px; align-items: center; }
.prompt-map-entry input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-radius-sm);
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
}
.prompt-map-entry textarea {
  flex: 2;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-radius-sm);
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
  font-size: 0.82rem;
  resize: vertical;
  min-height: 60px;
}

/* Tag list editor */
.tag-list-editor { display: flex; flex-direction: column; gap: 10px; }
.tag-list-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border-radius: var(--md-radius-full);
  font-size: 0.85rem;
  font-weight: 500;
}
.tag-item .material-icons-round { font-size: 16px; cursor: pointer; }
.tag-list-input-row { display: flex; gap: 8px; }
.tag-list-input-row input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-radius-sm);
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
}

/* ========== Responsive ========== */
@media (min-width: 600px) {
  .stats { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
