:root {
  --ink: #111827;
  --muted: #64748b;
  --paper: #f7f8fc;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-strong: #ffffff;
  --line: rgba(15, 23, 42, 0.1);
  --nav: #101828;
  --nav-soft: #1d2939;
  --teal: #14b8a6;
  --blue: #4f7cff;
  --violet: #7c3aed;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --green: #22c55e;
  --shadow: 0 18px 55px rgba(15, 23, 42, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(20, 184, 166, 0.16), transparent 34rem),
    radial-gradient(circle at 80% 12%, rgba(79, 124, 255, 0.14), transparent 32rem),
    linear-gradient(135deg, #f7f8fc 0%, #eef3f9 47%, #f9fafb 100%);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body.dark-mode {
  --ink: #eef2ff;
  --muted: #aab7cf;
  --paper: #0b1020;
  --panel: rgba(17, 24, 39, 0.86);
  --panel-strong: #111827;
  --line: rgba(255, 255, 255, 0.12);
  background:
    radial-gradient(circle at top left, rgba(20, 184, 166, 0.15), transparent 34rem),
    radial-gradient(circle at 80% 12%, rgba(124, 58, 237, 0.18), transparent 32rem),
    linear-gradient(135deg, #080d19 0%, #111827 48%, #0f172a 100%);
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.btn.disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 520px) minmax(0, 1fr);
  gap: 18px;
  padding: clamp(18px, 4vw, 42px);
  align-items: stretch;
}

.auth-panel,
.auth-side {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(20px, 4vw, 34px);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-panel {
  display: grid;
  align-content: center;
  gap: 22px;
}

.auth-panel h2,
.auth-side h2 {
  margin: 10px 0 8px;
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1;
}

.auth-panel p,
.auth-side p {
  margin: 0;
  color: var(--muted);
}

.auth-brand {
  padding: 0;
}

.auth-form {
  margin-top: 4px;
}

.auth-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.auth-side {
  display: grid;
  align-content: center;
  background:
    linear-gradient(135deg, rgba(20, 184, 166, 0.12), rgba(79, 124, 255, 0.12)),
    var(--panel);
}

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

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  height: 100dvh;
  padding: 22px 16px;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  color: #f9fafb;
  background:
    linear-gradient(180deg, rgba(16, 24, 40, 0.98), rgba(22, 28, 45, 0.96)),
    var(--nav);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar::-webkit-scrollbar {
  width: 9px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
  background-clip: content-box;
}

.brand,
.nav,
.sidebar-card {
  flex: 0 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 6px 10px;
}

.brand-mark,
.avatar,
.tool-icon,
.mini-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  background: linear-gradient(135deg, var(--teal), var(--blue) 58%, var(--violet));
  box-shadow: 0 10px 30px rgba(79, 124, 255, 0.28);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  font-weight: 900;
  letter-spacing: 0;
}

.brand-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
}

.brand-subtitle {
  color: #98a2b3;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: var(--radius);
  padding: 10px 11px;
  color: #d0d5dd;
  background: transparent;
  text-align: left;
}

.nav button:hover,
.nav button.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.nav-dot {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: #d1e7ff;
  background: rgba(255, 255, 255, 0.1);
  font-size: 11px;
  font-weight: 800;
}

.sidebar-card {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-card p {
  margin: 7px 0 12px;
  color: #cbd5e1;
  font-size: 13px;
}

.main {
  min-width: 0;
  width: 100%;
  max-width: 1580px;
  padding: clamp(20px, 2.1vw, 34px);
  padding-bottom: 96px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.topbar h1,
.page-title h1 {
  margin: 0;
  font-size: clamp(27px, 4vw, 42px);
  line-height: 1.04;
  letter-spacing: 0;
}

.topbar p,
.page-title p {
  margin: 7px 0 0;
  color: var(--muted);
}

.top-actions {
  display: flex;
  min-width: min(520px, 42vw);
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search {
  flex: 1 1 240px;
  min-width: 220px;
  width: min(360px, 36vw);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 13px;
  background: rgba(255, 255, 255, 0.78);
  outline: none;
}

.btn {
  min-height: 40px;
  max-width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: var(--radius);
  padding: 10px 13px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.primary {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--blue), var(--violet));
}

.btn.soft {
  color: #1d4ed8;
  background: #eef4ff;
  box-shadow: none;
}

.btn.danger {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #ef4444, #be123c);
}

.btn.ghost {
  box-shadow: none;
  background: transparent;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
}

.grid.three {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}

.grid.four {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}

.card,
.hero-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.card {
  padding: 18px;
}

.hero-card {
  padding: 24px;
  overflow: hidden;
  position: relative;
}

.hero-card:after {
  content: "";
  position: absolute;
  inset: auto 0 0 auto;
  width: 220px;
  height: 220px;
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.18), rgba(124, 58, 237, 0.12));
  clip-path: polygon(48% 0, 100% 28%, 82% 100%, 14% 85%, 0 24%);
  transform: translate(46px, 70px) rotate(-12deg);
}

