:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-alt: #f9fbfd;
  --text: #17202c;
  --muted: #667085;
  --line: #d9e2ec;
  --blue: #2563eb;
  --cyan: #21c7b7;
  --green: #16a34a;
  --red: #b42318;
  --shadow: rgba(16, 24, 40, 0.09);
  --gradient: linear-gradient(90deg, #2563eb 0%, #21c7b7 48%, #16a34a 100%);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
button, textarea { font: inherit; }
button { cursor: pointer; }

.app-frame { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 12px clamp(20px, 5vw, 76px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
}
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 11px;
  background: var(--gradient);
  color: #fff;
  font-weight: 900;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; letter-spacing: -.02em; }
.brand small { color: var(--muted); font-size: 11px; font-weight: 700; }
.nav-links { display: flex; gap: 20px; color: var(--muted); font-size: 14px; font-weight: 750; }
.nav-links a:hover { color: var(--blue); }
.nav-action, .primary-button, .secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-size: 14px;
  font-weight: 800;
}
.nav-action:hover, .secondary-button:hover { border-color: var(--blue); color: var(--blue); }
.primary-button { border: 0; background: var(--gradient); color: #fff; box-shadow: 0 10px 24px rgba(37, 99, 235, .18); }
.primary-button:hover { filter: brightness(1.03); }
.primary-button:disabled { cursor: not-allowed; opacity: .55; }

main { width: min(1040px, 100%); margin: 0 auto; padding: clamp(28px, 6vw, 76px) clamp(20px, 5vw, 42px); flex: 1; }
.hero { max-width: 700px; padding: clamp(28px, 6vw, 72px) 0; }
.eyebrow { margin: 0 0 10px; color: var(--blue); font-size: 12px; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
h1 { max-width: 760px; margin: 0; font-size: clamp(38px, 7vw, 68px); line-height: 1.03; letter-spacing: -.055em; }
.hero-copy { max-width: 560px; margin: 22px 0 28px; color: var(--muted); font-size: clamp(17px, 2vw, 20px); line-height: 1.6; }
.dashboard { display: grid; gap: 22px; }
.dashboard-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.dashboard-head h1 { font-size: clamp(30px, 5vw, 46px); }
.dashboard-head p { max-width: 640px; margin: 12px 0 0; color: var(--muted); line-height: 1.55; }
.card { padding: clamp(20px, 3vw, 30px); border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: 0 12px 36px var(--shadow); }
.card h2 { margin: 0; font-size: 21px; letter-spacing: -.02em; }
.card p { color: var(--muted); line-height: 1.6; }
.privacy-copy { display: grid; gap: 12px; margin-top: 18px; }
.privacy-copy p { margin: 0; }
.notice { padding: 14px 16px; border: 1px solid #bed3f9; border-radius: 8px; background: #f2f7ff; color: #244c92; line-height: 1.5; }
.notice.warning { border-color: #efd7aa; background: #fff9ee; color: #885b12; }
.notice.error { border-color: #e6b3ad; background: #fff4f2; color: var(--red); }
.case-list { display: grid; gap: 10px; margin-top: 18px; }
.case-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-alt); }
.case-row strong, .case-row span { display: block; }
.case-row span { margin-top: 2px; color: var(--muted); font-size: 13px; }
.case-actions { display: flex; align-items: center; gap: 10px; }
.compact-button { min-height: 36px; padding: 0 12px; }
.queue-group { display: grid; gap: 8px; margin-top: 20px; }
.queue-group h3 { margin: 0; color: var(--muted); font-size: 14px; }
.case-meta { margin: 4px 0 0; color: var(--muted) !important; font-size: 13px; }
.text-button { border: 0; background: transparent; color: var(--blue); font-weight: 800; }
.conversation { display: grid; gap: 16px; }
.conversation-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.conversation-header h2 { margin-bottom: 4px; }
.case-status { margin: 0; color: var(--blue) !important; font-size: 13px; font-weight: 800; }
.message-list { display: grid; gap: 10px; max-height: 420px; overflow-y: auto; }
.attachment-panel { display: grid; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-alt); }
.attachment-panel h3, .attachment-panel p { margin: 0; }
.attachment-panel h3 { font-size: 14px; }
.attachment-panel p { font-size: 13px; }
.attachment-link { color: var(--blue); font-size: 14px; font-weight: 800; }
.attachment-upload { display: grid; gap: 6px; color: var(--text); font-size: 13px; font-weight: 800; }
.attachment-upload input { max-width: 100%; font: inherit; font-weight: 500; }
.support-tools, .internal-notes { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-alt); }
.support-tools h3, .internal-notes h3 { margin: 0; font-size: 14px; }
.tool-form { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; }
.tool-form label { display: grid; gap: 5px; color: var(--text); font-size: 13px; font-weight: 800; }
select { min-height: 38px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--text); font: inherit; }
.note-list { display: grid; gap: 8px; }
.note-list > p { margin: 0; font-size: 13px; }
.internal-note { padding: 10px 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); }
.internal-note small { color: var(--muted); font-size: 11px; font-weight: 800; }
.internal-note p { margin: 4px 0 0; color: var(--text); overflow-wrap: anywhere; }
.admin-form-card { display: grid; gap: 16px; }
.admin-membership-form { display: grid; gap: 12px; }
.admin-membership-form > label, .destination-options { display: grid; gap: 6px; color: var(--text); font-size: 14px; font-weight: 800; }
.admin-membership-form input[type="text"] { min-height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel-alt); color: var(--text); font: inherit; }
.admin-enabled, .destination-option { display: flex !important; align-items: center; gap: 8px; }
.destination-options { padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-alt); }
.destination-options legend { padding: 0 4px; }
.membership-list, .audit-list { display: grid; gap: 10px; margin-top: 18px; }
.membership-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-alt); }
.membership-row strong, .membership-row span, .audit-row strong, .audit-row span { display: block; }
.membership-row span, .audit-row span { margin-top: 3px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.audit-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.audit-row:last-child { border-bottom: 0; }
.identity-reveal-panel { display: grid; gap: 10px; padding: 14px; border: 1px solid #e6b3ad; border-radius: 8px; background: #fff8f7; }
.identity-reveal-panel h3 { margin: 0; font-size: 14px; }
.reveal-confirmation { display: flex !important; align-items: flex-start; gap: 8px; color: var(--text); font-size: 13px !important; font-weight: 800; line-height: 1.4; }
.danger-button { justify-self: start; min-height: 42px; padding: 0 15px; border: 1px solid var(--red); border-radius: 8px; background: var(--red); color: #fff; font: inherit; font-size: 14px; font-weight: 800; }
.danger-button:disabled { cursor: not-allowed; opacity: .55; }
.revealed-subject { margin: 0; padding: 10px 12px; border: 1px solid #e6b3ad; border-radius: 7px; background: var(--panel); color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; overflow-wrap: anywhere; }
.head-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.message { max-width: min(85%, 640px); padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-alt); }
.message.student { justify-self: end; border-color: #b9d5fa; background: #f1f7ff; }
.message small { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.message p { margin: 0; color: var(--text); line-height: 1.5; overflow-wrap: anywhere; }
.message-form { display: grid; gap: 10px; }
.message-form label { font-size: 14px; font-weight: 800; }
.form-helper, .character-count, .send-status { margin: -3px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.typing-status { min-height: 20px; margin: -6px 0 0; color: var(--muted); font-size: 12px; font-style: italic; }
.live-notice { position: fixed; right: 20px; bottom: 20px; z-index: 10; max-width: min(360px, calc(100vw - 40px)); margin: 0; padding: 12px 14px; border: 1px solid #bed3f9; border-radius: 8px; background: #f2f7ff; box-shadow: 0 12px 36px var(--shadow); color: #244c92; font-size: 14px; font-weight: 750; line-height: 1.45; }
.character-count { margin: 0 auto 0 0; font-variant-numeric: tabular-nums; }
.error-text { color: var(--red); }
textarea { width: 100%; min-height: 124px; resize: vertical; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-alt); color: var(--text); line-height: 1.5; }
textarea:focus { outline: 3px solid rgba(37, 99, 235, .18); border-color: var(--blue); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.footer { display: flex; justify-content: space-between; gap: 18px; padding: 22px clamp(20px, 5vw, 76px); border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

@media (max-width: 650px) {
  .topbar { gap: 12px; min-height: 64px; }
  .nav-links { display: none; }
  .footer, .dashboard-head { align-items: flex-start; flex-direction: column; }
  .case-row { align-items: flex-start; flex-direction: column; }
  .membership-row { align-items: flex-start; flex-direction: column; }
  .case-actions { width: 100%; }
  .conversation-header { align-items: stretch; flex-direction: column; }
  .conversation-header .secondary-button { width: 100%; }
  .head-actions { width: 100%; }
  .head-actions .secondary-button { flex: 1; }
  .message { max-width: 96%; }
}
