/* Omni Menu WWW. Motywy jak w ui/menu.html i launcher/src/gui/theme.rs (data-theme na <html>). */

:root, [data-theme="emerald"] {
  --bg: #0e1014;
  --sidebar: #090a0d;
  --surface: #171a20;
  --surface-hover: #1d2129;
  --control: #252a33;
  --control-hover: #2e3440;
  --border: rgba(255, 255, 255, 0.06);
  --text: #e6e8ec;
  --muted: #7d8592;
  --accent: #3ddc97;
  --accent-hover: #5ae6a9;
  --accent-dim: rgba(61, 220, 151, 0.14);
  --on-accent: #0b0d10;
  --glow: rgba(61, 220, 151, 0.3);
}

[data-theme="purple"] {
  --bg: #110c1a;
  --sidebar: #0c0813;
  --surface: #1c1428;
  --surface-hover: #241a33;
  --control: #2c2140;
  --control-hover: #362852;
  --border: rgba(190, 150, 255, 0.09);
  --text: #ece6f5;
  --muted: #8c7fa3;
  --accent: #a970ff;
  --accent-hover: #bb8cff;
  --accent-dim: rgba(169, 112, 255, 0.16);
  --on-accent: #14091f;
  --glow: rgba(169, 112, 255, 0.35);
}

[data-theme="crimson"] {
  --bg: #150b0e;
  --sidebar: #0f0709;
  --surface: #23151a;
  --surface-hover: #2c1a21;
  --control: #36202a;
  --control-hover: #432733;
  --border: rgba(255, 120, 140, 0.09);
  --text: #f3e6e9;
  --muted: #a27f88;
  --accent: #ff4d6d;
  --accent-hover: #ff6f8a;
  --accent-dim: rgba(255, 77, 109, 0.15);
  --on-accent: #1d070c;
  --glow: rgba(255, 77, 109, 0.32);
}

[data-theme="ocean"] {
  --bg: #0a0f18;
  --sidebar: #070a11;
  --surface: #131c2b;
  --surface-hover: #182337;
  --control: #1f2c43;
  --control-hover: #273752;
  --border: rgba(120, 170, 255, 0.09);
  --text: #e4ebf5;
  --muted: #7b8ba3;
  --accent: #4da3ff;
  --accent-hover: #70b6ff;
  --accent-dim: rgba(77, 163, 255, 0.15);
  --on-accent: #06101d;
  --glow: rgba(77, 163, 255, 0.32);
}

:root {
  --danger: #ff6b6b;
  --danger-dim: rgba(255, 107, 107, 0.14);
  --warn: #f5c25b;
  --warn-dim: rgba(245, 194, 91, 0.14);
  --ok: #3ddc97;
  --ok-dim: rgba(61, 220, 151, 0.12);
  --radius: 14px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--control) transparent;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--control);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--control-hover);
}

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  transition: background 200ms;
}

body { display: flex; flex-direction: column; min-height: 100vh; overflow-x: hidden; -webkit-text-size-adjust: 100%; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

h1 { font-size: 24px; font-weight: 600; margin-bottom: 8px; }
h2 { font-size: 17px; font-weight: 600; margin-bottom: 12px; }
h3 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
.bold { font-weight: 600; }

/* --- Nagłówek --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 18px;
  padding: 12px 24px;
  background: var(--sidebar);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; font-size: 16px; }
.brand:hover { color: var(--text); }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--glow); }

.site-nav, .tabs { display: flex; gap: 4px; }
.site-nav a, .tabs a { white-space: nowrap; }
.site-nav a, .tabs a {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--muted);
  transition: background 120ms, color 120ms;
}
.site-nav a:hover, .tabs a:hover { background: var(--surface); color: var(--text); }
.site-nav a[aria-current="page"], .tabs a[aria-current="page"] { background: var(--accent-dim); color: var(--accent); }
.tabs { margin-bottom: 16px; }

.user-name { font-size: 14px; }

.theme-picker { display: flex; gap: 6px; }
.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: linear-gradient(135deg, var(--swatch-bg) 50%, var(--swatch-accent) 50%);
  cursor: pointer;
  transition: transform 100ms, border-color 120ms;
}
.swatch:hover { transform: scale(1.1); }
.swatch.active { border-color: var(--accent); box-shadow: 0 0 10px var(--glow); }

/* --- Układ --- */
.site-main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 32px 24px 48px; }
.site-footer { padding: 18px 24px; text-align: center; border-top: 1px solid var(--border); }

