:root {
  --bg: #0a0e1a;
  --bg-soft: #0f1624;
  --ink: #e2e8f0;
  --muted: #64748b;
  --muted-on-dark: rgba(226, 232, 240, 0.84);
  --line: rgba(255, 255, 255, 0.08);
  --brand-deep: #0ea5e9;
  --brand-mid: #38bdf8;
  --brand-soft: rgba(56, 189, 248, 0.1);
  --accent: #38bdf8;
  --accent-deep: #0ea5e9;
  --card: #111827;
}

html {
  scroll-behavior: smooth;
}

body {
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.05), transparent 28%),
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.04), transparent 24%),
    var(--bg);
  color: var(--ink);
  font-family: 'DM Sans', sans-serif;
}

a {
  color: var(--brand-mid);
}

.img-fluid {
  border-radius: 0.25rem;
}

/* ── Navbar ─────────────────────────────── */
.navbar-glass {
  --bs-navbar-color: rgba(226, 232, 240, 0.84);
  --bs-navbar-hover-color: #fff;
  --bs-navbar-active-color: #fff;
  --bs-navbar-disabled-color: rgba(226, 232, 240, 0.36);
  --bs-navbar-brand-color: #fff;
  --bs-navbar-brand-hover-color: #fff;
  background: rgba(10, 14, 26, 0.92);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.navbar-glass .navbar-brand,
.navbar-glass .navbar-brand span:not(.brand-mark) {
  color: #fff !important;
}

.nav-item,
.nav-item .nav-link {
  color: var(--brand-mid);
}

.navbar-glass .navbar-nav .nav-link {
  color: var(--bs-navbar-color) !important;
}

.navbar-glass .navbar-nav .nav-link:hover,
.navbar-glass .navbar-nav .nav-link:focus {
  color: var(--bs-navbar-hover-color) !important;
}

.navbar-glass .navbar-nav .nav-link.active,
.navbar-glass .navbar-nav .nav-link.show {
  color: var(--bs-navbar-active-color) !important;
}

.navbar-glass .nav-link:focus-visible,
.navbar-glass .navbar-brand:focus-visible {
  outline: 2px solid rgba(56, 189, 248, 0.55);
  outline-offset: 3px;
  border-radius: 0.25rem;
}

.btn:focus-visible,
.btn-accent:focus-visible {
  outline: 2px solid rgba(56, 189, 248, 0.6);
  outline-offset: 3px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand-mid), var(--accent-deep));
  color: #0a0e1a;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  font-family: 'Syne', sans-serif;
}

.btn-accent {
  background: var(--accent);
  border: 0;
  color: #0a0e1a;
  font-weight: 700;
}

.btn-accent:hover {
  background: var(--accent-deep);
  color: #0a0e1a;
}

/* ── Hero (legacy pages) ────────────────── */

.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  background: rgba(56, 189, 248, 0.1);
  color: var(--brand-mid);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-shot {
  margin: 0;
  overflow: hidden;
  border-radius: 0.25rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.hero-shot {
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 1.4rem 3rem rgba(0, 0, 0, 0.4);
}

.hero-shot-large {
  height: 100%;
}

.hero-shot img {
  display: block;
  width: 100%;
  height: auto;
}

.hero-shot figcaption {
  padding: 0.25rem 0.3rem;
  font-size: 0.95rem;
  line-height: 1.55;
}

.hero-shot figcaption {
  color: var(--muted-on-dark);
}

.grid-list-dot {
  width: 0.75rem;
  height: 0.75rem;
  margin-top: 0.3rem;
  flex: 0 0 auto;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--brand-mid));
}

.grid-list-dot.warning {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

.surface-card h3 {
  font-size: 1.05rem;
  font-weight: 800;
}

.surface-card p {
  color: var(--muted);
}

.page-hero {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.06), transparent);
}

.surface-card h2,
.auth-card h1,
.auth-card h2 {
  font-weight: 800;
}

.surface-card,
.auth-card,
.tariff-card {
  padding: 1.25rem;
  border-radius: 0.25rem;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 1.1rem 2.6rem rgba(0, 0, 0, 0.3);
}

.grid-list {
  display: grid;
  gap: 0.9rem;
}

.grid-list.compact {
  gap: 0.75rem;
}

.grid-list-item {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
}

.mini-title {
  margin-bottom: 0.35rem;
  color: var(--brand-mid);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tariff-card {
  position: relative;
  overflow: hidden;
}

.tariff-card::before,
.tariff-choice-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.03), rgba(14, 165, 233, 0.05));
  pointer-events: none;
}