.card h2,
.card h3,
.hero-card h2 {
  margin: 0 0 11px;
  letter-spacing: 0;
}

.hero-card h2 {
  max-width: 700px;
  font-size: clamp(25px, 3.2vw, 38px);
}

.card p,
.hero-card p,
.muted {
  color: var(--muted);
}

.dashboard-notice {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-top: 16px;
  border: 1px solid rgba(79, 124, 255, 0.22);
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.dashboard-notice h2 {
  margin: 8px 0 4px;
  font-size: 18px;
}

.dashboard-notice p {
  margin: 0;
  color: var(--muted);
}

.ai-context-card {
  margin-bottom: 16px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.stack {
  display: grid;
  gap: 12px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  color: #334155;
  background: #eef2ff;
}

.pill.good {
  color: #047857;
  background: #dffaf0;
}

.pill.warn {
  color: #92400e;
  background: #fff4d6;
}

.pill.hot {
  color: #be123c;
  background: #ffe4e6;
}

.progress {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.progress span {
  display: block;
  height: 100%;
  width: var(--value);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue), var(--violet));
}

.stat {
  padding: 16px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
}

.stat strong {
  display: block;
  font-size: 25px;
}

.profile-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  gap: 16px;
  align-items: stretch;
  width: 100%;
}

.profile-card,
.account-actions-card {
  min-width: 0;
}

.profile-card {
  display: grid;
  align-content: start;
  gap: 18px;
  padding: clamp(18px, 2.4vw, 26px);
}

.profile-identity {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
}

.profile-avatar {
  width: clamp(64px, 7vw, 86px);
  height: clamp(64px, 7vw, 86px);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 24px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--teal), var(--blue) 58%, var(--violet));
  box-shadow: 0 18px 42px rgba(79, 124, 255, 0.24);
}

.profile-heading {
  min-width: 0;
}

.profile-heading h2 {
  margin: 10px 0 8px;
  font-size: clamp(28px, 3.4vw, 42px);
  line-height: 1.04;
  overflow-wrap: anywhere;
}

.profile-heading p {
  margin: 0;
  color: var(--muted);
}

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

.account-actions-card {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: clamp(18px, 2.4vw, 26px);
}

.account-actions-card h2 {
  margin-bottom: 8px;
}

.account-actions-card p {
  margin: 0;
}

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

.account-action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  background: rgba(255, 255, 255, 0.62);
}

.account-action-row strong,
.account-action-row span {
  display: block;
}

.account-action-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.account-action-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.danger-zone {
  border-color: rgba(244, 63, 94, 0.22);
  background: rgba(255, 241, 242, 0.72);
}

body.dark-mode .account-action-row {
  background: rgba(15, 23, 42, 0.68);
}

body.dark-mode .danger-zone {
  background: rgba(127, 29, 29, 0.24);
}

.list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.list li,
.answer,
.table-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(255, 255, 255, 0.68);
}

body.dark-mode .list li,
body.dark-mode .answer,
body.dark-mode .table-row,
body.dark-mode .report-card,
body.dark-mode .dashboard-notice,
body.dark-mode .subject-card,
body.dark-mode .tool-card,
body.dark-mode .stat,
body.dark-mode .field input,
body.dark-mode .field select,
body.dark-mode .field textarea {
  color: var(--ink);
  background: rgba(15, 23, 42, 0.74);
}

body.dark-mode .btn {
  color: var(--ink);
  background: #172033;
}