.page-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 16px; }
.page-stack { display: flex; flex-direction: column; gap: 16px; }
.page-grid > * { min-width: 0; }

.card {
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card.narrow { max-width: 440px; margin: 24px auto; }
.card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.card-head h1, .card-head h2 { margin: 0; }
.back { color: var(--muted); font-size: 14px; }

/* --- Zwijane karty (components/collapse.rs) --- */
.collapse-title button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.collapse-title button:hover { color: var(--accent); }
.collapse-title button:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
.chevron {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  margin: 0 2px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-2px) rotate(45deg);
  transition: transform 150ms;
}
.card.collapsed .chevron { transform: rotate(-45deg); }
/* !important: część dzieci kart ma `display` w stylu inline. */
.card.collapsed > :not(.card-head) { display: none !important; }
.card.collapsed > .card-head { margin-bottom: 0; }

/* --- Landing --- */
.hero { max-width: 720px; margin: 16px auto 32px; text-align: center; }
.hero h1 { font-size: 40px; letter-spacing: -0.5px; }
.lead { font-size: 17px; color: var(--muted); margin: 8px 0 20px; }
.hero-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }

.demo { margin-bottom: 40px; }
.landing-download { max-width: 980px; margin: 0 auto 32px; }
.download-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px 24px;
}
.download-info { flex: 1 1 320px; min-width: 0; }
.download-info .card-head { justify-content: flex-start; margin-bottom: 6px; }
.download-action { flex: 0 1 auto; }
.download-state { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.download-state .note { margin: 0; }
.demo-frame {
  height: 600px;
  max-width: 980px;
  margin: 0 auto 10px;
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--accent-dim), 0 0 40px var(--glow);
  overflow: hidden;
}
.demo-frame iframe { display: block; width: 100%; height: 100%; border: 0; background: transparent; }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); gap: 14px; }

/* --- Formularze --- */
.form { display: flex; flex-direction: column; gap: 14px; margin: 12px 0; }
.form.inline { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
.form.inline .field { flex: 1 1 180px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.field > span, .field .field-label { color: var(--text); font-weight: 500; font-size: 13px; }
.field .field-hint { color: var(--muted); font-size: 12px; margin-top: -2px; }
.check { display: flex; align-items: center; gap: 8px; padding-bottom: 9px; font-size: 14px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.check.danger input { accent-color: var(--danger); }

/* --- Switch / Toggle --- */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--control);
  transition: all 0.2s ease;
  border-radius: 24px;
  border: 1px solid var(--border);
}
.switch-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--muted);
  transition: all 0.2s ease;
  border-radius: 50%;
}
.switch input:checked + .switch-slider {
  background-color: var(--danger);
  border-color: var(--danger);
}
.switch input:checked + .switch-slider:before {
  transform: translateX(20px);
  background-color: #ffffff;
}

.kill-switch-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  transition: border-color 0.2s, background 0.2s;
}
.kill-switch-box.active {
  border-color: var(--danger);
  background: var(--danger-dim);
}
.kill-mode-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
}
.kill-mode-option.selected {
  border-color: var(--border);
  background: var(--sidebar);
}
.kill-mode-option input {
  margin-top: 3px;
}

.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--sidebar);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 120ms;
}
.input:focus { border-color: var(--accent); }
.input.search { width: 260px; max-width: 100%; }
.input[type="date"] { color-scheme: dark; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--control);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background 120ms, transform 60ms;
}
.btn:hover { background: var(--control-hover); color: var(--text); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); color: var(--on-accent); }
.btn.danger { background: var(--danger-dim); color: var(--danger); }
.btn.sm, .btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.copy-field { display: flex; gap: 8px; }
.copy-field .input { min-width: 0; }
.invite-result { margin-top: 14px; padding: 14px; border-radius: 10px; background: var(--accent-dim); }
.invite-result p { margin-bottom: 10px; font-size: 14px; }

