:root {
  color-scheme: light;
  --ink: #512244;
  --muted: #7e5d74;
  --line: #ead6df;
  --panel: #ffffff;
  --soft: #fff7fa;
  --accent: #d06e93;
  --accent-dark: #642653;
  --red: #f21b1b;
  --rose: #d89aad;
  --green: #7c6e9f;
  --shadow: 0 18px 42px rgba(81, 34, 68, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% 10%, rgba(208, 110, 147, 0.2), transparent 24rem),
    radial-gradient(circle at 84% 22%, rgba(124, 110, 159, 0.14), transparent 22rem),
    linear-gradient(135deg, #fffafb 0%, #f8edf3 48%, #fff 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  background: #642653;
  color: #fff;
}

.sidebar::before {
  position: absolute;
  inset: 0;
  content: "";
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 255, 255, 0.22) 0 2px, transparent 3px),
    radial-gradient(circle at 72% 10%, rgba(255, 255, 255, 0.16) 0 3px, transparent 4px),
    radial-gradient(circle at 86% 34%, rgba(255, 255, 255, 0.18) 0 2px, transparent 3px),
    radial-gradient(circle at 28% 54%, rgba(255, 255, 255, 0.14) 0 3px, transparent 4px),
    radial-gradient(circle at 76% 76%, rgba(255, 255, 255, 0.2) 0 2px, transparent 3px);
  pointer-events: none;
}

.sidebar > * {
  position: relative;
  z-index: 1;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: #fff;
  object-fit: cover;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.7);
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3,
.panel p {
  margin: 0;
}

.brand h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  line-height: 1;
}

.brand p,
.sidebar-note p {
  color: rgba(255, 255, 255, 0.72);
}

.nav-tabs {
  display: grid;
  gap: 14px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: transparent;
  color: #fff;
  font-size: 1.04rem;
  font-weight: 800;
  text-align: left;
}

.nav-tab[data-view="home"] {
  border-color: rgba(255, 255, 255, 0.36);
  background: rgba(255, 255, 255, 0.13);
  box-shadow: 0 12px 30px rgba(40, 14, 33, 0.16);
}

.nav-tab[data-view="home"] span {
  color: #d89aad;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.42);
}

.nav-tab.active,
.nav-tab:hover {
  background: rgba(255, 255, 255, 0.15);
}

.staff-access {
  display: grid;
  gap: 10px;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.staff-access summary {
  width: max-content;
  color: rgba(255, 255, 255, 0.58);
  font-size: 0.78rem;
  font-weight: 700;
  list-style-position: inside;
  outline: none;
}

.staff-access summary:hover {
  color: rgba(255, 255, 255, 0.82);
}

.staff-access div {
  display: grid;
  gap: 8px;
  justify-items: start;
}

.staff-link {
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: left;
}

.staff-link:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.staff-link::after {
  margin-left: 6px;
  color: rgba(255, 255, 255, 0.48);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.staff-link[data-access="guide"]::after {
  content: "Guide";
}

.staff-link[data-access="admin"]::after {
  content: "Admin";
}

body.guide-unlocked .staff-link[data-access="guide"]::after,
body.admin-unlocked .staff-link[data-access="admin"]::after {
  content: "";
}

.sidebar-note {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.sidebar-note h2 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h2 {
  max-width: 780px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 2vw, 2.15rem);
  line-height: 1.14;
}

body[data-view="thread"] .sidebar,
body[data-view="thread"] .topbar {
  display: none;
}

body[data-view="thread"] .app-shell {
  grid-template-columns: 1fr;
}

body[data-view="thread"] main {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hidden {
  display: none;
}

.split-layout,
.mentor-grid,
.settings-layout {
  display: grid;
  gap: 18px;
}

.split-layout {
  grid-template-columns: minmax(340px, 0.92fr) minmax(360px, 1.08fr);
  align-items: start;
}

.mentor-grid {
  grid-template-columns: minmax(310px, 0.42fr) minmax(420px, 0.58fr);
}

.settings-layout {
  grid-template-columns: minmax(320px, 0.85fr) minmax(320px, 1fr);
}

.panel {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.opening-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, 0.34fr);
  gap: 22px;
  align-items: end;
  min-height: calc(100vh - 190px);
  padding: clamp(28px, 5vw, 56px);
  border: 1px solid #efcad8;
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 244, 247, 0.96)),
    radial-gradient(circle at right top, rgba(208, 110, 147, 0.18), transparent 20rem);
  box-shadow: 0 18px 48px rgba(81, 34, 68, 0.1);
}

.opening-copy {
  max-width: 760px;
}

.opening-copy h3,
.opening-copy p {
  margin: 0;
}

.opening-copy h3 {
  margin-top: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.15rem, 4.8vw, 4.8rem);
  line-height: 0.98;
}

.opening-copy p:not(.eyebrow) {
  max-width: 680px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.55;
}

.opening-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.opening-actions .primary-action,
.opening-actions .secondary-action {
  min-width: 180px;
  padding: 0 20px;
}

.opening-promises {
  display: grid;
  gap: 10px;
}

.opening-promises button {
  padding: 12px;
  border: 1px solid #efcad8;
  border-radius: 999px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
}

.opening-promises button:hover,
.welcome-badges button:hover {
  border-color: var(--accent);
  background: #fff0f5;
}