body.dark-mode .btn.primary,
body.dark-mode .btn.danger {
  color: #fff;
}

.subject-card,
.tool-card {
  min-width: 0;
  min-height: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 17px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.subject-card:hover,
.tool-card:hover {
  transform: translateY(-2px);
  border-color: rgba(79, 124, 255, 0.34);
}

.subject-card h3,
.tool-card h3 {
  margin: 0 0 9px;
}

.my-subject-card {
  position: relative;
  display: grid;
  gap: 14px;
  padding-right: 54px;
}

.subject-open {
  display: grid;
  gap: 10px;
  width: 100%;
  min-width: 0;
  border: 0;
  padding: 0;
  color: inherit;
  text-align: left;
  background: transparent;
}

.subject-edit-row,
.custom-subject-row,
.selected-subjects {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.subject-menu-wrap {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
}

.subject-menu-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.78);
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.subject-menu-button:hover {
  color: var(--ink);
  border-color: rgba(79, 124, 255, 0.34);
  background: #fff;
}

.subject-menu {
  position: absolute;
  top: 40px;
  right: 0;
  display: grid;
  gap: 4px;
  width: 190px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
}

.subject-menu button {
  width: 100%;
  border: 0;
  border-radius: 7px;
  padding: 10px 11px;
  color: var(--ink);
  text-align: left;
  background: transparent;
  font-weight: 800;
}

.subject-menu button:hover {
  background: rgba(79, 124, 255, 0.1);
}

.subject-menu .danger-action {
  color: var(--rose);
}

.subject-menu .danger-action:hover {
  background: rgba(244, 63, 94, 0.1);
}

.subject-edit-row input,
.custom-subject-row input {
  flex: 1 1 220px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 13px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
}

.subject-picker {
  display: grid;
  gap: 14px;
}

.subject-picker.compact {
  margin-top: 12px;
}

.subject-chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  gap: 10px;
}

.subject-chip {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--ink);
  text-align: left;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.subject-chip.selected {
  color: #fff;
  border-color: rgba(79, 124, 255, 0.72);
  background: linear-gradient(135deg, var(--blue), #2563eb);
}

.subject-chip:disabled {
  color: var(--muted);
  background: rgba(226, 232, 240, 0.7);
}

.selected-subjects .pill button {
  border: 0;
  margin-left: 6px;
  padding: 0;
  color: inherit;
  font-weight: 900;
  background: transparent;
}

body.dark-mode .subject-chip,
body.dark-mode .subject-edit-row input,
body.dark-mode .custom-subject-row input,
body.dark-mode .subject-menu-button,
body.dark-mode .subject-menu {
  color: var(--ink);
  background: rgba(15, 23, 42, 0.74);
}

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

.mini-icon,
.tool-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
}

.tool-icon {
  width: 48px;
  height: 48px;
}

.coach {
  background:
    linear-gradient(135deg, rgba(17, 24, 39, 0.94), rgba(31, 41, 55, 0.9)),
    var(--nav-soft);
  color: #fff;
}

.coach p,
.coach .muted {
  color: #d0d5dd;
}

.coach .btn {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

.upload-zone {
  min-height: 220px;
  border: 1px dashed rgba(79, 124, 255, 0.45);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(79, 124, 255, 0.08), rgba(20, 184, 166, 0.08)),
    rgba(255, 255, 255, 0.64);
}

.upload-zone.dragging {
  border-color: var(--blue);
  background:
    linear-gradient(135deg, rgba(79, 124, 255, 0.16), rgba(20, 184, 166, 0.14)),
    rgba(255, 255, 255, 0.78);
}

.camera-hint {
  margin: 10px 0 0;
  border: 1px solid rgba(79, 124, 255, 0.22);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--muted);
  background: rgba(79, 124, 255, 0.08);
}

.camera-capture-panel {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(255, 255, 255, 0.7);
}

.camera-preview-frame {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f172a;
}

.camera-preview-frame video {
  width: 100%;
  max-height: 420px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.camera-placeholder {
  width: 100%;
  padding: 22px;
  color: #fff;
  text-align: center;
}

.camera-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  background: rgba(15, 23, 42, 0.72);
}

