:root {
  --bg: #05050d;
  --panel: rgba(16, 16, 34, 0.88);
  --panel-deep: rgba(8, 8, 18, 0.92);
  --panel-soft: rgba(255, 255, 255, 0.06);
  --text: #f7f2ff;
  --muted: #aaa3c4;
  --purple: #9d4dff;
  --pink: #ff4fd8;
  --blue: #37d5ff;
  --cyan: #41ffe6;
  --green: #44ffb1;
  --danger: #ff4f75;
  --warning: #ffd166;
  --border: rgba(255, 255, 255, 0.14);
  --border-strong: rgba(255, 255, 255, 0.28);
  --shadow: 0 0 36px rgba(157, 77, 255, 0.28);
  --shadow-blue: 0 0 28px rgba(55, 213, 255, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(157, 77, 255, 0.38), transparent 28%),
    radial-gradient(circle at top right, rgba(55, 213, 255, 0.18), transparent 28%),
    radial-gradient(circle at bottom, rgba(255, 79, 216, 0.16), transparent 32%),
    linear-gradient(135deg, #05050d 0%, #0a0a19 45%, #05050d 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent 85%);
}

button,
input,
select,
textarea {
  font-family: inherit;
}

button {
  user-select: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 290px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 24px;
  border-right: 1px solid var(--border);
  background: rgba(5, 5, 13, 0.84);
  backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 28px;
  background: linear-gradient(135deg, var(--purple), var(--pink), var(--blue));
  box-shadow: var(--shadow);
}

.brand h1 {
  margin: 0;
  font-size: 27px;
  line-height: 1;
}

.brand p,
.topbar p,
.panel p,
.login-card p {
  color: var(--muted);
}

.brand p {
  margin: 5px 0 0;
  font-size: 13px;
}

.login-card {
  margin-bottom: 24px;
  padding: 18px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background:
    linear-gradient(135deg, rgba(157, 77, 255, 0.12), rgba(55, 213, 255, 0.05)),
    var(--panel);
  box-shadow: var(--shadow);
}

.login-help {
  margin-bottom: 16px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.045);
}

.login-help strong {
  display: block;
  margin-bottom: 8px;
  color: var(--cyan);
  font-size: 15px;
}

.login-help p {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.45;
}

.code-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding: 10px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.code-row:last-child {
  margin-bottom: 0;
}

.code-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.code-row code {
  color: white;
  font-weight: 900;
  letter-spacing: 0.8px;
  font-size: 12px;
}

#loginForm {
  display: grid;
  gap: 10px;
}

#loginForm label {
  color: var(--blue);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 900;
}

#loginCode,
.login-card select,
.section-header input,
.section-header select,
.chat-input-row input,
.note-box textarea,
.edit-grid input,
.edit-grid select,
.edit-grid textarea,
.reply-box textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  padding: 13px;
  border-radius: 14px;
  outline: none;
}

#loginCode:focus,
.section-header input:focus,
.section-header select:focus,
.chat-input-row input:focus,
.note-box textarea:focus,
.edit-grid input:focus,
.edit-grid select:focus,
.edit-grid textarea:focus,
.reply-box textarea:focus {
  border-color: rgba(55, 213, 255, 0.72);
  box-shadow: 0 0 0 3px rgba(55, 213, 255, 0.12);
}

.login-btn,
.logout-btn,
.nav-btn,
.ghost-btn,
#sendMessageBtn,
.action-row button,
.note-box button,
.status-btn,
.reply-btn,
.save-profile-btn {
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--text);
  padding: 13px 15px;
  border-radius: 16px;
  cursor: pointer;
  transition: 0.22s ease;
  font-weight: 800;
}

.login-btn,
.logout-btn,
.save-profile-btn {
  background: linear-gradient(135deg, rgba(157, 77, 255, 0.62), rgba(55, 213, 255, 0.22));
}