.student-welcome {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  margin-bottom: 18px;
  padding: 24px;
  border: 1px solid #efcad8;
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.88), rgba(255, 244, 247, 0.95)),
    radial-gradient(circle at right top, rgba(208, 110, 147, 0.18), transparent 18rem);
  box-shadow: 0 18px 48px rgba(81, 34, 68, 0.1);
}

.student-welcome h3,
.student-welcome p {
  margin: 0;
}

.student-welcome h3 {
  max-width: 780px;
  margin-top: 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 2.4vw, 2.35rem);
  line-height: 1.08;
}

.student-welcome p:not(.eyebrow) {
  max-width: 720px;
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.5;
}

.welcome-badges {
  display: grid;
  gap: 8px;
  min-width: 170px;
}

.welcome-badges button {
  padding: 8px 10px;
  border: 1px solid #efcad8;
  border-radius: 999px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 0.84rem;
  font-weight: 800;
  text-align: center;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel h3 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
}

.status-pill {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f9e1ea;
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 700;
}

.privacy-note {
  margin: 0 0 4px;
  padding: 14px;
  border: 1px solid #efcad8;
  border-radius: 12px;
  background: #fff4f7;
  color: var(--accent-dark);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.45;
}

form,
.reply-options {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdfd;
  color: var(--ink);
  padding: 13px 14px;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.45;
  min-height: 178px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(208, 110, 147, 0.18);
}

.choice-row,
.reply-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdfd;
  color: var(--ink);
  font-size: 0.9rem;
}

.toggle-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.attention-pulse {
  animation: attentionPulse 900ms ease;
}

@keyframes attentionPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(208, 110, 147, 0.42);
  }

  100% {
    box-shadow: 0 0 0 12px rgba(208, 110, 147, 0);
  }
}

.primary-action,
.reply-box button {
  min-height: 50px;
  border: 0;
  border-radius: 999px;
  background: var(--accent-dark);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 10px 26px rgba(100, 38, 83, 0.18);
}

.primary-action:hover,
.reply-box button:hover {
  background: #4b1c3e;
}

.secondary-action,
.danger-action,
.filter {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

.secondary-action {
  padding: 0 12px;
}

.danger-action {
  padding: 0 12px;
  color: var(--red);
}

.danger-action.flagged {
  background: #ffeaef;
  border-color: #e8adbf;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.filter.active {
  border-color: var(--accent);
  background: #fff0f5;
  color: var(--accent-dark);
}

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

.inbox-item {
  width: 100%;
  min-height: 94px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.inbox-item.active {
  border-color: var(--accent);
  background: #fff2f6;
}

.inbox-meta,
.message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.inbox-item strong {
  display: block;
  margin: 8px 0 4px;
}

.inbox-item p {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.conversation {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 320px;
  max-height: 470px;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    radial-gradient(circle at 18% 12%, rgba(208, 110, 147, 0.1), transparent 14rem),
    #fff7fa;
}

.thread-only-view {
  width: min(860px, 100%);
}

.thread-only-shell {
  padding: clamp(18px, 4vw, 34px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.thread-only-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.thread-only-header h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 2.2vw, 2.1rem);
}

.thread-only-conversation {
  min-height: min(58vh, 560px);
  max-height: min(62vh, 640px);
}

.message {
  max-width: min(82%, 620px);
  padding: 13px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 8px 20px rgba(81, 34, 68, 0.07);
}

.message.mentor {
  align-self: flex-end;
  background: #fff0f5;
  border-color: #efcad8;
}

.message.student {
  align-self: flex-start;
}

.message p {
  margin: 6px 0 0;
  line-height: 1.45;
}

.empty-state {
  display: grid;
  min-height: 280px;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 18px;
  border: 1px dashed #e8bdca;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.68);
}

.empty-state.compact {
  min-height: 120px;
}

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

.policy-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.5;
}

.mentor-card {
  display: grid;
  gap: 6px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.mentor-card:last-child {
  border-bottom: 0;
}

.mentor-card strong {
  color: var(--ink);
}

.mentor-card span {
  color: var(--muted);
}

.mentor-card em {
  color: var(--accent-dark);
  font-style: normal;
  font-weight: 700;
  line-height: 1.35;
}

.mentor-card-actions,
.guide-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.mentor-card-actions button,
.guide-actions button {
  min-height: 38px;
}

.guide-editor-panel {
  grid-column: 1 / -1;
}

.guide-form textarea {
  min-height: 96px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  transform: translateY(20px);
  opacity: 0;
  max-width: 320px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--accent-dark);
  color: #fff;
  transition: 180ms ease;
  pointer-events: none;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.access-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(81, 34, 68, 0.55);
}

.access-modal.open {
  display: flex;
}

.access-card {
  display: grid;
  width: min(440px, 100%);
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.access-card h2,
.access-card p {
  margin: 0;
}

.access-card h2 {
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
}

.access-card p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.45;
}

.access-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

  .sidebar {
    position: static;
  }

  .nav-tabs {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .split-layout,
  .mentor-grid,
  .settings-layout,
  .opening-page,
  .student-welcome {
    grid-template-columns: 1fr;
  }

  .opening-page {
    min-height: auto;
  }

  .welcome-badges {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  main,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .panel-header,
  .thread-only-header {
    align-items: stretch;
    flex-direction: column;
  }

  .choice-row,
  .reply-options,
  .filter-row,
  .nav-tabs,
  .opening-actions,
  .welcome-badges {
    grid-template-columns: 1fr;
  }

  .opening-actions {
    display: grid;
  }

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