:root {
  color-scheme: dark;
  --bg: #07111f;
  --bg-accent: #0b1729;
  --surface: #0f1b2d;
  --surface-muted: #122036;
  --surface-soft: #18263b;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.26);
  --text: #e8eef7;
  --text-soft: #b7c4d8;
  --text-muted: #8fa3bf;
  --primary: #60a5fa;
  --primary-strong: #3b82f6;
  --primary-soft: rgba(96, 165, 250, 0.14);
  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.14);
  --danger: #fca5a5;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --shadow-lg: 0 24px 60px rgba(2, 6, 23, 0.42);
  --shadow-md: 0 14px 30px rgba(2, 6, 23, 0.32);
  --shadow-sm: 0 8px 18px rgba(2, 6, 23, 0.24);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.12), transparent 24%),
    linear-gradient(180deg, #09111d 0%, var(--bg) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.045) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.28), transparent 70%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 40px 0 56px;
}

.page-shell-single {
  width: min(1040px, calc(100% - 2rem));
}

.layout-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.card {
  background: rgba(15, 27, 45, 0.8);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
}

.hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  padding: 32px;
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(15, 27, 45, 0.94), rgba(17, 24, 39, 0.92)),
    var(--surface);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.hero::after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  right: -60px;
  top: -90px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(96, 165, 250, 0.16), transparent 70%);
}

.hero-single {
  min-height: 172px;
}

.hero h1,
.panel h2 {
  margin: 10px 0 12px;
  letter-spacing: -0.03em;
}

.hero h1 {
  font-size: clamp(2rem, 4vw, 3.15rem);
  line-height: 1.02;
}

.panel h2 {
  font-size: 1.5rem;
}

.hero-copy,
.hint,
.identity-bar p,
.conversation-head p,
.conversation-item small,
.muted {
  margin: 0;
  color: var(--text-soft);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #93c5fd, var(--primary));
  box-shadow: 0 0 0 6px rgba(96, 165, 250, 0.12);
}

.security-summary,
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.security-summary span,
.pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.5);
  color: var(--text-soft);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.14);
}

.panel {
  padding: 30px;
  border-radius: 28px;
  background: rgba(15, 27, 45, 0.86);
}

.single-panel {
  min-height: 70vh;
}

.panel-header,
.identity-bar,
.conversation-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.panel-header {
  margin-bottom: 26px;
}

#user-guest-view,
#admin-guest-view,
#user-auth-view,
#admin-auth-view {
  display: grid;
  gap: 22px;
}

#user-guest-view {
  justify-items: center;
}

#user-guest-view .hint {
  text-align: center;
}

.stack-form,
.message-form {
  display: grid;
  gap: 16px;
}

.stack-form {
  max-width: 460px;
  padding: 24px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(20, 32, 52, 0.96), rgba(15, 27, 45, 0.88));
  box-shadow: var(--shadow-sm);
}

.stack-form label,
.message-form {
  margin-top: 0;
}

.stack-form span {
  display: block;
  margin-bottom: 8px;
  color: var(--text-soft);
  font-size: 0.96rem;
  font-weight: 600;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 90px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text-soft);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.password-toggle svg {
  width: 20px;
  height: 20px;
}

.password-toggle .icon-eye-off {
  display: none;
}

.password-toggle.is-visible .icon-eye {
  display: none;
}

.password-toggle.is-visible .icon-eye-off {
  display: block;
}

input,
textarea {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 16px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 14px 16px;
  outline: none;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

input:focus,
textarea:focus {
  border-color: rgba(96, 165, 250, 0.34);
  background: #1b2b42;
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.14);
}

textarea {
  min-height: 104px;
  resize: vertical;
}

button {
  border: none;
  border-radius: 16px;
  padding: 13px 18px;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff;
  font-weight: 700;
  letter-spacing: -0.01em;
  box-shadow: 0 12px 22px rgba(37, 99, 235, 0.18);
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    opacity 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(37, 99, 235, 0.22);
}

button:active {
  transform: translateY(0);
}

.ghost-button,
.switcher-button,
.conversation-item,
.password-toggle {
  box-shadow: none;
}