.tariff-card.featured,
.tariff-choice-card.featured {
  background: linear-gradient(135deg, rgba(14, 30, 60, 0.96), rgba(10, 22, 48, 0.95));
  color: #fff;
  border-color: rgba(56, 189, 248, 0.25);
}

.tariff-card.featured p,
.tariff-card.featured .mini-title,
.tariff-card.featured .text-secondary-emphasis,
.tariff-choice-card.featured .text-secondary-emphasis,
.tariff-choice-card.featured .small {
  color: rgba(226, 232, 240, 0.84) !important;
}

.price-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  background: rgba(56, 189, 248, 0.1);
  color: var(--brand-mid);
  font-weight: 800;
  white-space: nowrap;
}

.tariff-card.featured .price-pill,
.tariff-choice-card.featured .price-pill {
  background: rgba(56, 189, 248, 0.15);
  color: var(--brand-mid);
}

.quick-link-card {
  display: block;
  height: 100%;
  padding: 1.1rem;
  border-radius: 1rem;
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid var(--line);
  text-decoration: none;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

#file-browser {
  scroll-margin-top: 6rem;
}

.quick-link-card:hover {
  transform: translateY(-3px);
  border-color: rgba(56, 189, 248, 0.3);
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.3);
}

.quick-link-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  color: inherit;
}

.quick-link-title {
  font-weight: 800;
  color: var(--brand-mid);
}

.auth-card {
  background: rgba(17, 24, 39, 0.95);
}

.tariff-choice {
  cursor: pointer;
}

.tariff-choice-card {
  position: relative;
  display: block;
  padding: 1.2rem;
  border-radius: 1.1rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(17, 24, 39, 0.9);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.tariff-choice-card.active {
  border-color: rgba(56, 189, 248, 0.65);
  box-shadow: 0 0 0 0.22rem rgba(56, 189, 248, 0.18);
  transform: translateY(-2px);
}

.sticky-card {
  position: sticky;
  top: 6rem;
}

.password-toggle-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.85rem;
  min-width: 2.85rem;
  padding: 0;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-left: 0;
  border-top-right-radius: 0.85rem;
  border-bottom-right-radius: 0.85rem;
  background: rgba(17, 24, 39, 0.9);
  color: rgba(226, 232, 240, 0.5);
  transition: color 160ms ease, background-color 160ms ease;
}

.password-toggle-icon-btn svg {
  width: 1rem;
  height: 1rem;
}

.password-toggle-icon-btn:hover,
.password-toggle-icon-btn:focus-visible,
.password-toggle-icon-btn.is-visible {
  background: rgba(56, 189, 248, 0.08);
  color: rgba(226, 232, 240, 0.92);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-new {
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
}

.status-active {
  background: rgba(34, 197, 94, 0.16);
  color: #4ade80;
}

.status-paused {
  background: rgba(100, 116, 139, 0.2);
  color: #94a3b8;
}

.status-deleted {
  background: rgba(239, 68, 68, 0.16);
  color: #f87171;
}

.status-admin {
  background: rgba(56, 189, 248, 0.15);
  color: var(--brand-mid);
}

.status-user {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted-on-dark);
}

.surface-subcard {
  padding: 1rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.admin-grid-page {
  display: grid;
  gap: 1rem;
}

.admin-grid-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.admin-grid-tab {
  padding: 0.75rem 1.2rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.85);
  color: var(--ink);
  font-weight: 700;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.admin-grid-tab.is-active {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.4);
  transform: translateY(-1px);
}

.admin-grid-shell {
  display: grid;
  gap: 1rem;
  padding: 0.25rem;
}

.admin-grid-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
}

.admin-grid-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  flex: 1 1 24rem;
  justify-content: flex-start;
}

.admin-grid-toolbar-actions .form-control {
  width: min(100%, 18rem);
  margin-left: auto;
}

.admin-grid-feedback {
  margin-bottom: 0;
}

.admin-grid-panel[hidden] {
  display: none !important;
}

.admin-grid-tab {
  cursor: pointer;
}

.admin-grid-tab:focus-visible {
  outline: 2px solid rgba(56, 189, 248, 0.55);
  outline-offset: 2px;
}

.admin-grid-frame {
  width: 100%;
  height: min(72vh, 760px);
  min-height: 420px;
  border-radius: 1rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #111827;
}

