:root {
  color-scheme: light;
  --bg: #ece6de;
  --panel: rgba(251, 247, 241, 0.9);
  --sidebar: #202520;
  --ink: #211c18;
  --muted: #6d6359;
  --line: rgba(58, 42, 30, 0.12);
  --accent: #b75a29;
  --accent-soft: rgba(183, 90, 41, 0.12);
  --sage: #415446;
  --danger: #b0483f;
  --shadow: 0 24px 60px rgba(34, 24, 17, 0.12);
  --radius-lg: 28px;
  --radius-md: 20px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  background: linear-gradient(180deg, #efe9e0 0%, #e3d9cd 100%);
  font-family: "IBM Plex Sans", "Noto Sans SC", "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.page-backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at top right, rgba(183, 90, 41, 0.14), transparent 24rem),
    radial-gradient(circle at bottom left, rgba(65, 84, 70, 0.12), transparent 24rem);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card,
.panel,
.detail-empty,
.modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-card {
  width: min(480px, 100%);
  padding: 34px;
}

.auth-card h1,
.coach-brand h2,
.main-head h2,
.detail-head h2,
.detail-empty h3 {
  margin: 0;
  font-family: "IBM Plex Serif", "Source Han Serif SC", serif;
  letter-spacing: -0.02em;
}

.auth-copy {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.auth-form,
.stack,
.sidebar-actions,
.detail-conversations,
.detail-messages {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
}

label span {
  font-size: 0.92rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  padding: 14px 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  border-radius: 16px;
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(183, 90, 41, 0.7);
  box-shadow: 0 0 0 4px rgba(183, 90, 41, 0.08);
}

.primary-button,
.ghost-button,
.student-card,
.detail-conversation {
  border: 0;
  border-radius: 16px;
}

.primary-button {
  padding: 14px 18px;
  color: #fff8f3;
  background: linear-gradient(135deg, #a0481f, #cd7341);
  box-shadow: 0 14px 28px rgba(160, 72, 31, 0.18);
}

.ghost-button {
  padding: 11px 14px;
  color: inherit;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid var(--line);
}

.status-text,
.muted {
  color: var(--muted);
}

.coach-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(0, 1.1fr) minmax(360px, 0.9fr);
}

.coach-sidebar {
  padding: 22px 18px;
  color: #f1ece3;
  background:
    radial-gradient(circle at top, rgba(183, 90, 41, 0.18), transparent 14rem),
    linear-gradient(180deg, #1c211d 0%, #171b17 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  align-content: start;
  gap: 18px;
}

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

.metric-card {
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 18px;
}

.metric-card span {
  display: block;
  color: rgba(241, 236, 227, 0.7);
  font-size: 0.88rem;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 2rem;
}

.panel {
  padding: 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h3 {
  margin: 0;
}

.coach-main,
.coach-detail {
  padding: 24px;
  min-width: 0;
}

.coach-main {
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.main-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.student-grid {
  display: grid;
  gap: 14px;
  min-height: 0;
  overflow: auto;
  padding-right: 6px;
}

.student-card,
.detail-conversation {
  width: 100%;
  padding: 18px;
  text-align: left;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  display: grid;
  gap: 12px;
}

.student-card.active,
.detail-conversation.active {
  border-color: rgba(183, 90, 41, 0.28);
  box-shadow: inset 0 0 0 1px rgba(183, 90, 41, 0.18);
}

.student-head,
.student-meta,
.modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.detail-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.detail-summary {
  min-width: 0;
  flex: 1 1 auto;
}

.detail-summary p,
.detail-summary h2 {
  overflow-wrap: anywhere;
}

.detail-actions {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  align-items: start;
  justify-content: end;
  gap: 8px;
  flex: 0 0 auto;
}

.detail-actions .ghost-button {
  padding: 7px 11px;
  white-space: nowrap;
  word-break: keep-all;
  font-size: 0.88rem;
  line-height: 1.2;
  min-width: max-content;
}

.student-head p,
.student-meta,
.detail-conversation p,
.detail-conversation span,
.transcript-card header span {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 8px 14px;
  color: var(--sage);
  background: rgba(65, 84, 70, 0.12);
  border: 1px solid rgba(65, 84, 70, 0.14);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.pill.danger {
  color: var(--danger);
  background: rgba(176, 72, 63, 0.12);
  border-color: rgba(176, 72, 63, 0.16);
}

.detail-empty {
  padding: 28px;
}

.detail-columns {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.transcript-panel {
  min-height: 0;
}

.detail-conversations {
  max-height: 260px;
  overflow: auto;
}

.detail-messages {
  max-height: calc(100vh - 260px);
  overflow: auto;
}

.transcript-card {
  padding: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.transcript-card header,
.transcript-grid {
  display: grid;
  gap: 12px;
}

.transcript-card h4,
.transcript-card h5 {
  margin: 0;
}

.transcript-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.transcript-reply .reply-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.8;
}

.transcript-reply .reply-text :where(h1, h2, h3, h4, h5, h6, p, ul, ol, blockquote, hr) {
  margin: 0;
}

.transcript-reply .reply-text > :where(h1, h2, h3, h4, h5, h6, p, ul, ol, blockquote, hr, pre) + :where(h1, h2, h3, h4, h5, h6, p, ul, ol, blockquote, hr, pre) {
  margin-top: 0.38rem;
}

.transcript-reply .reply-text :where(h1, h2, h3, h4, h5, h6) {
  line-height: 1.35;
  font-weight: 700;
}

.transcript-reply .reply-text h1 {
  font-size: 1.2rem;
}

.transcript-reply .reply-text h2 {
  font-size: 1.12rem;
}

.transcript-reply .reply-text h3,
.transcript-reply .reply-text h4,
.transcript-reply .reply-text h5,
.transcript-reply .reply-text h6 {
  font-size: 1rem;
}

.transcript-reply .reply-text :where(ul, ol) {
  padding-left: 1.05rem;
}

.transcript-reply .reply-text li {
  margin: 0;
  line-height: 1.7;
}

.transcript-card.user .reply-text {
  line-height: 1.45;
}

.transcript-card.user .reply-text > :where(h1, h2, h3, h4, h5, h6, p, ul, ol, blockquote, hr, pre) + :where(h1, h2, h3, h4, h5, h6, p, ul, ol, blockquote, hr, pre) {
  margin-top: 0 !important;
}

.transcript-card.user .reply-text :where(h1, h2, h3, h4, h5, h6, p, ul, ol, li, blockquote, hr) {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

.transcript-card.user .reply-text :where(ul, ol) {
  padding-left: 0.95rem;
  margin-left: 0 !important;
}

.transcript-card.user .reply-text li + li {
  margin-top: 0 !important;
}

.transcript-card.user .reply-text h1,
.transcript-card.user .reply-text h2,
.transcript-card.user .reply-text h3,
.transcript-card.user .reply-text h4,
.transcript-card.user .reply-text h5,
.transcript-card.user .reply-text h6 {
  line-height: 1.2;
}

.transcript-reply .reply-text pre {
  margin-top: 0;
  padding: 14px;
  color: #f4eee7;
  background: #181b19;
  border-radius: 16px;
  overflow: auto;
}

.transcript-reply .reply-text code {
  padding: 0.15em 0.38em;
  background: rgba(24, 27, 25, 0.08);
  border-radius: 8px;
  font-family: "IBM Plex Mono", "Consolas", monospace;
  font-size: 0.94em;
}

.transcript-reply .reply-text pre code {
  padding: 0;
  background: transparent;
}

.case-block + .case-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(58, 42, 30, 0.08);
}

.case-block strong {
  display: block;
  margin-bottom: 8px;
}

.transcript-section {
  padding: 14px;
  background: rgba(255, 255, 255, 0.54);
  border: 1px solid rgba(58, 42, 30, 0.08);
  border-radius: 14px;
}

.transcript-section ul,
.transcript-section p {
  margin: 0;
}

.transcript-section.code {
  margin-top: 14px;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "IBM Plex Mono", "Consolas", monospace;
  line-height: 1.6;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 20;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 14, 12, 0.42);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(480px, 100%);
  padding: 28px;
}

@media (max-width: 1200px) {
  .coach-layout {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .coach-main {
    height: auto;
    overflow: visible;
  }

  .coach-detail {
    grid-column: 1 / -1;
  }

  .detail-messages {
    max-height: none;
  }
}

@media (max-width: 860px) {
  .coach-layout {
    grid-template-columns: 1fr;
  }

  .student-grid {
    overflow: visible;
  }

  .main-head,
  .detail-head,
  .detail-actions,
  .student-head,
  .student-meta {
    flex-direction: column;
    align-items: stretch;
  }

  .transcript-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }
}