.logout-btn {
  width: 100%;
  margin-top: 10px;
}

.login-btn:hover,
.logout-btn:hover,
.nav-btn:hover,
.nav-btn.active,
.ghost-btn:hover,
#sendMessageBtn:hover,
.action-row button:hover,
.note-box button:hover,
.status-btn:hover,
.reply-btn:hover,
.save-profile-btn:hover {
  background: linear-gradient(135deg, rgba(157, 77, 255, 0.55), rgba(55, 213, 255, 0.22));
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

#loginStatus {
  margin: 0;
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.logged-in-box {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.logged-in-box p {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

nav {
  display: grid;
  gap: 10px;
}

.nav-btn {
  text-align: left;
}

.main {
  padding: 30px;
  transition: 0.22s ease;
}

.main.locked {
  opacity: 0.24;
  pointer-events: none;
  filter: blur(2px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 28px;
}

.eyebrow {
  color: var(--blue);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 900;
  margin: 0 0 8px;
}

.topbar h2 {
  margin: 0;
  font-size: clamp(34px, 4.8vw, 60px);
  line-height: 0.95;
  background: linear-gradient(135deg, var(--text), var(--blue), var(--pink));
  -webkit-background-clip: text;
  color: transparent;
}

.topbar p {
  max-width: 760px;
  line-height: 1.55;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card,
.panel,
.profile-card,
.modal-card,
.feature-card,
.note-item,
.reply-item {
  border: 1px solid var(--border);
  background:
    linear-gradient(135deg, rgba(157, 77, 255, 0.08), rgba(55, 213, 255, 0.035)),
    var(--panel);
  border-radius: 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.stat-card {
  padding: 22px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top right, rgba(65, 255, 230, 0.12), transparent 40%),
    linear-gradient(135deg, rgba(157, 77, 255, 0.12), rgba(55, 213, 255, 0.06));
  pointer-events: none;
}

.stat-card span {
  position: relative;
  color: var(--muted);
  font-size: 13px;
}

.stat-card strong {
  position: relative;
  display: block;
  margin-top: 8px;
  font-size: 36px;
  color: var(--cyan);
}

.panel {
  padding: 22px;
}

.panel h3,
.section-header h3 {
  margin: 0;
  font-size: 25px;
}

.panel p {
  line-height: 1.65;
}

.feature-grid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.feature-card {
  padding: 16px;
  box-shadow: none;
}

.feature-card strong {
  display: block;
  color: var(--cyan);
  margin-bottom: 8px;
}

.feature-card p {
  margin: 0;
  font-size: 13px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 20px;
}

.section-header input,
.section-header select {
  max-width: 330px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.profile-card {
  padding: 18px;
  cursor: pointer;
  transition: 0.22s ease;
  overflow: hidden;
  position: relative;
}

.profile-card:hover {
  transform: translateY(-5px);
  border-color: var(--border-strong);
  box-shadow:
    var(--shadow),
    0 0 24px rgba(55, 213, 255, 0.1);
}

.profile-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      135deg,
      rgba(157, 77, 255, 0.14),
      rgba(255, 79, 216, 0.04),
      rgba(55, 213, 255, 0.08)
    );
  pointer-events: none;
}

.profile-top {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.avatar {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  object-fit: cover;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-blue);
}

.profile-card h4 {
  margin: 0;
  font-size: 18px;
}

.profile-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 15px;
  position: relative;
}

.tag {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(157, 77, 255, 0.22);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
}

.split-layout {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 18px;
}

.conversation-list {
  display: grid;
  gap: 10px;
}

.conversation-item {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  cursor: pointer;
  transition: 0.2s ease;
}

.conversation-item:hover,
.conversation-item.active {
  background:
    linear-gradient(
      135deg,
      rgba(157, 77, 255, 0.34),
      rgba(55, 213, 255, 0.12)
    );
  border-color: var(--border-strong);
}

.conversation-item strong {
  display: block;
  margin-bottom: 5px;
}

.conversation-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.chat-panel {
  min-height: 620px;
  display: flex;
  flex-direction: column;
}

.chat-header {
  border-bottom: 1px solid var(--border);
  margin: -22px -22px 14px;
  padding: 20px 22px;
  background: rgba(255,255,255,0.03);
  border-radius: 26px 26px 0 0;
}

.chat-header h3 {
  margin: 0;
}

.chat-messages {
  flex: 1;
  display: grid;
  align-content: start;
  gap: 10px;
  overflow-y: auto;
  padding-right: 6px;
}

.message-bubble {
  max-width: 76%;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid var(--border);
  line-height: 1.55;
}

.message-bubble.mine {
  margin-left: auto;
  background:
    linear-gradient(
      135deg,
      rgba(157, 77, 255, 0.6),
      rgba(255, 79, 216, 0.22)
    );
}

.message-bubble.theirs {
  background: rgba(255,255,255,0.075);
}

.message-meta {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

.chat-input-row {
  display: flex;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 14px;
}

#sendMessageBtn {
  min-width: 96px;
}

.notes-list {
  display: grid;
  gap: 14px;
  margin-top: 15px;
}

.note-item {
  padding: 18px;
}

.note-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.note-status {
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.status-needs {
  background: rgba(255, 79, 117, 0.2);
  color: #ff6f8f;
}

.status-progress {
  background: rgba(255, 209, 102, 0.18);
  color: #ffd166;
}

.status-done {
  background: rgba(68, 255, 177, 0.16);
  color: #44ffb1;
}

.note-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

.reply-list {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.reply-item {
  padding: 12px;
  border-radius: 18px;
}

.reply-item strong {
  display: block;
  margin-bottom: 6px;
}

.reply-box {
  margin-top: 14px;
}

.reply-box textarea {
  min-height: 80px;
  resize: vertical;
  margin-bottom: 10px;
}

.status-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.status-btn.active-status {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(65,255,230,0.16);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.76);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 50;
}

.modal-card {
  width: min(960px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  background:
    linear-gradient(
      135deg,
      rgba(157,77,255,0.12),
      rgba(55,213,255,0.04)
    ),
    #101024;
  position: relative;
}

.close-btn {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--text);
  font-size: 26px;
  cursor: pointer;
}

.modal-profile-head {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}

.big-avatar {
  width: 90px;
  height: 90px;
  border-radius: 24px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.detail-grid,
.edit-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.detail,
.edit-field {
  padding: 14px;
  background: rgba(255,255,255,0.045);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.detail span,
.edit-field label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.detail strong {
  display: block;
  line-height: 1.45;
}

.edit-field textarea {
  min-height: 90px;
  resize: vertical;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0;
}

.note-box {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.18);
  border-radius: 18px;
}

.note-box h3 {
  margin-top: 0;
}

.note-box textarea {
  min-height: 100px;
  resize: vertical;
  margin: 10px 0;
}

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

::-webkit-scrollbar-thumb {
  background:
    linear-gradient(
      180deg,
      rgba(157,77,255,0.8),
      rgba(55,213,255,0.45)
    );
  border-radius: 999px;
}

::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.03);
}

@media (max-width: 1100px) {
  .stats-grid,
  .feature-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 950px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  .split-layout,
  .detail-grid,
  .edit-grid,
  .stats-grid,
  .feature-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-header,
  .note-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .section-header input,
  .section-header select {
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 20px;
  }

  .panel,
  .modal-card,
  .profile-card,
  .stat-card,
  .note-item,
  .reply-item {
    border-radius: 22px;
  }

  .chat-input-row {
    flex-direction: column;
  }

  #sendMessageBtn {
    width: 100%;
  }

  .action-row,
  .status-row {
    flex-direction: column;
  }

  .action-row button,
  .status-row button {
    width: 100%;
  }
}