.admin-grid-overlay {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 8rem;
  color: var(--muted);
  font-weight: 700;
}

.admin-grid-frame .ag-root-wrapper {
  border: 0 !important;
  border-radius: 1rem;
  overflow: hidden;
}

.admin-grid-frame .ag-header-cell-label {
  font-weight: 800;
}

.admin-grid-frame .ag-floating-filter-input,
.admin-grid-frame .ag-text-field-input,
.admin-grid-frame .ag-picker-field-wrapper {
  border-radius: 0.6rem;
}

.admin-grid-frame .ag-row-pinned {
  background: rgba(56, 189, 248, 0.06);
}

.admin-grid-frame .ag-row-pinned .ag-cell {
  font-weight: 600;
}

.admin-grid-frame .ag-cell.ag-cell-inline-editing {
  box-shadow: inset 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.admin-grid-cell-id,
.admin-grid-cell-code,
.admin-grid-cell-date,
.admin-grid-cell-number {
  font-variant-numeric: tabular-nums;
}

.admin-grid-cell-id,
.admin-grid-cell-code {
  font-weight: 700;
}

.admin-grid-cell-number {
  justify-content: flex-end;
}

.admin-grid-frame .ag-cell.admin-grid-cell-number input {
  text-align: right;
}

.admin-grid-cell-comments {
  line-height: 1.2;
}

@media (max-width: 991.98px) {
  .admin-grid-toolbar-actions {
    width: 100%;
  }

  .admin-grid-toolbar-actions .form-control {
    width: 100%;
  }

  .admin-grid-frame {
    min-height: 28rem;
  }
}

@media (max-width: 575.98px) {
  .admin-grid-tabs {
    display: grid;
  }

  .admin-grid-tab {
    justify-content: center;
    text-align: center;
  }

  .admin-grid-toolbar-actions .btn {
    width: 100%;
  }
}

/* ── Footer ──────────────────────────────── */

/* ── Instructions ────────────────────────── */

.instruction-scroll-top {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: 1030;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.2);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #fff;
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  box-shadow: 0 0.75rem 1.8rem rgba(0, 0, 0, 0.4);
  transition: background 180ms ease, transform 180ms ease;
}

.instruction-scroll-top:hover {
  background: rgba(56, 189, 248, 0.35);
  transform: translateY(-2px);
}

@media (max-width: 991.98px) {

  .sticky-card {
    position: static;
  }
}

@media (max-width: 575.98px) {
  .surface-card,
  .auth-card,
  .tariff-card {
    padding: 0.75rem;
  }
}

/* ── Instructions page layout ───────────── */
body.lightbox-open {
  overflow: hidden;
}

body.instructions-body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

body.instructions-body .p2n-footer-shell {
  display: none;
}

.instructions-page {
  height: calc(100vh - 4.5rem);
  height: calc(100dvh - 4.5rem);
  overflow: hidden;
}

.instructions-page > .container-fluid {
  height: 100%;
  min-height: 0;
}