.camera-placeholder p {
  margin: 8px 0 0;
  color: rgba(255, 255, 255, 0.76);
}

.hidden-input {
  display: none;
}

.upload-preview {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(255, 255, 255, 0.66);
}

.upload-preview img,
.file-preview {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: calc(var(--radius) - 4px);
  border: 1px solid var(--line);
  object-fit: cover;
  background: #f8fafc;
}

.file-preview {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 12px;
  text-align: center;
}

body.dark-mode .upload-zone,
body.dark-mode .upload-preview,
body.dark-mode .camera-capture-panel,
body.dark-mode .file-preview {
  background: rgba(15, 23, 42, 0.74);
}

.answer {
  width: 100%;
  text-align: left;
  min-height: 46px;
}

.answer.selected {
  border-color: var(--blue);
  background: #eef4ff;
}

.answer.correct {
  border-color: rgba(34, 197, 94, 0.5);
  background: #dcfce7;
}

.answer.wrong {
  border-color: rgba(244, 63, 94, 0.5);
  background: #ffe4e6;
}

.answer:hover {
  border-color: rgba(79, 124, 255, 0.38);
}

.flashcard {
  min-height: clamp(250px, 34vh, 390px);
  display: grid;
  place-items: center;
  padding: 28px;
  text-align: center;
  border-radius: var(--radius);
  color: #fff;
  background: linear-gradient(135deg, #101828, #344054 58%, #293056);
  box-shadow: var(--shadow);
}

.flashcard h2 {
  max-width: 580px;
  margin: 0;
  font-size: clamp(24px, 4vw, 38px);
}

.flashcard-stage {
  margin-top: 16px;
}

.flashcard-progress {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  margin: 14px 0;
  background: #e5e7eb;
}

.flashcard-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue), var(--violet));
}

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

.deck-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(255, 255, 255, 0.66);
}

.empty-state {
  border: 1px dashed rgba(99, 102, 241, 0.28);
  border-radius: var(--radius);
  padding: 18px;
  background: rgba(248, 250, 252, 0.72);
}

.empty-state h3 {
  margin: 0 0 8px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.table > .empty-state {
  grid-column: 1 / -1;
}

.summary-output {
  margin-top: 16px;
}

.study-plan-output {
  margin-top: 10px;
}

.summary-mini {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: rgba(255, 255, 255, 0.66);
}

body.dark-mode .summary-mini {
  background: rgba(15, 23, 42, 0.74);
}

.summary-mini h3 {
  margin: 0 0 11px;
}

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

.plan-block {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(255, 255, 255, 0.62);
}

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

.exam-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  background: rgba(255, 255, 255, 0.62);
}

.exam-card h3 {
  margin: 8px 0 4px;
}

.exam-card p {
  margin: 0;
}

.exam-card p + p {
  margin-top: 8px;
}

.exam-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.exam-list.compact .exam-card {
  grid-template-columns: 1fr;
}

body.dark-mode .plan-block {
  background: rgba(15, 23, 42, 0.72);
}

body.dark-mode .exam-card {
  background: rgba(15, 23, 42, 0.72);
}

body.dark-mode .deck-list div {
  background: rgba(15, 23, 42, 0.74);
}

body.dark-mode .empty-state {
  background: rgba(15, 23, 42, 0.66);
}

body.dark-mode .admin-reply {
  background: rgba(20, 184, 166, 0.14);
}

.flashcard-error {
  border: 1px solid rgba(244, 63, 94, 0.34);
  border-radius: var(--radius);
  padding: 11px;
  color: #be123c;
  background: #fff1f2;
}

.form-success {
  border: 1px solid rgba(20, 184, 166, 0.3);
  border-radius: var(--radius);
  padding: 11px;
  color: #0f766e;
  background: rgba(20, 184, 166, 0.1);
}

.report-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.report-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(255, 255, 255, 0.68);
}

.report-card p {
  margin: 0;
}

.admin-reply {
  border-left: 3px solid var(--teal);
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(20, 184, 166, 0.08);
}

.admin-reply p {
  margin-top: 6px;
  color: var(--muted);
}

.admin-report-card textarea {
  min-height: 110px;
}

.form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: #344054;
  font-weight: 800;
  font-size: 13px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
  outline: none;
}

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