/* --- Komunikaty, plakietki, spinner --- */
.note { padding: 10px 14px; border-radius: 10px; font-size: 14px; margin: 8px 0; }
.note.error { background: var(--danger-dim); color: var(--danger); }
.note.warn { background: var(--warn-dim); color: var(--warn); }
.note.ok { background: var(--ok-dim); color: var(--ok); }

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--control);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.ok { background: var(--ok-dim); color: var(--ok); }
.badge.warn { background: var(--warn-dim); color: var(--warn); }
.badge.danger { background: var(--danger-dim); color: var(--danger); }
.badge.accent { background: var(--accent-dim); color: var(--accent); }

.spinner-row { display: flex; align-items: center; gap: 10px; padding: 12px 0; }
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--control);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
.spinner.small { width: 14px; height: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Listy i tabele --- */
.props { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 14px; }
.props dt { color: var(--muted); }
.props dd { min-width: 0; overflow-wrap: anywhere; }

.list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.list-row > div:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  padding: 8px 10px;
  text-align: left;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:hover td { background: var(--surface-hover); }
.table .actions { text-align: right; }
.table .data { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-hover); }

/* --- Modal --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modal-fade-in 0.15s ease-out;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--border);
  animation: modal-scale-in 0.15s ease-out;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-scale-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.modal-close:hover {
  background: var(--control);
  color: var(--text);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
  gap: 10px;
}

.modal-meta-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--bg);
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.modal-meta-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  font-weight: 600;
}

.modal-meta-value {
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
}

.modal-section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-code-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  overflow-x: auto;
  max-height: 340px;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* --- Telefony --- */
@media (max-width: 640px) {
  html, body { font-size: 14px; }
  h1 { font-size: 21px; }

  /* Nagłówek: logo + motywy + konto w pierwszym wierszu, nawigacja w drugim (przewijana w poziomie). */
  .site-header { gap: 10px 12px; padding: 10px 16px; }
  .site-header .spacer { display: none; }
  .theme-picker { margin-left: auto; gap: 5px; }
  .swatch { width: 20px; height: 20px; }
  .site-header > .btn { padding: 7px 12px; }
  .user-name { display: none; }
  .site-nav {
    order: 10;
    width: calc(100% + 32px);
    margin: 0 -16px -10px;
    padding: 6px 16px;
    border-top: 1px solid var(--border);
    overflow-x: auto;
  }
  .site-nav:empty { display: none; }
  .tabs { overflow-x: auto; margin: 0 -16px 14px; padding: 0 16px; }

  .site-main { padding: 18px 16px 36px; }
  .site-footer { padding: 14px 16px; }
  .card { padding: 16px; }
  .card.narrow { margin: 8px auto; }
  .card-head .input.search { width: 100%; }

  .hero { margin: 4px auto 22px; }
  .hero h1 { font-size: 30px; }
  .lead { font-size: 15px; }
  .hero-actions .btn { flex: 1 1 140px; }
  .demo-frame { height: min(75vh, 560px); border-radius: 10px; }
  .download-action, .download-action .btn { width: 100%; }

  /* iOS powiększa stronę przy fokusie pola z fontem < 16px. */
  .input, select, textarea { font-size: 16px; }
  .form.inline { flex-direction: column; align-items: stretch; }
  .form.inline .field { flex: 1 1 auto; }
  .form.inline > .btn { width: 100%; }
  .button-row .btn { flex: 1 1 auto; }
  .copy-field { flex-wrap: wrap; }
  .copy-field .input { flex: 1 1 100%; }
  .copy-field .btn { flex: 1 1 auto; }

  .props { grid-template-columns: 1fr; gap: 0; }
  .props dt { margin-top: 8px; font-size: 12px; }
  .props dt:first-child { margin-top: 0; }

  .list-row { flex-wrap: wrap; gap: 8px 10px; padding: 10px; }
  .list-row > div:first-child { flex: 1 1 100%; }

  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .table { font-size: 13px; }
  .table th, .table td { padding: 8px 6px; }
  .table td { white-space: nowrap; }

  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal-content { max-height: 92vh; border-radius: 14px 14px 0 0; }
  .modal-header, .modal-body { padding: 14px 16px; }
  .modal-footer { padding: 12px 16px; flex-wrap: wrap; }
  .modal-footer .btn { flex: 1 1 auto; }
}

@media (max-width: 380px) {
  .theme-picker { gap: 4px; }
  .swatch { width: 18px; height: 18px; }
  .hero h1 { font-size: 26px; }
}