.instructions-shell {
  display: grid;
  grid-template-columns: minmax(240px, 290px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.instructions-sidebar,
.instructions-main {
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.instructions-sidebar {
  top: 6rem;
  align-self: start;
}

.instructions-sidebar-card {
  display: grid;
  gap: 0.9rem;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-left: 0.3rem;
  border-radius: 0.35rem;
  background: linear-gradient(180deg, rgba(10, 22, 48, 0.98), rgba(7, 16, 38, 0.97));
  color: #fff;
  box-shadow: 0 1rem 2.4rem rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(56, 189, 248, 0.12);
}

.instructions-nav {
  display: grid;
  gap: 0;
}

.instructions-nav-link {
  display: block;
  padding: 0;
  border-radius: 0.28rem;
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  line-height: 2;
}

.instructions-nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
}

.instructions-nav-sub {
  padding-left: 1.1rem;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.95rem;
}

.instructions-main {
  display: grid;
  gap: 1rem;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 0.25rem;
  scrollbar-gutter: stable;
}

.instructions-section {
  padding: 1rem;
  border-radius: 0.35rem;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 1rem 2.2rem rgba(0, 0, 0, 0.3);
}

.instructions-section-number {
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.instructions-section-number {
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  line-height: 1.15;
}

.instructions-section-copy,
.instructions-step-copy p,
.instructions-note p {
  margin: 0;
  color: rgba(226, 232, 240, 0.75);
  line-height: 1.6;
}

.instructions-section[id],
.instructions-step[id],
.instructions-note[id] {
  scroll-margin-top: 1rem;
}

.instructions-section + .instructions-section {
  margin-top: 0;
}

.instructions-section-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.9rem;
  align-items: start;
  margin-bottom: 1rem;
}

.instructions-section-title {
  margin: 0 0 0.35rem;
  color: #fff;
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  line-height: 1.15;
  font-weight: 800;
  font-family: 'Syne', sans-serif;
}

.instructions-step,
.instructions-note {
  margin-top: 0.9rem;
}

.instructions-step {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(60px, 120px);
  gap: 0,5rem;
  column-gap: 0.5rem;
  align-items: start;
  padding: 0.5rem;
  border-radius: 0.3rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.instructions-step-copy {
  display: grid;
  gap: 0.5rem;
}

.instructions-step-title,
.instructions-note-title {
  margin: 0;
  color: #fff;
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1.3;
}

.instructions-urlbox {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  border-radius: 0.3rem;
  background: transparent;
  border: 0;
}

.instructions-url {
  padding: 0;
  color: var(--brand-mid);
  font-size: 0.95rem;
  word-break: break-all;
}

.instructions-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0.25rem;
  width: auto;
  height: auto;
  padding: 0.08rem;
  background: transparent;
  color: rgba(226, 232, 240, 0.4);
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.18s ease, opacity 0.18s ease;
}

.instructions-copy-btn:hover,
.instructions-copy-btn:focus-visible {
  color: rgba(226, 232, 240, 0.85);
}

.instructions-copy-btn:focus-visible {
  outline: 2px solid rgba(56, 189, 248, 0.25);
  outline-offset: 0.08rem;
}

.instructions-copy-btn:disabled {
  opacity: 0.78;
}

.instructions-copy-btn.is-copied {
  color: var(--brand-mid);
}

.instructions-copy-btn.is-copy-error {
  color: #f87171;
}

.instructions-warning {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: start;
  padding: 0.8rem 0.85rem;
  border-radius: 0.3rem;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: #fbbf24;
  line-height: 1.55;
}

.instructions-warning-wide {
  grid-column: 1 / -1;
  margin-top: 1rem;
}

.instructions-warning-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.85);
  color: #0a0e1a;
  font-weight: 800;
}

.instructions-thumb,
.instructions-thumb-stack {
  min-width: 0;
}

.instructions-thumb-stack {
  display: grid;
  gap: 0.75rem;
}

.instructions-thumb {
  display: grid;
  gap: 0.35rem;
  justify-items: stretch;
  width: min(160px, 100%);
  padding: 0.28rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.3rem;
  background: rgba(17, 24, 39, 0.98);
  cursor: zoom-in;
  box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.3);
}

.instructions-thumb img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0.2rem;
}

.instructions-thumb-hint {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.1);
  color: var(--brand-mid);
  font-size: 0;
}

.instructions-thumb-hint::before {
  content: "";
  width: 0.72rem;
  height: 0.72rem;
  border: 0.12rem solid currentColor;
  border-radius: 999px;
  transform: translate(-0.1rem, -0.1rem);
}

.instructions-thumb-hint::after {
  content: "";
  position: absolute;
  width: 0.48rem;
  height: 0.12rem;
  border-radius: 999px;
  background: currentColor;
  transform: translate(0.36rem, 0.36rem) rotate(45deg);
  transform-origin: center;
}

.instructions-note {
  padding: 0.9rem 1rem;
  border-radius: 0.3rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.instructions-lightbox[hidden] {
  display: none;
}

.instructions-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1060;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
}

.instructions-lightbox-panel {
  position: relative;
  width: min(100%, 960px);
  max-height: 100%;
  padding: 1rem;
  border-radius: 0.4rem;
  background: rgba(17, 24, 39, 0.99);
  box-shadow: 0 1.4rem 3rem rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.instructions-lightbox-close {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  font-size: 1.4rem;
  line-height: 1;
}

.instructions-lightbox-image {
  display: block;
  width: 100%;
  max-height: calc(100vh - 9rem);
  object-fit: contain;
}

.instructions-lightbox-caption {
  margin-top: 0.8rem;
  color: rgba(226, 232, 240, 0.75);
  line-height: 1.5;
}

/* ── Chat ────────────────────────────────── */
.chat-page {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 1rem;
  height: calc(100vh - 8.5rem);
  min-height: calc(100vh - 8.5rem);
}

.chat-sidebar,
.chat-main {
  height: 100%;
  min-height: 0;
  max-height: calc(100vh - 8.5rem);
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  background: rgba(15, 22, 36, 0.95);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
}

.chat-sidebar {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
}

.chat-main {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}

.chat-sidebar-top,
.chat-main-header {
  padding: 1rem 1rem 0;
}

.chat-main-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.chat-main-actions,
.chat-contact-toolbar,
.chat-mode-switch,
.chat-order-buttons,
.chat-send-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.chat-contact-toolbar {
  justify-content: space-between;
  padding: 0 0.8rem 0.85rem;
}

.chat-mode-button,
.chat-order-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.85);
  color: var(--ink);
  font-weight: 800;
  padding: 0.5rem 0.85rem;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.chat-mode-button,
