:root {
  color-scheme: light;
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #20313a;
  --muted: #66757d;
  --paper: #fffdf7;
  --page: #f7f1e3;
  --blue: #2b6f89;
  --blue-dark: #1f5368;
  --line: #d9d5c9;
  --danger: #8a382c;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--page); color: var(--ink); }
button, input { font: inherit; }
button { cursor: pointer; }
.admin-shell { width: min(1180px, 100%); margin: 0 auto; padding: 28px max(22px, env(safe-area-inset-right)) 40px max(22px, env(safe-area-inset-left)); }
.admin-header, .section-heading, .admin-account { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.admin-header { margin-bottom: 24px; }
.admin-header a { color: var(--blue-dark); font-weight: 750; }
h1 { margin: 5px 0 0; font-size: clamp(34px, 5vw, 48px); }
h2 { margin: 0; }
.admin-account { justify-content: flex-end; font-weight: 700; }
.sign-in-card { width: min(520px, 100%); margin: 70px auto; padding: 32px; border-radius: 22px; background: var(--paper); box-shadow: 0 7px 22px rgb(69 67 57 / 15%); text-align: center; }
.sign-in-card p { color: var(--muted); font-size: 18px; line-height: 1.45; }
.primary-button, .small-button, .quiet-button, .danger-button { min-height: 48px; padding: 9px 16px; border-radius: 12px; font-weight: 800; }
.primary-button { border: 0; background: var(--blue); color: white; }
.small-button, .quiet-button { border: 2px solid #a9bcc2; background: white; color: var(--blue-dark); }
.danger-button { border: 2px solid #c9978f; background: #fff6f4; color: var(--danger); }
.message { min-height: 24px; margin: 8px 0 16px; color: var(--muted); font-weight: 650; }
.message.error { color: var(--danger); }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.metric-card { padding: 17px; border: 2px solid white; border-radius: 17px; background: var(--paper); box-shadow: 0 3px 12px rgb(69 67 57 / 9%); }
.metric-card span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 14px; font-weight: 750; }
.metric-card strong { font-size: 27px; }
.dashboard-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 20px; align-items: start; }
.profiles-panel, .profile-detail { padding: 20px; border-radius: 20px; background: var(--paper); box-shadow: 0 4px 16px rgb(69 67 57 / 11%); }
.profile-list { display: grid; gap: 9px; margin-top: 16px; }
.profile-button { width: 100%; padding: 13px; border: 2px solid var(--line); border-radius: 12px; background: white; color: var(--ink); text-align: left; }
.profile-button strong, .profile-button span { display: block; }
.profile-button span { margin-top: 3px; color: var(--muted); font-size: 13px; }
.profile-button.is-selected { border-color: var(--blue); background: #eef8fa; }
.profile-button.is-disabled { opacity: .62; }
.profile-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.profile-top p { margin: 5px 0 0; color: var(--muted); }
.profile-actions { display: flex; gap: 8px; }
.detail-metrics { grid-template-columns: repeat(3, 1fr); }
.detail-section { margin-top: 24px; }
.detail-section h3 { margin: 0 0 10px; }
.mistake-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.mistake-box { padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.mistake-box h4 { margin: 0 0 8px; }
.mistake-box ul { margin: 0; padding-left: 22px; }
.attempt-table { width: 100%; border-collapse: collapse; }
.attempt-table th, .attempt-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.attempt-table th { color: var(--muted); font-size: 13px; }
.score-track { width: 90px; height: 9px; margin-top: 5px; overflow: hidden; border-radius: 99px; background: #e0e4e5; }
.score-track span { display: block; height: 100%; background: #5b9a70; }
.writing-response-list { display: grid; gap: 10px; }
.writing-response-card { padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.writing-response-card > div { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.writing-response-card > div span { color: var(--muted); font-size: 13px; }
.writing-response-card p { margin: 3px 0 10px; white-space: pre-wrap; }
.writing-response-card p:last-child { margin-bottom: 0; color: var(--muted); }
.response-label { color: var(--blue-dark); font-size: 12px; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.empty-state { color: var(--muted); }
.guest-access-panel { margin-bottom: 24px; padding: 20px; border-radius: 20px; background: var(--paper); box-shadow: 0 4px 16px rgb(69 67 57 / 11%); }
.guest-access-note { color: var(--muted); font-size: 14px; line-height: 1.5; }
.guest-access-panel summary { color: var(--blue-dark); font-weight: 750; cursor: pointer; padding: 10px 0; }
.guest-access-tables { display: grid; grid-template-columns: minmax(190px, 1fr) minmax(0, 3fr); gap: 20px; }
.guest-history-wrap { overflow-x: auto; }
.guest-access-tables h3 { margin: 10px 0; }
dialog { width: min(480px, calc(100% - 32px)); padding: 0; border: 0; border-radius: 20px; background: var(--paper); color: var(--ink); box-shadow: 0 15px 50px rgb(0 0 0 / 24%); }
dialog::backdrop { background: rgb(27 38 42 / 55%); }
#profile-form { padding: 24px; }
#profile-form label { display: block; margin: 17px 0 6px; font-weight: 800; }
#profile-form input:not([type="hidden"]) { width: 100%; min-height: 52px; padding: 9px 12px; border: 2px solid #9aadb4; border-radius: 11px; background: white; }
.field-help { margin: 6px 0; color: var(--muted); font-size: 14px; }
.close-button { width: 44px; height: 44px; border: 0; background: transparent; color: var(--muted); font-size: 31px; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 4px solid #f2c94c; outline-offset: 3px; }

@media (max-width: 800px) {
  .guest-access-tables { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-layout { grid-template-columns: 1fr; }
  .profile-list { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
}

@media (max-width: 560px) {
  .admin-header, .profile-top { display: block; }
  .admin-account, .profile-actions { justify-content: flex-start; margin-top: 12px; }
  .detail-metrics, .mistake-grid { grid-template-columns: 1fr; }
  .attempt-table th:nth-child(2), .attempt-table td:nth-child(2) { display: none; }
}