.ghost-button,
.switcher-button {
  background: transparent;
  color: var(--text-soft);
}

.ghost-button {
  padding-inline: 16px;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.28);
}

.ghost-button:hover,
.switcher-button:hover,
.conversation-item:hover {
  transform: none;
}

.ghost-button:hover {
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.34);
}

.switcher-button:hover,
.password-toggle:hover {
  box-shadow: none;
}

.password-toggle:hover {
  transform: translateY(-50%);
}

.switcher {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border-radius: 18px;
  background: var(--surface-soft);
  width: fit-content;
}

.switcher.compact {
  margin-top: 2px;
}

.switcher-button {
  padding: 11px 15px;
  border-radius: 14px;
}

.switcher-button.active {
  background: rgba(15, 27, 45, 0.96);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.chat-section,
.admin-grid {
  margin-top: 10px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.conversation-list,
.conversation-detail,
.chat-box {
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(20, 32, 52, 0.96), rgba(15, 27, 45, 0.88));
  box-shadow: var(--shadow-sm);
}

.conversation-list {
  min-height: 420px;
  max-height: 620px;
  overflow: auto;
  padding: 10px;
}

.conversation-detail {
  padding: 22px;
}

.chat-box {
  min-height: 340px;
  max-height: 440px;
  overflow: auto;
  padding: 16px;
  display: grid;
  gap: 12px;
  background: linear-gradient(180deg, #101d31, #0d1727);
}

.message {
  max-width: min(85%, 720px);
  padding: 13px 15px;
  border-radius: 18px 18px 18px 8px;
  background: #162337;
  color: var(--text);
  box-shadow: 0 8px 18px rgba(2, 6, 23, 0.18);
}

.message.self {
  margin-left: auto;
  border-radius: 18px 18px 8px 18px;
  background: linear-gradient(135deg, #16365f, #123054);
}

.message-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.message-head strong {
  color: var(--text-soft);
}

.message-body {
  margin-top: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}

.conversation-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 14px;
  border-radius: 18px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.conversation-item:hover {
  background: rgba(19, 32, 52, 0.92);
  box-shadow:
    0 0 0 1px rgba(96, 165, 250, 0.2),
    0 14px 28px rgba(2, 6, 23, 0.24);
}

.conversation-item.active {
  background: rgba(15, 27, 45, 0.96);
  box-shadow:
    inset 0 0 0 1px rgba(148, 163, 184, 0.08),
    var(--shadow-sm);
}

.conversation-item.active:hover {
  background: rgba(17, 31, 51, 0.98);
  box-shadow:
    0 0 0 1px rgba(96, 165, 250, 0.24),
    0 16px 30px rgba(2, 6, 23, 0.28),
    inset 0 0 0 1px rgba(148, 163, 184, 0.06);
}

.conversation-item strong {
  font-size: 0.98rem;
}

.message-form {
  margin-top: 16px;
}

.message-form button {
  justify-self: flex-end;
  min-width: 160px;
}

.alert {
  margin-bottom: 20px;
  padding: 15px 18px;
  border-radius: 18px;
  background: rgba(127, 29, 29, 0.2);
  color: var(--danger);
  box-shadow: var(--shadow-sm);
}

.alert.success {
  background: rgba(20, 83, 45, 0.24);
  color: var(--success);
}

.hidden {
  display: none !important;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 150px;
  padding: 22px;
  text-align: center;
  color: var(--text-muted);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.45);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 980px) {
  .page-shell {
    padding-top: 24px;
  }

  .hero,
  .layout-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .panel,
  .hero {
    padding: 22px;
    border-radius: 24px;
  }

  .stack-form {
    max-width: none;
  }

  .message {
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100%, calc(100% - 1rem));
  }

  .panel,
  .hero,
  .conversation-detail,
  .stack-form {
    padding: 18px;
  }

  .panel-header,
  .identity-bar,
  .conversation-head {
    flex-direction: column;
    align-items: stretch;
  }

  .switcher {
    width: 100%;
  }

  .switcher-button {
    flex: 1;
  }

  .message-form button,
  .ghost-button {
    width: 100%;
  }
}