.chat-order-button {
  width: 2.65rem;
  height: 2.65rem;
  padding: 0;
}

.chat-mode-button svg,
.chat-order-button svg {
  width: 1.1rem;
  height: 1.1rem;
}

.chat-mode-button.is-active,
.chat-mode-button:hover,
.chat-order-button:hover {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.35);
  transform: translateY(-1px);
}

.chat-order-button:disabled,
.chat-mode-button:disabled {
  opacity: 0.45;
  transform: none;
}

.chat-contact-filter {
  display: block;
  width: auto;
  margin: 0 0.8rem 1rem;
}

.chat-contact-list,
.chat-messages {
  overflow: visible;
}

.chat-contact-list {
  display: grid;
  align-content: start;
  align-items: start;
  grid-auto-rows: max-content;
  gap: 0.3rem;
  padding: 0 0.8rem 0.8rem;
  border-radius: 0.25rem;
}

.chat-contact-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.15rem;
  align-self: start;
  align-items: flex-start;
  width: 100%;
  padding: 0.85rem 0.95rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0.25rem;
  background: rgba(17, 24, 39, 0.6);
  color: inherit;
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, background-color 160ms ease;
}

.chat-contact-card:hover,
.chat-contact-card.is-active {
  border-color: rgba(56, 189, 248, 0.3);
  background: rgba(56, 189, 248, 0.06);
  transform: translateY(-1px);
}

.chat-contact-card-main,
.chat-contact-card-meta,
.chat-contact-card-top {
  display: grid;
  gap: 0.2rem;
}

.chat-contact-card-top {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
}

.chat-contact-card-top span,
.chat-contact-card-meta span,
.chat-contact-card-preview,
.chat-empty-state span,
.chat-message-meta-line,
.chat-message-status-line,
.chat-file-caption span,
.chat-draft-file-copy span {
  color: rgba(226, 232, 240, 0.55);
}

.chat-contact-card-preview {
  font-size: 0.94rem;
  line-height: 1.4;
}

.chat-contact-card-meta {
  justify-items: end;
  font-size: 0.8rem;
}

.chat-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6rem;
  padding: 0.75rem 0.45rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand-mid), var(--accent-deep));
  color: #0a0e1a;
  font-weight: 800;
  font-size: 0.75rem;
}

.chat-feedback {
  margin: 0 1rem 1rem;
}

.chat-empty-state {
  display: grid;
  gap: 0.3rem;
  padding: 1rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-empty-state strong {
  color: var(--brand-mid);
}

.chat-empty-state-wide {
  margin: 1rem;
}

.chat-messages {
  min-height: 20rem;
  display: grid;
  gap: 0.95rem;
  align-content: start;
  padding: 1rem;
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.04), transparent 28%),
    radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.06), transparent 24%),
    rgba(10, 14, 26, 0.7);
}

.chat-message-row {
  display: grid;
  gap: 0.3rem;
}

.chat-message-row.is-own {
  justify-items: end;
}

.chat-message-meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: rgba(226, 232, 240, 0.55);
}

.chat-message-body-line {
  display: flex;
  gap: 0.65rem;
  align-items: flex-end;
}

.chat-message-row.is-own .chat-message-body-line {
  flex-direction: row-reverse;
}

.chat-message-card {
  position: relative;
  display: grid;
  gap: 0.75rem;
  width: min(100%, 44rem);
  padding: 0.95rem 1rem;
  border-radius: 0.25rem;
  background: rgba(17, 24, 39, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 0.8rem 1.6rem rgba(0, 0, 0, 0.2);
}

.chat-message-row.is-own .chat-message-card {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.08), rgba(17, 24, 39, 0.95));
}

