:root {
  --bg: #f7f6f2;
  --surface: #fffefb;
  --text: #1f2937;
  --muted: #667085;
  --line: #e5dfd3;
  --primary: #0f766e;
  --primary-soft: #e6f5f3;
  --green: #1f8a5c;
  --green-soft: #e8f6ef;
  --red: #c1545f;
  --red-soft: #fdf0f1;
  --shadow: 0 18px 42px rgba(34, 47, 59, 0.08);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.app-shell { min-height: 100vh; }

.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 10; display: flex; width: 245px; flex-direction: column; padding: 28px 20px; border-right: 1px solid #e6e0d6; background: rgba(255, 253, 248, 0.96); }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px; color: var(--text); font-size: 20px; font-weight: 760; letter-spacing: -0.4px; text-decoration: none; }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 12px; background: linear-gradient(145deg, #0f766e, #154e6b); color: white; box-shadow: 0 10px 22px rgba(15, 118, 110, 0.24); }
.brand-mark svg { width: 23px; height: 23px; }
.side-nav { display: grid; gap: 7px; margin-top: 42px; }
.nav-item { display: flex; align-items: center; gap: 13px; padding: 12px 14px; border-radius: 12px; color: #75798f; font-size: 14px; font-weight: 650; text-decoration: none; transition: 160ms ease; }
.nav-item:hover { background: #eff7f6; color: var(--primary); transform: translateX(2px); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-item svg { width: 19px; height: 19px; }
.sidebar-tip { display: flex; gap: 10px; margin-top: auto; padding: 16px; border: 1px solid #d8ebe7; border-radius: 16px; background: linear-gradient(145deg, #f7fbfa, #f1f7f3); }
.tip-icon { color: var(--primary); font-size: 18px; }
.sidebar-tip strong { font-size: 13px; }
.sidebar-tip p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

.main-content { width: calc(100% - 245px); max-width: 1480px; margin-left: 245px; padding: 38px 48px 64px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.eyebrow { margin: 0 0 6px; color: var(--primary); font-size: 11px; font-weight: 750; letter-spacing: 1.15px; text-transform: uppercase; }
.topbar h1 { margin: 0; font-size: clamp(24px, 3vw, 34px); line-height: 1.18; letter-spacing: -1.1px; }
.profile-chip { display: flex; align-items: center; gap: 11px; padding: 8px 13px 8px 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.avatar { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 11px; background: #243447; color: white; font-size: 13px; font-weight: 750; }
.profile-copy { display: grid; gap: 2px; }
.profile-copy strong { font-size: 12px; }
.profile-copy small { color: var(--muted); font-size: 10px; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(290px, 0.75fr); gap: 22px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.composer-panel { padding: 30px; }
.panel-heading { display: flex; gap: 14px; margin-bottom: 27px; }
.heading-icon { display: grid; flex: 0 0 44px; width: 44px; height: 44px; place-items: center; border-radius: 13px; }
.heading-icon.purple { background: var(--primary-soft); color: var(--primary); }
.heading-icon.green { background: var(--green-soft); color: var(--green); }
.heading-icon svg { width: 23px; height: 23px; }
.panel h2 { margin: 0; font-size: 20px; letter-spacing: -0.35px; }
.panel-description { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

.form-group { display: grid; gap: 9px; margin-top: 20px; }
.form-group label { color: #3d4158; font-size: 12px; font-weight: 700; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.field-hint { color: #a0a3b3; font-size: 10px; }
input, textarea, select { width: 100%; border: 1px solid #ddd6c8; outline: 0; background: #fffefc; color: var(--text); transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease; }
input { height: 48px; padding: 0 15px; border-radius: 12px; }
select { height: 48px; padding: 0 40px 0 15px; border-radius: 12px; cursor: pointer; }
textarea { min-height: 220px; padding: 15px; border-radius: 14px; line-height: 1.6; resize: vertical; }
input::placeholder, textarea::placeholder { color: #a7a9b8; }
input:hover, textarea:hover, select:hover { border-color: #c7c0b4; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); background: #ffffff; box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12); }
.primary-button { display: flex; width: 100%; min-height: 50px; align-items: center; justify-content: center; gap: 10px; margin-top: 22px; padding: 12px 18px; border: 0; border-radius: 13px; background: linear-gradient(135deg, #0f766e, #195a77); color: white; box-shadow: 0 12px 24px rgba(15, 118, 110, 0.22); cursor: pointer; font-size: 13px; font-weight: 720; transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease; }
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 16px 30px rgba(15, 118, 110, 0.3); filter: saturate(1.06); }
.primary-button:active { transform: translateY(0); }
.primary-button:disabled { cursor: wait; opacity: 0.7; transform: none; }
.primary-button svg { width: 18px; height: 18px; }
.button-arrow { margin-left: auto; }

.library-panel { overflow: hidden; }
.library-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 25px 24px 19px; border-bottom: 1px solid var(--line); }
.live-badge { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 20px; background: var(--green-soft); color: #267e61; font-size: 9px; font-weight: 750; text-transform: uppercase; }
.live-badge span { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.study-sets-list { display: grid; gap: 10px; max-height: 560px; padding: 14px; overflow-y: auto; }
.study-set-card { position: relative; padding: 15px 42px 15px 15px; border: 1px solid transparent; border-radius: 13px; background: #fbfbf8; cursor: pointer; transition: 160ms ease; }
.study-set-card::after { content: "›"; position: absolute; top: 50%; right: 16px; color: #b0b2c0; font-size: 22px; transform: translateY(-52%); transition: 160ms ease; }
.study-set-card:hover { border-color: #d8e8e4; background: #f4f9f7; transform: translateY(-1px); }
.study-set-card:hover::after { right: 13px; color: var(--primary); }
.study-set-card h3 { margin: 0 0 7px; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.study-set-card p { margin: 0; color: var(--muted); font-size: 10px; }
.empty-state { padding: 38px 20px; color: var(--muted); text-align: center; }
.empty-state-icon { display: grid; width: 44px; height: 44px; margin: 0 auto 12px; place-items: center; border-radius: 14px; background: var(--primary-soft); color: var(--primary); font-size: 18px; }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--text); font-size: 13px; }
.empty-state p { margin: 0; font-size: 11px; line-height: 1.5; }
.skeleton-card { display: grid; gap: 10px; padding: 17px 15px; border-radius: 13px; background: #fbfbf8; }
.skeleton-card span { height: 9px; border-radius: 8px; background: linear-gradient(90deg, #ece8e0 25%, #f7f3eb 50%, #ece8e0 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.skeleton-card span:last-child { width: 48%; height: 7px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.quiz-output { margin-top: 22px; }
.quiz-output:empty { display: none; }
.quiz-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.quiz-header h2 { margin: 0; font-size: 22px; }
.quiz-count { padding: 7px 10px; border-radius: 20px; background: var(--primary-soft); color: var(--primary); font-size: 10px; font-weight: 750; }
.question-list { display: grid; gap: 14px; }
.question-card { padding: 24px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); box-shadow: 0 8px 28px rgba(32, 35, 68, 0.045); }
.question-number { margin: 0 0 8px; color: var(--primary); font-size: 10px; font-weight: 760; letter-spacing: 1px; text-transform: uppercase; }
.question-text { margin: 0 0 18px; font-size: 15px; font-weight: 650; line-height: 1.55; }
.choices { display: grid; gap: 9px; }
.choice-option { display: flex; align-items: center; gap: 11px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 11px; background: #fdfcf8; cursor: pointer; font-size: 12px; line-height: 1.4; transition: 150ms ease; }
.choice-option:hover { border-color: #cadfdc; background: #f5faf9; }
.choice-option:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: #105f59; box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.08); }
.choice-option input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }
.submit-button { width: auto; min-width: 170px; margin: 18px 0 0 auto; }
.loading-state { display: flex; align-items: center; gap: 12px; padding: 20px; border: 1px solid #d9ebe7; border-radius: 15px; background: var(--primary-soft); color: #10625b; font-size: 13px; font-weight: 650; }
.spinner { width: 19px; height: 19px; border: 2px solid rgba(15, 118, 110, 0.2); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-message { padding: 13px 15px; border: 1px solid #ffd7da; border-radius: 12px; background: var(--red-soft); color: #b53f4a; font-size: 12px; }
.score-card { padding: 25px; border: 1px solid #d8f0e7; border-radius: 17px; background: linear-gradient(145deg, #f4fcf8, #ebf9f3); text-align: center; }
.score-card p { margin: 0 0 6px; color: var(--green); font-size: 10px; font-weight: 760; letter-spacing: 1px; text-transform: uppercase; }
.score-card h2 { margin: 0; font-size: 28px; }
.result-list { display: grid; gap: 12px; margin-top: 14px; }
.result-card { padding: 20px; border: 1px solid var(--line); border-left: 4px solid var(--red); border-radius: 14px; background: var(--surface); }
.result-card.correct { border-left-color: var(--green); }
.result-card h4 { margin: 0 0 12px; font-size: 13px; }
.result-card p { margin: 6px 0; color: #5e6278; font-size: 11px; line-height: 1.5; }
.result-status { display: inline-flex; margin-top: 7px; padding: 5px 8px; border-radius: 8px; background: var(--red-soft); color: var(--red); font-weight: 750; }
.correct .result-status { background: var(--green-soft); color: var(--green); }

@media (max-width: 980px) {
  .sidebar { width: 82px; padding: 26px 14px; }
  .brand { justify-content: center; padding: 0; }
  .brand > span:last-child { display: none; }
  .nav-item { justify-content: center; padding: 13px; font-size: 0; }
  .nav-item svg { width: 21px; height: 21px; }
  .sidebar-tip { display: none; }
  .main-content { width: calc(100% - 82px); margin-left: 82px; padding: 32px 28px 56px; }
}

@media (max-width: 760px) {
  .sidebar { position: static; width: 100%; height: 70px; flex-direction: row; align-items: center; justify-content: space-between; padding: 10px 18px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand > span:last-child { display: inline; }
  .side-nav { display: flex; margin: 0; }
  .nav-item { padding: 10px; }
  .main-content { width: 100%; margin: 0; padding: 25px 18px 48px; }
  .workspace-grid { grid-template-columns: 1fr; }
  .library-panel { order: -1; }
  .study-sets-list { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 230px; }
  .topbar { align-items: flex-start; }
  .profile-copy { display: none; }
  .profile-chip { padding: 5px; border: 0; background: transparent; }
  .logout-button { display: inline-flex; }
}

@media (max-width: 520px) {
  .topbar h1 { font-size: 24px; }
  .composer-panel { padding: 22px 18px; }
  .study-sets-list { grid-template-columns: 1fr; }
  .field-hint { display: none; }
  .question-card { padding: 19px 16px; }
  .submit-button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Authentication */
.auth-body { min-height: 100vh; overflow-x: hidden; }
.auth-page { position: relative; display: grid; min-height: 100vh; place-items: center; padding: 32px 20px; overflow: hidden; background: radial-gradient(circle at 50% 0%, #fffaf1 0, var(--bg) 45%); }
.auth-glow { position: absolute; border-radius: 50%; filter: blur(2px); pointer-events: none; }
.auth-glow-one { top: -170px; right: -120px; width: 430px; height: 430px; background: rgba(15, 118, 110, 0.1); }
.auth-glow-two { bottom: -210px; left: -160px; width: 480px; height: 480px; background: rgba(217, 165, 84, 0.11); }
.auth-card { position: relative; z-index: 1; width: min(100%, 440px); padding: 34px; border: 1px solid rgba(226, 220, 208, 0.95); border-radius: 24px; background: rgba(255, 252, 246, 0.96); box-shadow: 0 24px 70px rgba(35, 35, 70, 0.11); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 34px; font-size: 18px; font-weight: 760; letter-spacing: -0.35px; }
.auth-brand .brand-mark { width: 36px; height: 36px; }
.auth-brand .brand-mark svg { width: 21px; height: 21px; }
.auth-heading { margin-bottom: 27px; }
.auth-heading h1 { margin: 0; font-size: 27px; line-height: 1.2; letter-spacing: -0.8px; }
.auth-heading > p:last-child { min-height: 21px; margin: 9px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.auth-form > .form-group:first-child { margin-top: 0; }
.auth-label-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.auth-text-button { padding: 0; border: 0; background: transparent; color: var(--primary); cursor: pointer; font-size: 11px; font-weight: 720; }
.auth-text-button:hover { color: #125f59; text-decoration: underline; text-underline-offset: 3px; }
.auth-text-button:disabled { cursor: wait; opacity: 0.65; }
.auth-text-link { color: var(--primary); font-weight: 720; text-decoration: none; }
.auth-text-link:hover { color: #125f59; text-decoration: underline; text-underline-offset: 3px; }
.auth-message.is-success { color: var(--green); }
.auth-message.is-info { color: var(--muted); }
.auth-signup-fields { display: grid; max-height: 0; overflow: hidden; opacity: 0; transform: translateY(-8px); transition: max-height 320ms ease, opacity 220ms ease, transform 320ms ease; }
.auth-card.is-signup .auth-signup-fields { max-height: 105px; opacity: 1; transform: translateY(0); }
.auth-actions { display: grid; margin-top: 22px; }
.auth-submit { grid-area: 1 / 1; margin: 0; opacity: 0; pointer-events: none; transform: translateY(7px); transition: opacity 180ms ease, transform 220ms ease, box-shadow 160ms ease; }
.auth-submit.is-active { opacity: 1; pointer-events: auto; transform: translateY(0); }
.auth-submit:hover { transform: translateY(-2px); }
.auth-message { min-height: 18px; margin: 14px 0 0; color: var(--red); font-size: 12px; line-height: 1.5; text-align: center; }
.auth-message:empty { margin-top: 6px; }
.auth-switch { display: flex; align-items: center; justify-content: center; gap: 5px; margin-top: 17px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.auth-switch button { padding: 3px 2px; border: 0; background: transparent; color: var(--primary); cursor: pointer; font-weight: 720; }
.auth-switch button:hover { color: #125f59; text-decoration: underline; text-underline-offset: 3px; }
.auth-switch button:focus-visible { border-radius: 4px; outline: 3px solid rgba(15, 118, 110, 0.18); }

@media (max-width: 480px) {
  .auth-page { align-items: start; padding-top: 22px; }
  .auth-card { padding: 27px 22px; border-radius: 20px; }
  .auth-brand { margin-bottom: 28px; }
  .auth-heading h1 { font-size: 24px; }
  .auth-switch { flex-direction: column; gap: 2px; }
}

/* App views and study-set library */
[hidden] { display: none !important; }
.app-view { animation: view-in 240ms ease both; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.workspace-focus { width: min(100%, 900px); margin: 0 auto; }
.workspace-focus .quiz-output { scroll-margin-top: 28px; }
.workspace-dashboard { display: grid; width: min(100%, 1180px); gap: 24px; margin: 0 auto; }
.workspace-hero { position: relative; display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(250px, .55fr); gap: 34px; align-items: center; overflow: hidden; padding: clamp(28px, 5vw, 52px); border: 1px solid #dbe8e4; border-radius: 26px; background: radial-gradient(circle at 95% 5%, rgba(15,118,110,.12), transparent 34%), linear-gradient(135deg, #ffffff 0%, #f7fbfa 72%); box-shadow: 0 20px 54px rgba(34,47,59,.08); }
.workspace-hero::after { content: ""; position: absolute; right: -80px; bottom: -110px; width: 260px; height: 260px; border: 46px solid rgba(15,118,110,.06); border-radius: 50%; pointer-events: none; }
.workspace-hero-copy { position: relative; z-index: 1; }
.workspace-hero h2 { max-width: 650px; margin: 0; font-size: clamp(27px, 4vw, 42px); line-height: 1.13; letter-spacing: -1.3px; }
.workspace-hero-copy > p:last-of-type { max-width: 650px; margin: 15px 0 0; color: #5f6874; font-size: 14px; line-height: 1.7; }
.workspace-hero-actions { display: flex; flex-wrap: wrap; gap: 11px; margin-top: 25px; }
.workspace-hero-actions .primary-button { width: auto; min-width: 170px; margin: 0; }
.dashboard-secondary-button { min-height: 50px; padding: 12px 18px; border: 1px solid #cfe0dc; border-radius: 13px; background: rgba(255,255,255,.9); color: var(--primary); cursor: pointer; font-size: 12px; font-weight: 720; }
.dashboard-secondary-button:hover { background: #fffefb; box-shadow: 0 8px 22px rgba(34,47,59,.08); }
.workspace-stats { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.workspace-stats > div { display: grid; min-height: 112px; place-content: center; border: 1px solid rgba(214,226,222,.9); border-radius: 18px; background: rgba(255,252,246,.8); box-shadow: 0 12px 30px rgba(34,47,59,.06); text-align: center; backdrop-filter: blur(8px); }
.workspace-stats strong { color: var(--primary); font-size: 30px; letter-spacing: -1px; }
.workspace-stats span { margin-top: 4px; color: var(--muted); font-size: 10px; font-weight: 720; text-transform: uppercase; letter-spacing: .8px; }
.dashboard-section { padding: 25px; border: 1px solid var(--line); border-radius: 21px; background: var(--surface); box-shadow: var(--shadow); }
.dashboard-section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.dashboard-section-heading h3 { margin: 0; font-size: 19px; letter-spacing: -.35px; }
.text-button { padding: 6px 0; border: 0; background: transparent; color: var(--primary); cursor: pointer; font-size: 11px; font-weight: 730; }
.text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.dashboard-action-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.dashboard-action-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 13px; align-items: center; min-height: 120px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: #fdfcf8; color: var(--text); cursor: pointer; text-align: left; transition: border-color 170ms ease, box-shadow 170ms ease, transform 170ms ease; }
.dashboard-action-card:hover { border-color: #cfe0dc; box-shadow: 0 12px 30px rgba(34,47,59,.09); transform: translateY(-2px); }
.dashboard-action-card > span:nth-child(2) { display: grid; gap: 6px; }
.dashboard-action-card strong { font-size: 13px; }
.dashboard-action-card small { color: var(--muted); font-size: 10px; line-height: 1.5; }
.dashboard-action-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 13px; }
.dashboard-action-icon svg { width: 21px; height: 21px; }
.dashboard-action-icon.purple { background: var(--primary-soft); color: var(--primary); }
.dashboard-action-icon.green { background: var(--green-soft); color: var(--green); }
.dashboard-action-icon.amber { background: #fff5df; color: #b87912; }
.dashboard-action-arrow { color: #a2a4b4; font-size: 18px; transition: transform 170ms ease; }
.dashboard-action-card:hover .dashboard-action-arrow, .dashboard-recent-card:hover .dashboard-action-arrow { color: var(--primary); transform: translateX(3px); }
.dashboard-recent-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.dashboard-recent-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 13px; align-items: center; min-height: 92px; padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: #fbfbf8; color: var(--text); cursor: pointer; text-align: left; transition: 170ms ease; }
.dashboard-recent-card:hover { border-color: #cfe0dc; background: #f4f9f7; transform: translateY(-2px); }
.dashboard-recent-card > span:nth-child(2) { display: grid; min-width: 0; gap: 6px; }
.dashboard-recent-card strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-recent-card small { overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-recent-card .study-set-tile-icon { width: 38px; height: 38px; }
.dashboard-empty-state { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 20px; border: 1px dashed #dcd9ef; border-radius: 15px; background: #fcfcfa; }
.dashboard-empty-state .empty-state-icon { flex: 0 0 auto; margin: 0; }
.dashboard-empty-state > div { min-width: 0; flex: 1; }
.dashboard-empty-state strong { font-size: 12px; }
.dashboard-empty-state p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.dashboard-empty-state .secondary-button { flex: 0 0 auto; margin: 0; }
.pdf-import-group > div:first-child { display: grid; gap: 5px; }
.pdf-import-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.create-study-set-status:not(:empty) { margin-top: 17px; }
.composer-actions { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 11px; margin-top: 22px; }
.composer-actions .primary-button { margin-top: 0; }
.clear-button { display: inline-flex; min-height: 50px; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border: 1px solid #dedfe9; border-radius: 13px; background: #fffefb; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 720; transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease; }
.clear-button svg { width: 17px; height: 17px; }
.clear-button:hover { border-color: #cfcafc; background: var(--primary-soft); color: var(--primary); transform: translateY(-1px); }
.clear-button:active { transform: translateY(0); }
.logout-button { padding: 7px 10px; border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; font-size: 10px; font-weight: 700; transition: color 150ms ease; }
.logout-button:hover { color: var(--red); }

.view-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 23px; }
.view-heading h2 { margin: 0; font-size: 25px; letter-spacing: -0.6px; }
.view-heading > div > p:last-child { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.collection-count { flex: 0 0 auto; padding: 7px 11px; border: 1px solid #dfdcff; border-radius: 20px; background: var(--primary-soft); color: var(--primary); font-size: 10px; font-weight: 750; }
.study-sets-page-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.study-sets-page-grid .skeleton-card { min-height: 172px; align-content: end; padding: 22px; border: 1px solid var(--line); background: var(--surface); }
.study-set-tile { display: flex; min-height: 180px; flex-direction: column; align-items: flex-start; padding: 22px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 8px 28px rgba(32, 35, 68, 0.045); color: var(--text); cursor: pointer; text-align: left; transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease; }
.study-set-tile:hover { border-color: #d3ceff; box-shadow: 0 16px 36px rgba(70, 59, 158, 0.11); transform: translateY(-3px); }
.study-set-tile:focus-visible { outline: 4px solid rgba(15, 118, 110, 0.14); border-color: var(--primary); }
.study-set-tile-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 12px; background: var(--primary-soft); color: var(--primary); }
.study-set-tile-icon svg { width: 21px; height: 21px; }
.study-set-tile-copy { display: grid; gap: 7px; width: 100%; margin-top: 18px; }
.study-set-tile-copy strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.study-set-tile-copy small { color: var(--muted); font-size: 10px; }
.study-set-open { display: flex; width: 100%; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 17px; color: var(--primary); font-size: 11px; font-weight: 720; }
.study-set-open span { font-size: 17px; transition: transform 160ms ease; }
.study-set-tile:hover .study-set-open span { transform: translateX(3px); }
.library-empty-state { grid-column: 1 / -1; padding: 60px 20px; border: 1px dashed #dcd9ef; border-radius: 18px; background: rgba(255,253,248,0.72); }
.secondary-button { margin-top: 17px; padding: 9px 13px; border: 1px solid #d7d2ff; border-radius: 10px; background: #fffefb; color: var(--primary); cursor: pointer; font-size: 11px; font-weight: 720; }
.secondary-button:hover { background: var(--primary-soft); }

.back-button { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 18px; padding: 8px 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; font-weight: 700; }
.back-button:hover { color: var(--primary); }
.back-button svg { width: 17px; height: 17px; }
.study-set-detail-panel { padding: 28px; }
.detail-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.detail-heading-main { display: flex; min-width: 0; align-items: center; gap: 14px; }
.detail-heading h2 { margin: 0; font-size: 23px; letter-spacing: -0.5px; }
.saved-notes { margin-top: 24px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: #fbfbf8; }
.saved-notes-label { margin: 0 0 9px; color: var(--primary); font-size: 10px; font-weight: 760; letter-spacing: 0.9px; text-transform: uppercase; }
.saved-notes > p:last-child { max-height: 160px; margin: 0; overflow-y: auto; color: #5e6278; font-size: 12px; line-height: 1.7; white-space: pre-wrap; }
.study-set-edit-form { background: #fffefb; }
.study-set-edit-form .form-group:first-child { margin-top: 0; }
.study-set-edit-form textarea { min-height: 240px; }
.edit-form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 17px; }
.edit-form-actions .primary-button, .edit-form-actions .clear-button { width: auto; min-height: 44px; margin: 0; }
.study-set-detail-layout { display: grid; gap: 18px; }
.note-set-detail-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(290px, 0.85fr); gap: 18px; }
.detail-mobile-tabs { display: none; }
.detail-quiz-output { margin-top: 28px; }
.quiz-result:not(:empty) { margin-top: 18px; }
.note-comments-panel { display: grid; }
.note-comments-list { display: grid; gap: 10px; }
.note-comment-card { padding: 14px 15px; border: 1px solid var(--line); border-radius: 14px; background: #fbfbf8; }
.note-comment-label { margin: 0 0 7px; color: var(--primary); font-size: 10px; font-weight: 760; letter-spacing: 0.9px; text-transform: uppercase; }
.note-comment-card p:last-child { margin: 0; color: #5e6278; font-size: 12px; line-height: 1.6; white-space: pre-wrap; }

@media (max-width: 1100px) {
  .study-sets-page-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-action-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .view-heading { align-items: flex-start; flex-direction: column; gap: 13px; }
  .study-sets-page-grid { grid-template-columns: 1fr; }
  .study-set-tile { min-height: 165px; }
  .study-set-detail-panel { padding: 22px 18px; }
  .detail-heading { align-items: flex-start; }
  .note-compose-grid { grid-template-columns: 1fr; }
  .note-set-detail-layout { grid-template-columns: 1fr; }
  .detail-mobile-tabs {
    position: sticky;
    top: 0;
    z-index: 4;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 253, 248, 0.92);
    box-shadow: 0 10px 24px rgba(32, 35, 68, 0.05);
    backdrop-filter: blur(10px);
  }
  .detail-mobile-tab {
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fafafe;
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
    font-weight: 720;
  }
  .detail-mobile-tab.active {
    border-color: #d8d2ff;
    background: var(--primary-soft);
    color: var(--primary);
  }
  #studySetDetailView[data-mobile-mode="notes"] .quiz-library-panel,
  #studySetDetailView[data-mobile-mode="notes"] #detailQuizOutput,
  #studySetDetailView[data-mobile-mode="notes"] #detailFlashcardOutput {
    display: none;
  }
  #studySetDetailView[data-mobile-mode="practice"] #studySetNotesView,
  #studySetDetailView[data-mobile-mode="practice"] #studySetEditForm,
  #studySetDetailView[data-mobile-mode="practice"] #editStudySetBtn {
    display: none;
  }
  #noteSetDetailView[data-mobile-mode="notes"] #noteSetCommentsPane,
  #noteSetDetailView[data-mobile-mode="comments"] #noteSetNotesPane,
  #noteSetDetailView[data-mobile-mode="comments"] #noteSetFreeTextView,
  #noteSetDetailView[data-mobile-mode="comments"] #noteSetEditForm,
  #noteSetDetailView[data-mobile-mode="comments"] #editNoteSetBtn {
    display: none;
  }
  #noteSetDetailView[data-mobile-mode="notes"] #noteSetCommentsPane {
    display: none;
  }
  .workspace-hero { grid-template-columns: 1fr; }
  .workspace-stats { max-width: 340px; }
  .dashboard-recent-grid { grid-template-columns: 1fr; }
  .logout-button { display: inline-flex; }
}

@media (max-width: 430px) {
  .composer-actions { grid-template-columns: 1fr; }
  .workspace-hero { padding: 25px 20px; }
  .workspace-hero-actions { align-items: stretch; flex-direction: column; }
  .workspace-hero-actions .primary-button { width: 100%; }
  .workspace-stats { grid-template-columns: 1fr 1fr; }
  .workspace-stats > div:last-child { grid-column: 1 / -1; }
  .workspace-stats > div { min-height: 88px; }
  .dashboard-section { padding: 20px 16px; }
  .dashboard-empty-state { align-items: flex-start; flex-direction: column; }
  .pdf-import-row { grid-template-columns: 1fr; }
  .detail-heading { flex-direction: column; }
  .edit-form-actions { align-items: stretch; flex-direction: column-reverse; }
  .edit-form-actions .primary-button, .edit-form-actions .clear-button { width: 100%; }
}

.chat-messages {
  display: grid;
  gap: 12px;
  max-height: 520px;
  min-height: 280px;
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fafafe;
}

.chat-message {
  max-width: 78%;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.user-message {
  justify-self: end;
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.ai-message {
  justify-self: start;
  background: #fffefb;
  border: 1px solid var(--line);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-input-row {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 12px;
  margin-top: 16px;
}

.chat-input-row textarea {
  min-height: 70px;
}

.chat-input-row .primary-button {
  margin-top: 0;
}

@media (max-width: 620px) {
  .chat-input-row {
    grid-template-columns: 1fr;
  }

  .chat-mobile-tabs {
    margin-top: 0;
  }

  .chat-message {
    max-width: 92%;
  }
}

.ai-message p {
  margin: 0 0 8px;
}

.ai-message p:last-child {
  margin-bottom: 0;
}

.ai-message ul,
.ai-message ol {
  margin: 8px 0;
  padding-left: 20px;
}

.ai-message strong {
  font-weight: 750;
}

.ai-message h1,
.ai-message h2,
.ai-message h3 {
  margin: 10px 0 6px;
  font-size: 15px;
}

.chat-view {
  display: grid;
  grid-template-columns: minmax(240px, 0.35fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.chat-mobile-tabs {
  display: none;
}

.chat-history-panel {
  overflow: hidden;
}

.chat-history-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.chat-history-heading h2 {
  margin: 0;
  font-size: 18px;
}

.chat-threads-list {
  display: grid;
  gap: 10px;
  max-height: 620px;
  overflow-y: auto;
  padding: 14px;
}

.chat-thread-card {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 14px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: #fafafe;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: 160ms ease;
}

.chat-thread-card:hover,
.chat-thread-card.active {
  border-color: #dedaff;
  background: var(--primary-soft);
}

.chat-thread-card strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-thread-card small {
  color: var(--muted);
  font-size: 10px;
}

.chat-panel {
  min-height: 650px;
}

@media (max-width: 800px) {
  .chat-view {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .chat-mobile-tabs {
    position: sticky;
    top: 0;
    z-index: 4;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 10px;
    margin: -10px -2px 0;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 253, 248, 0.92);
    box-shadow: 0 10px 24px rgba(32, 35, 68, 0.05);
    backdrop-filter: blur(10px);
  }

  .chat-mobile-tab {
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fafafe;
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
    font-weight: 720;
  }

  .chat-mobile-tab.active {
    border-color: #d8d2ff;
    background: var(--primary-soft);
    color: var(--primary);
  }

  .chat-view[data-mobile-mode="threads"] .chat-panel {
    display: none;
  }

  .chat-view[data-mobile-mode="conversation"] .chat-history-panel {
    display: none;
  }

  .chat-history-panel,
  .chat-panel {
    min-height: 0;
  }

  .chat-threads-list {
    max-height: none;
  }

  .chat-panel {
    min-height: calc(100dvh - 215px);
  }
}

.quiz-library-panel {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.quiz-library-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

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

.quiz-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quiz-open-button {
  flex: 1;
  display: grid;
  gap: 5px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafafe;
  text-align: left;
  cursor: pointer;
}

.quiz-open-button:hover {
  border-color: #dedaff;
  background: var(--primary-soft);
}

.quiz-open-button strong {
  font-size: 13px;
}

.quiz-open-button small {
  color: var(--muted);
  font-size: 10px;
}

.delete-quiz-button {
  padding: 10px 12px;
  border: 1px solid #ffd7da;
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.flashcard-output { margin-top: 22px; scroll-margin-top: 28px; }
.flashcard-output:empty { display: none; }
.flashcard-viewer { padding: 26px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.flashcard-progress { height: 6px; overflow: hidden; border-radius: 20px; background: #ececf4; }
.flashcard-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #0f766e, #d9a554); transition: width 220ms ease; }
.flashcard-position { margin: 12px 0; color: var(--muted); font-size: 10px; font-weight: 720; text-align: center; }
.flashcard-card { position: relative; display: block; width: 100%; min-height: 300px; padding: 0; border: 0; border-radius: 20px; background: transparent; cursor: pointer; perspective: 1200px; }
.flashcard-card:focus-visible { outline: 4px solid rgba(15, 118, 110, 0.16); outline-offset: 4px; }
.flashcard-face { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 18px; padding: 38px; border: 1px solid #d9e7e2; border-radius: 20px; background: linear-gradient(145deg, #fffdf8, #f4faf8); box-shadow: 0 18px 42px rgba(34, 47, 59, 0.1); backface-visibility: hidden; transform-style: preserve-3d; transition: transform 420ms cubic-bezier(.2,.7,.2,1); }
.flashcard-face small { color: var(--primary); font-size: 10px; font-weight: 780; letter-spacing: 1px; text-transform: uppercase; }
.flashcard-face strong { max-width: 720px; font-size: clamp(18px, 3vw, 26px); font-weight: 680; line-height: 1.5; text-align: center; white-space: pre-wrap; }
.flashcard-back { border-color: #cfece2; background: linear-gradient(145deg, #ffffff, #f0fbf7); transform: rotateY(180deg); }
.flashcard-back small { color: var(--green); }
.flashcard-card.is-flipped .flashcard-front { transform: rotateY(-180deg); }
.flashcard-card.is-flipped .flashcard-back { transform: rotateY(0); }
.flashcard-hint { margin: 13px 0 0; color: var(--muted); font-size: 10px; text-align: center; }
.flashcard-controls { display: grid; grid-template-columns: 1fr minmax(140px, .75fr) 1fr; gap: 10px; margin-top: 18px; }
.flashcard-controls .primary-button, .flashcard-controls .clear-button { width: 100%; min-height: 44px; margin: 0; }
.flashcard-controls button:disabled { cursor: not-allowed; opacity: .45; transform: none; }

@media (max-width: 620px) {
  .flashcard-viewer { padding: 20px 16px; }
  .flashcard-card { min-height: 260px; }
  .flashcard-face { padding: 26px 20px; }
  .flashcard-controls { grid-template-columns: 1fr 1fr; }
  .flashcard-flip { grid-column: 1 / -1; grid-row: 1; }
}

.chat-thread-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: stretch;
}
.chat-thread-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: stretch;
}

.chat-thread-menu-wrap {
  position: relative;
}

.chat-thread-menu-btn {
  width: 36px;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafafe;
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
  font-weight: 700;
}

.chat-thread-menu-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.chat-thread-menu {
  position: absolute;
  top: 0;
  right: calc(100% + 6px);
  z-index: 999;
  min-width: 135px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chat-thread-delete-option {
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--red);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
}

.chat-thread-delete-option:hover {
  background: var(--red-soft);
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 22, 40, 0.42);
}

.modal-card {
  width: min(100%, 390px);
  padding: 24px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(20, 22, 40, 0.24);
}

.modal-card h2 {
  margin: 0;
  font-size: 20px;
}

.modal-card p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.danger-button {
  padding: 9px 13px;
  border: 0;
  border-radius: 10px;
  background: var(--red);
  color: white;
  cursor: pointer;
  font-size: 12px;
  font-weight: 720;
}

.study-set-row {
  position: relative;
  min-height: 180px;
}

.study-set-row .study-set-tile {
  width: 100%;
  height: 100%;
  min-height: 180px;
  padding-right: 54px;
}

.study-set-menu-wrap {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 5;
}

.study-set-menu-btn {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 253, 248, 0.92);
  color: var(--text);
  cursor: pointer;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

.study-set-menu-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.study-set-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  min-width: 160px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.study-set-delete-option {
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--red);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
}

.study-set-delete-option:hover {
  background: var(--red-soft);
}
.study-set-move-option {
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
}
.study-set-move-option:hover { background: var(--primary-soft); color: var(--primary); }
.study-set-move-option + .study-set-delete-option { margin-top: 3px; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; }

/* Course hierarchy */
.course-select-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.inline-secondary-button { min-height: 48px; padding: 0 16px; border: 1px solid #d7d2ff; border-radius: 12px; background: #fffefb; color: var(--primary); cursor: pointer; font-size: 11px; font-weight: 720; white-space: nowrap; }
.inline-secondary-button:hover { background: var(--primary-soft); }
.form-help { color: var(--muted); font-size: 10px; line-height: 1.4; }
.library-heading-actions { display: flex; align-items: center; gap: 10px; }
.compact-button { margin: 0; white-space: nowrap; }
.course-library { display: grid; gap: 22px; }
.note-compose-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 20px; }
.note-compose-panel { padding: 18px; border: 1px solid #e2ddd2; border-radius: 16px; background: #fbfbf8; }
.note-compose-panel textarea { min-height: 250px; }
.course-section { padding: 24px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.course-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.course-identity { display: flex; min-width: 0; align-items: center; gap: 13px; }
.course-icon { display: grid; flex: 0 0 44px; width: 44px; height: 44px; place-items: center; border-radius: 13px; background: linear-gradient(145deg, #0f766e, #154e6b); color: white; }
.course-icon svg { width: 23px; height: 23px; }
.standalone-icon { background: var(--primary-soft); color: var(--primary); }
.note-course-icon { background: var(--green-soft); color: var(--green); }
.note-set-icon { background: var(--green-soft); color: var(--green); }
.course-identity h3 { margin: 0; overflow: hidden; font-size: 18px; letter-spacing: -0.35px; text-overflow: ellipsis; white-space: nowrap; }
.course-identity p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.course-heading-meta { display: flex; flex: 0 0 auto; align-items: center; gap: 12px; color: var(--muted); font-size: 10px; font-weight: 700; }
.course-add-set, .course-add-note { padding: 8px 11px; border: 1px solid #d7d2ff; border-radius: 9px; background: #fffefb; color: var(--primary); cursor: pointer; font-size: 10px; font-weight: 720; }
.course-add-set:hover, .course-add-note:hover { background: var(--primary-soft); }
.course-menu-wrap { position: relative; }
.course-menu-btn { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: rgba(255, 253, 248, 0.92); color: var(--text); cursor: pointer; font-size: 18px; font-weight: 800; line-height: 1; }
.course-menu-btn:hover { background: var(--primary-soft); color: var(--primary); }
.course-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 50; min-width: 160px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.course-delete-option { width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--red); cursor: pointer; font-size: 12px; font-weight: 700; text-align: left; }
.course-delete-option:hover { background: var(--red-soft); }
.course-set-count { flex: 0 0 auto; color: var(--muted); font-size: 10px; font-weight: 700; }
.course-empty-state { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px; border: 1px dashed #dbd8ec; border-radius: 14px; background: #fafafe; }
.course-empty-state p { margin: 0; color: var(--muted); font-size: 12px; }
.empty-library-actions { display: flex; justify-content: center; gap: 9px; }
.detail-course-name { display: inline-flex; margin: 7px 0 0; padding: 5px 9px; border-radius: 20px; background: var(--primary-soft); color: var(--primary); font-size: 10px; font-weight: 720; }
.course-description-input { min-height: 90px; }
.optional-label { color: var(--muted); font-size: 10px; font-weight: 500; }
.modal-primary-button { width: auto; min-height: 38px; margin: 0; padding: 9px 14px; border-radius: 10px; }
#courseFormError { margin: 14px 0 0; }

@media (max-width: 680px) {
  .library-heading-actions { width: 100%; justify-content: space-between; }
  .course-section { padding: 18px; }
  .course-section-heading { align-items: flex-start; flex-direction: column; gap: 14px; }
  .course-heading-meta { width: 100%; justify-content: space-between; }
  .course-set-count { margin-left: 57px; }
}

@media (max-width: 480px) {
  .course-select-row { grid-template-columns: 1fr; }
  .empty-library-actions { align-items: stretch; flex-direction: column; }
  .course-empty-state { align-items: flex-start; flex-direction: column; }
}

.note-workspace {
  display: grid;
  gap: 18px;
  min-height: calc(100vh - 160px);
}

.note-workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.note-title-input {
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: clamp(24px, 3vw, 36px);
  font-weight: 780;
  letter-spacing: -1px;
}

.note-title-input:focus {
  box-shadow: none;
}

.note-workspace-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.note-workspace-actions select {
  min-width: 220px;
}

.compact-save-button {
  width: auto;
  min-height: 44px;
  margin-top: 0;
  padding: 10px 18px;
}

.note-mode-tabs {
  display: flex;
  gap: 10px;
}

.note-mode-tab {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}

.note-mode-tab.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.note-mode-pane {
  min-height: calc(100vh - 300px);
}

.doc-note-editor {
  width: 100%;
  min-height: calc(100vh - 300px);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 16px;
  line-height: 1.8;
  resize: vertical;
}

.comments-mode-pane {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 14px;
}

.comment-stream {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: calc(100vh - 380px);
  max-height: calc(100vh - 380px);
  overflow-y: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.note-comment-bubble {
  max-width: 760px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfbf8;
}

.note-comment-bubble p {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
}

.comment-delete-button {
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--red);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.comment-input-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.comment-input-bar input {
  border-radius: 12px;
}

.comment-send-button {
  width: auto;
  min-width: 90px;
  margin-top: 0;
}

@media (max-width: 760px) {
  .note-workspace-header {
    align-items: stretch;
    flex-direction: column;
  }

  .note-workspace-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .note-workspace-actions select,
  .compact-save-button {
    width: 100%;
  }

  .doc-note-editor {
    padding: 22px;
  }

  .comment-input-bar {
    grid-template-columns: 1fr;
  }
}