.school-year-setting {
  margin-bottom: 14px;
}

.table {
  display: grid;
  gap: 8px;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.4fr) minmax(100px, 1fr) minmax(90px, 0.9fr) minmax(90px, 0.7fr) minmax(220px, 1.2fr);
  gap: 12px;
  align-items: center;
}

.switch {
  width: 70px;
  min-width: 70px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 4px;
  background: #cbd5e1;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.switch span {
  display: block;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  transform: translateX(0);
  transition: transform 0.2s ease;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.18);
}

.switch.on {
  background: var(--blue);
  box-shadow: 0 8px 18px rgba(79, 124, 255, 0.22);
}

.switch.on span {
  transform: translateX(26px);
}

.switch:focus-visible {
  outline: 3px solid rgba(79, 124, 255, 0.28);
  outline-offset: 3px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.45);
}

.coach-backdrop {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(10px);
}

.coach-panel {
  width: min(780px, 100%);
  max-height: min(860px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  padding: 20px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(246, 248, 252, 0.94)),
    var(--panel-strong);
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.28);
}

body.dark-mode .coach-panel {
  background:
    linear-gradient(135deg, rgba(17, 24, 39, 0.96), rgba(30, 41, 59, 0.96)),
    var(--panel-strong);
}

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

.coach-panel-head h2 {
  margin: 10px 0 6px;
  font-size: clamp(25px, 4vw, 38px);
  line-height: 1.05;
}

.coach-panel-head p {
  margin: 0;
  color: var(--muted);
}

.icon-btn {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
}

.coach-context,
.quick-prompts,
.coach-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.coach-context {
  margin: 14px 0;
}

.quick-prompts {
  margin: 16px 0;
}

.quick-prompts button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 11px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  font-weight: 800;
}

body.dark-mode .quick-prompts button {
  background: rgba(15, 23, 42, 0.78);
}

.coach-input-label {
  display: block;
  margin: 8px 0 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.coach-input {
  width: 100%;
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.84);
  outline: none;
  resize: vertical;
}

body.dark-mode .coach-input {
  background: rgba(15, 23, 42, 0.82);
}

.coach-actions {
  margin: 12px 0;
}

.coach-response {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px;
  background: rgba(255, 255, 255, 0.72);
}

body.dark-mode .coach-response {
  background: rgba(15, 23, 42, 0.72);
}

.coach-response p {
  margin: 8px 0 0;
  color: var(--muted);
}

.coach-response.success {
  border-color: rgba(20, 184, 166, 0.42);
}

.coach-response.error {
  border-color: rgba(244, 63, 94, 0.48);
  background: #fff1f2;
}

body.dark-mode .coach-response.error {
  background: rgba(127, 29, 29, 0.32);
}

  .modal {
    width: min(520px, 100%);
  border-radius: var(--radius);
  padding: 20px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.28);
}

body.dark-mode .modal {
  color: var(--ink);
  background: #111827;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  border-radius: var(--radius);
  padding: 13px 15px;
  color: #fff;
  background: #111827;
  box-shadow: var(--shadow);
}

.update-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: var(--radius);
  color: #1e3a8a;
  background: #eff6ff;
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.08);
}

.update-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

body.dark-mode .update-banner {
  color: #bfdbfe;
  background: rgba(37, 99, 235, 0.14);
  border-color: rgba(147, 197, 253, 0.22);
}

.bottom-nav {
  display: none;
}