.chat-message-row.is-blocked .chat-message-card {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(17, 24, 39, 0.95));
}

.chat-message-card-actions {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
}

.chat-message-card-top {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}

.chat-message-copy {
  color: var(--ink);
  line-height: 1.55;
  word-break: break-word;
}

.chat-message-copy strong {
  font-weight: 800;
}

.chat-message-copy em {
  font-style: italic;
}

.chat-message-copy u {
  text-decoration-thickness: 0.08em;
}

.chat-message-select {
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
}

.chat-message-select input {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  cursor: pointer;
  accent-color: var(--brand-mid);
}

.chat-message-menu {
  position: relative;
}

.chat-message-menu summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  list-style: none;
  cursor: pointer;
}

.chat-message-menu summary::-webkit-details-marker {
  display: none;
}

.chat-message-menu-icon {
  width: 1rem;
  height: 1rem;
  transition: transform 160ms ease;
}

.chat-message-menu[open] .chat-message-menu-icon {
  transform: rotate(180deg);
}

.chat-message-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 0.45rem);
  z-index: 5;
  display: none;
  min-width: 12rem;
  padding: 0.45rem;
  border-radius: 0.9rem;
  background: rgba(17, 24, 39, 0.99);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.4);
}

.chat-message-menu[open] .chat-message-menu-list {
  display: grid;
  gap: 0.2rem;
}

.chat-message-menu-list button {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 0;
  border-radius: 0.7rem;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 600;
}

.chat-message-menu-list button:hover {
  background: rgba(56, 189, 248, 0.08);
}

.chat-reply-card,
.chat-context-banner {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.75rem 0.85rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-reply-card {
  display: grid;
  border-radius: 0.25rem;
}

.chat-context-banner {
  border-radius: 0.95rem;
}

.chat-reply-card strong,
.chat-context-banner strong {
  color: var(--brand-mid);
}

.chat-reply-card span,
.chat-context-banner div:last-child {
  color: rgba(226, 232, 240, 0.6);
  line-height: 1.45;
}

.chat-message-status-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  font-size: 0.78rem;
}

.chat-file-list {
  display: grid;
  gap: 0.7rem;
}

.chat-file-card,
.chat-draft-file {
  display: grid;
  gap: 0.65rem;
  padding: 0.75rem;
  border-radius: 0.95rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-file-card-plain {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.chat-file-preview,
.chat-draft-preview {
  display: block;
  overflow: hidden;
  border-radius: 0.8rem;
  background: rgba(17, 24, 39, 0.9);
}

.chat-file-preview img,
.chat-draft-preview img,
.chat-file-preview video,
.chat-draft-preview video,
.chat-file-preview iframe,
.chat-draft-preview iframe {
  display: block;
  width: 100%;
  max-height: 18rem;
  border: 0;
  object-fit: cover;
}

.chat-file-preview-frame video,
.chat-draft-preview-frame video,
.chat-file-preview-frame iframe,
.chat-draft-preview-frame iframe {
  aspect-ratio: 16 / 10;
  max-height: none;
}

.chat-file-preview-generic,
.chat-draft-preview-generic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 4.2rem;
  min-width: 4.2rem;
  padding: 1rem;
  color: var(--brand-mid);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.chat-file-caption,
.chat-draft-file-copy {
  display: grid;
  gap: 0.2rem;
}

.chat-file-caption a {
  color: var(--brand-mid);
  font-weight: 700;
  text-decoration: none;
}

.chat-composer {
  display: grid;
  gap: 0.75rem;
  padding-bottom: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(15, 22, 36, 0.98);
}

.chat-draft-files,
.chat-upload-progress {
  margin: 0 1rem;
}

.chat-upload-progress {
  height: 0.75rem;
}

.chat-editor-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: flex-end;
  padding: 0 1rem;
}

.chat-send-stack {
  display: flex;
  gap: 0.65rem;
  align-items: center;
}

.chat-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.9rem;
  height: 2.9rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.9);
  color: var(--ink);
  transition: transform 160ms ease, border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.chat-icon-btn svg {
  width: 1.2rem;
  height: 1.2rem;
}

.chat-icon-btn:hover,
.chat-icon-btn:focus-visible,
.chat-icon-btn.is-active {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.35);
  color: var(--brand-mid);
  transform: translateY(-1px);
}

.chat-icon-btn:disabled {
  opacity: 0.45;
  background: rgba(255, 255, 255, 0.03);
  color: rgba(226, 232, 240, 0.45);
  transform: none;
}

.chat-icon-btn-dark {
  background: var(--brand-mid);
  border-color: var(--brand-mid);
  color: #0a0e1a;
}

.chat-icon-btn-dark:hover,
.chat-icon-btn-dark:focus-visible,
.chat-icon-btn-dark.is-active {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
  color: #0a0e1a;
}

.chat-icon-btn-dark:disabled {
  background: rgba(56, 189, 248, 0.25);
  border-color: rgba(56, 189, 248, 0.15);
  color: rgba(226, 232, 240, 0.7);
}

.chat-editor {
  min-height: 3.5rem;
  max-height: 11rem;
  overflow-y: auto;
  padding: 0.85rem 1rem;
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(17, 24, 39, 0.9);
  outline: none;
  line-height: 1.55;
  word-break: break-word;
  color: var(--ink);
}

.chat-editor:empty::before {
  content: attr(data-placeholder);
  color: rgba(226, 232, 240, 0.35);
}

.chat-editor.is-disabled {
  background: rgba(255, 255, 255, 0.03);
}

.chat-editor-shell.is-dragover,
.chat-editor-shell.is-dragover .chat-editor {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.06);
}

@media (max-width: 991.98px) {
  .chat-page {
    grid-template-columns: 1fr;
    height: auto;
    min-height: auto;
  }

  .chat-sidebar,
  .chat-main {
    height: auto;
    max-height: none;
    min-height: auto;
    overflow-y: visible;
  }

  .chat-contact-list {
    overflow-y: auto;
    max-height: 32vh;
  }

  .chat-messages {
    overflow-y: auto;
    min-height: 42vh;
    max-height: 52vh;
  }

  .chat-editor-shell {
    grid-template-columns: 1fr;
  }

  .chat-main-actions {
    width: 100%;
  }

  .chat-main-actions .chat-icon-btn {
    flex: 0 0 auto;
  }

  .instructions-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .instructions-page,
  .instructions-page > .container-fluid {
    height: auto;
    overflow: visible;
  }

  body.instructions-body {
    height: auto;
    overflow: auto;
  }

  body.instructions-body .p2n-footer-shell {
    display: block;
  }

  .instructions-sidebar {
    position: static;
    top: auto;
  }

  .instructions-main {
    height: auto;
    overflow: visible;
    padding-right: 0;
  }

  .instructions-sidebar-card {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .instructions-section[id],
  .instructions-step[id],
  .instructions-note[id] {
    scroll-margin-top: 6rem;
  }

  .instructions-step {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 575.98px) {
  .chat-sidebar-top,
  .chat-main-header,
  .chat-editor-shell,
  .chat-draft-files,
  .chat-upload-progress,
  .chat-messages,
  .chat-contact-list {
    padding-left: 0.8rem;
    padding-right: 0.8rem;
  }

  .chat-contact-toolbar {
    padding-left: 0.8rem;
    padding-right: 0.8rem;
    gap: 0.75rem;
  }

  .chat-contact-filter {
    margin-left: 0.8rem;
    margin-right: 0.8rem;
  }

  .chat-mode-switch,
  .chat-order-buttons,
  .chat-send-stack,
  .chat-main-actions {
    width: 100%;
  }

  .chat-send-stack .btn,
  .chat-main-actions .btn {
    flex: 1 1 auto;
  }

  .chat-mode-button,
  .chat-order-button {
    flex: 0 0 auto;
  }

  .chat-send-stack .chat-icon-btn,
  .chat-main-actions .chat-icon-btn {
    flex: 0 0 auto;
  }

  .chat-message-body-line {
    flex-direction: column;
    align-items: stretch;
  }

  .chat-message-row.is-own .chat-message-body-line {
    flex-direction: column;
  }

  .chat-message-card,
  .chat-message-row.is-own .chat-message-card {
    width: 100%;
  }

  .instructions-section,
  .instructions-sidebar-card {
    padding: 0.85rem;
  }

  .instructions-urlbox {
    flex-direction: column;
    align-items: stretch;
  }

  .instructions-warning {
    grid-template-columns: 1fr;
  }

  .instructions-lightbox {
    padding: 0.8rem;
  }

  .instructions-lightbox-panel {
    padding: 0.75rem;
  }
}

/* ── p2n home page ───────────────────────── */
.p2n-divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin: 0;
}

.p2n-hero {
  padding: 1rem 1rem 1rem;
}

.p2n-hero-title {
  font-family: 'Syne', sans-serif;
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: #fff;
  /* max-width: 700px; */
  margin: 0 auto 1.25rem;
}

.p2n-hero-title em {
  font-style: normal;
  color: var(--brand-mid);
}

.p2n-hero-sub {
  font-size: 1.05rem;
  color: var(--muted);
  /* max-width: 500px; */
  margin: 0 auto 2rem;
  line-height: 1.7;
  font-weight: 300;
}

.p2n-trust-item {
  font-size: 0.8rem;
  color: #475569;
}

.p2n-check {
  color: var(--brand-mid);
  font-size: 0.9rem;
  margin-right: 4px;
}

.p2n-screen {
  margin: 1rem auto 0;
  /* max-width: 820px; */
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.25rem;
  overflow: hidden;
}

.p2n-screen .hero-shot {
  border-radius: 0;
  border: none;
  box-shadow: none;
  background: transparent;
}

.p2n-screen .hero-shot figcaption {
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: #64748b;
  background: #111827;
}

.p2n-screen-bar {
  background: #1e293b;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.p2n-screen-dots {
  display: flex;
  gap: 5px;
}

.p2n-d {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.p2n-screen-url {
  margin-left: 0.75rem;
  font-size: 0.7rem;
  color: #475569;
}

.p2n-section {
  padding: 1rem 1rem;
}

.p2n-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--brand-mid);
  text-transform: uppercase;
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
}