.mobile-menu {
  display: none;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 232px minmax(0, 1fr);
  }

  .sidebar {
    padding: 18px 12px;
    padding-bottom: calc(26px + env(safe-area-inset-bottom));
  }

  .nav button {
    padding: 9px;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .top-actions {
    min-width: 0;
    justify-content: flex-start;
  }

  .grid.four,
  .grid.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profile-layout {
    grid-template-columns: 1fr;
    max-width: none;
  }

  .account-action-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

@media (max-width: 820px) {
  .auth-shell {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .auth-side {
    display: none;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .main {
    padding: 16px;
    padding-bottom: 96px;
  }

  .topbar {
    gap: 14px;
  }

  .search {
    min-width: 0;
    width: 100%;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .top-actions .btn,
  .pill-row .btn {
    width: 100%;
  }

  .hero-card,
  .card {
    padding: 16px;
  }

  .grid.two,
  .grid.three,
  .grid.four {
    grid-template-columns: 1fr;
  }

  .profile-identity,
  .dashboard-notice,
  .account-action-row {
    grid-template-columns: 1fr;
  }

  .dashboard-notice {
    display: grid;
    align-items: stretch;
  }

  .profile-stats {
    grid-template-columns: 1fr;
  }

  .account-action-row .btn,
  .account-action-buttons,
  .account-action-buttons .btn {
    width: 100%;
  }

  .account-action-buttons {
    display: grid;
    justify-content: stretch;
  }

  .table-row {
    grid-template-columns: 1fr;
  }

  .exam-card {
    grid-template-columns: 1fr;
  }

  .exam-actions,
  .exam-actions .btn {
    width: 100%;
  }

  .exam-actions {
    display: grid;
    justify-content: stretch;
  }

  .plan-block {
    grid-template-columns: 1fr;
  }

  .upload-preview {
    grid-template-columns: 1fr;
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 15;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 5px;
    padding: 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    overflow: visible;
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(18px);
  }

  body.dark-mode .bottom-nav {
    background: rgba(15, 23, 42, 0.96);
  }

  .bottom-nav button {
    min-width: 0;
    min-height: 48px;
    border: 0;
    border-radius: var(--radius);
    padding: 8px 3px;
    color: var(--muted);
    background: transparent;
    font-size: 10px;
    font-weight: 800;
    line-height: 1.08;
  }

  .bottom-nav button.active {
    color: #fff;
    background: linear-gradient(135deg, var(--blue), var(--violet));
  }

  .coach-backdrop {
    align-items: end;
    padding: 10px;
    padding-bottom: calc(82px + env(safe-area-inset-bottom));
  }

  .coach-panel {
    max-height: calc(100vh - 110px - env(safe-area-inset-bottom));
    padding: 16px;
  }

  .coach-panel-head {
    align-items: flex-start;
  }

  .quick-prompts,
  .coach-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .quick-prompts button,
  .coach-actions .btn {
    width: 100%;
    min-height: 44px;
  }

  .mobile-menu {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(70px + env(safe-area-inset-bottom));
    z-index: 14;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    max-height: calc(100dvh - 98px - env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 10px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.97);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
  }

  body.dark-mode .mobile-menu {
    background: rgba(15, 23, 42, 0.97);
  }

  .mobile-menu button {
    min-width: 0;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    background: rgba(255, 255, 255, 0.72);
    font-weight: 800;
  }

  body.dark-mode .mobile-menu button {
    background: rgba(17, 24, 39, 0.86);
  }

  .mobile-menu button span {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    margin-right: 7px;
    border-radius: 7px;
    color: #fff;
    background: linear-gradient(135deg, var(--teal), var(--blue));
    font-size: 10px;
  }

  .mobile-menu button.active {
    border-color: rgba(79, 124, 255, 0.42);
    background: #eef4ff;
  }
}

@media (max-width: 430px) {
  .main {
    padding: 12px;
    padding-bottom: 96px;
  }

  .subject-chip-grid {
    grid-template-columns: 1fr;
  }

  .custom-subject-row .btn,
  .subject-edit-row .btn {
    width: 100%;
  }

  .subject-menu {
    width: min(190px, calc(100vw - 40px));
  }

  .topbar h1,
  .page-title h1 {
    font-size: 26px;
  }

  .hero-card h2 {
    font-size: 24px;
  }

  .card h2,
  .card h3,
  .hero-card h2 {
    overflow-wrap: anywhere;
  }

  .pill,
  .badge {
    max-width: 100%;
    white-space: normal;
    text-align: center;
  }

  .subject-head {
    align-items: flex-start;
  }

  .flashcard {
    min-height: 230px;
    padding: 20px;
  }

  .flashcard h2 {
    font-size: 24px;
  }

  .toast {
    left: 12px;
    right: 12px;
    bottom: calc(86px + env(safe-area-inset-bottom));
  }

  .update-banner {
    align-items: stretch;
    flex-direction: column;
  }

  .update-banner-actions {
    justify-content: flex-start;
  }
}