.p2n-section-title {
  font-family: 'Syne', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

.p2n-section-sub {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.7;
  /* max-width: 480px; */
  margin: 0;
}

.p2n-steps {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 0.25rem;
  overflow: hidden;
}

.p2n-step {
  background: #0f1624;
  padding: 2rem 1.5rem;
}

.p2n-step-num {
  font-family: 'Syne', sans-serif;
  font-size: 2.5rem;
  font-weight: 800;
  color: rgba(56, 189, 248, 0.5);
  line-height: 1;
  margin-bottom: 0.75rem;
}

.p2n-step h3 {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.5rem;
}

.p2n-step p {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}

.p2n-apps {
  margin: 0;
}

.p2n-app-card {
  background: #0f1624;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0.25rem;
  padding: 1.25rem 0.75rem;
  text-align: center;
  text-decoration: none;
  transition: border-color 180ms ease, transform 180ms ease;
  display: block;
}

.p2n-app-card:hover {
  border-color: rgba(56, 189, 248, 0.3);
  transform: translateY(-2px);
}

.p2n-app-img {
  width: 2rem;
  height: 2rem;
  object-fit: contain;
  margin-bottom: 0.5rem;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.p2n-app-name {
  font-size: 0.7rem;
  font-weight: 500;
  color: #94a3b8;
}

.p2n-methods {
  margin: 0;
}

.p2n-method {
  background: #0f1624;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0.25rem;
  padding: 1.5rem;
}

.p2n-method-featured {
  border-color: rgba(56, 189, 248, 0.25);
}

.p2n-method-num {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--brand-mid);
  background: rgba(56, 189, 248, 0.1);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.p2n-method h3 {
  font-family: 'Syne', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.5rem;
}

.p2n-method-subtitle {
  font-size: 0.7rem;
  color: var(--brand-mid);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.p2n-pro-con {
  margin-top: 0.75rem;
}

.p2n-pro,
.p2n-con {
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0.2rem 0;
  display: flex;
  gap: 6px;
  line-height: 1.5;
}

.p2n-pro::before {
  content: '+';
  color: #34d399;
  flex-shrink: 0;
  font-weight: 700;
}

.p2n-con::before {
  content: '−';
  color: #f87171;
  flex-shrink: 0;
  font-weight: 700;
}

/* ── p2n footer ──────────────────────────── */
.p2n-footer-shell {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(10, 14, 26, 0.98);
}

.footer-nav-link {
  font-size: 0.82rem;
  color: #475569;
  text-decoration: none;
  transition: color 160ms ease;
}

.footer-nav-link:hover {
  color: var(--brand-mid);
}

.footer-contact {
  font-size: 0.82rem;
  color: #475569;
}

.footer-contact a {
  color: var(--brand-mid);
  text-decoration: none;
}

@media (max-width: 767.98px) {
  .p2n-hero {
    padding: 3rem 1rem 2rem;
  }

  .p2n-section {
    padding: 2.5rem 1rem;
  }
}
