/* ── RESET & BASE ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f5f5f4;
  color: #1c1917;
  min-height: 100vh;
}

/* ── VIEWS ── */
.view { min-height: 100vh; }
.view.hidden { display: none; }
.view.active { display: block; }
.hidden { display: none !important; }

/* ── LOGIN ── */
#view-login {
  display: none;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1c3170 0%, #2b4494 55%, #cc2229 100%);
  min-height: 100vh;
}
#view-login.active { display: flex; }

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.login-logo {
  width: 170px;
  height: auto;
  object-fit: contain;
  margin: 0 auto 14px;
  display: block;
}

.login-org {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1c1917;
  margin-bottom: 4px;
}

.login-sub {
  font-size: 0.83rem;
  color: #78716c;
  margin-bottom: 28px;
}

.login-card label {
  display: block;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #57534e;
  margin-bottom: 6px;
}

.login-card input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #e7e5e4;
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 14px;
}

.login-card input:focus { border-color: #cc2229; }

.error {
  color: #dc2626;
  font-size: 0.82rem;
  text-align: left;
  margin-top: -8px;
  margin-bottom: 10px;
}

/* ── BUTTONS ── */
.btn-primary {
  width: 100%;
  padding: 12px;
  background: #cc2229;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: #a81b21; }
.btn-primary:active { transform: scale(0.99); }

.btn-logout {
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-logout:hover { background: rgba(255, 255, 255, 0.25); }

.btn-back {
  padding: 5px 10px;
  background: transparent;
  color: #ffd0d2;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-back:hover { background: rgba(255, 255, 255, 0.1); }

/* ── TOP BAR ── */
.top-bar {
  height: 60px;
  background: #1c3170;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.top-bar-left { display: flex; align-items: center; gap: 12px; }

.topbar-logo {
  height: 36px;
  width: auto;
  object-fit: contain;
  border-radius: 4px;
  background: #fff;
  padding: 2px 6px;
}

.topbar-org {
  font-size: 0.95rem;
  font-weight: 700;
  color: #b8c8f8;
}

.planner-course-badge {
  font-size: 0.83rem;
  font-weight: 600;
  color: #e8eeff;
  background: rgba(255, 255, 255, 0.15);
  padding: 3px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ── COURSE SELECT ── */
.select-main {
  max-width: 780px;
  margin: 48px auto;
  padding: 0 24px;
  text-align: center;
}

.select-heading {
  font-size: 1.6rem;
  font-weight: 700;
  color: #1c1917;
  margin-bottom: 8px;
}

.select-sub {
  color: #78716c;
  font-size: 0.9rem;
  margin-bottom: 40px;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.course-card {
  padding: 28px 16px;
  background: #fff;
  border: 2px solid #e7e5e4;
  border-radius: 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
}
.course-card:hover {
  border-color: #cc2229;
  box-shadow: 0 8px 28px rgba(204, 34, 41, 0.15);
  transform: translateY(-3px);
}

.course-icon { font-size: 2.8rem; line-height: 1; }
.course-name {
  font-size: 1rem;
  font-weight: 700;
  color: #1c1917;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.course-level {
  font-size: 0.72rem;
  font-weight: 600;
  color: #cc2229;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  background: #fff0f1;
  border: 1px solid #ffd0d2;
  border-radius: 10px;
  padding: 1px 8px;
}

/* ── MODE SELECT ── */
.mode-main {
  max-width: 860px;
  margin: 64px auto;
  padding: 0 24px;
  text-align: center;
}

.mode-heading {
  font-size: 1.6rem;
  font-weight: 700;
  color: #1c1917;
  margin-bottom: 8px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 36px;
}

.mode-card {
  padding: 40px 24px 32px;
  background: #fff;
  border: 2px solid #e7e5e4;
  border-radius: 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
  text-align: center;
}
.mode-card:hover {
  border-color: #cc2229;
  box-shadow: 0 8px 28px rgba(204, 34, 41, 0.15);
  transform: translateY(-3px);
}

.mode-icon  { font-size: 3rem; line-height: 1; }
.mode-title { font-size: 1rem; font-weight: 700; color: #1c1917; line-height: 1.4; }
.mode-desc  { font-size: 0.78rem; color: #78716c; line-height: 1.5; }

/* ── COURSE OUTLINE VIEW ── */
#view-course-outline.active {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
}

.co-toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.co-hint {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.55);
  font-style: italic;
}

.btn-co-reset {
  padding: 5px 14px;
  background: transparent;
  color: #ffd0d2;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-co-reset:hover { background: rgba(204, 34, 41, 0.6); color: #fff; }

.co-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 32px 40px;
  background: #f5f5f4;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Module card */
.co-module {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e7e5e4;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.co-module-header {
  display: flex;
  align-items: center;
  gap: 0;
  border-left: 5px solid var(--module-color, #6366f1);
  background: #fafaf9;
  border-bottom: 1px solid #f0efee;
}

.co-module-num {
  font-size: 0.68rem;
  font-weight: 700;
  color: #a8a29e;
  padding: 12px 10px 12px 14px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Editable text element */
.co-editable {
  display: block;
  flex: 1;
  padding: 12px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #1c1917;
  cursor: text;
  border-radius: 4px;
  transition: background 0.12s;
  word-break: break-word;
}
.co-editable:hover { background: #fff0f1; }
.co-module-header .co-editable { font-size: 0.9rem; font-weight: 700; }

.co-edit-input {
  width: 100%;
  border: none;
  outline: 2px solid #cc2229;
  border-radius: 4px;
  font-size: inherit;
  font-weight: inherit;
  font-family: inherit;
  color: #1c1917;
  background: #fff;
  padding: 2px 6px;
}

/* Topic rows */
.co-topics { padding: 6px 0; }

.co-topic-row {
  display: flex;
  align-items: center;
  padding: 2px 14px 2px 24px;
  gap: 10px;
  border-bottom: 1px solid #f5f5f4;
}
.co-topic-row:last-child { border-bottom: none; }

.co-day-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #a8a29e;
  flex-shrink: 0;
  width: 42px;
}

/* ── COURSE OUTLINE – RICH CARDS ── */

/* Generic card wrapper */
.co-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e7e5e4;
  padding: 18px 22px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Course header card */
.co-header-card {
  background: linear-gradient(135deg, #1c3170 0%, #2b4494 100%);
  border: none;
  color: #fff;
  gap: 14px;
}
.co-header-card .co-editable { color: #fff; }
.co-header-card .co-editable:hover { background: rgba(255,255,255,0.12); }
.co-header-card .co-meta-key { color: #b8c8f8; }
.co-header-card .co-edit-input { background: rgba(255,255,255,0.15); color: #fff; outline-color: rgba(255,255,255,0.6); }

.co-card-title {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.3;
  padding: 4px 6px;
  border-radius: 4px;
}

.co-meta-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.co-meta-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.co-meta-key {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #78716c;
  flex-shrink: 0;
  min-width: 100px;
}
.co-meta-val {
  font-size: 0.88rem;
  font-weight: 500;
  padding: 2px 6px;
}

/* Card section label */
.co-card-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #78716c;
}

/* Paragraph block */
.co-paragraph {
  font-size: 0.87rem;
  font-weight: 400;
  line-height: 1.65;
  color: #1c1917;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: text;
}
.co-paragraph:hover { background: #fff0f1; }

/* List items */
.co-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.co-list-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.co-list-bullet {
  color: #cc2229;
  font-size: 0.9rem;
  flex-shrink: 0;
  margin-top: 2px;
}
.co-list-text {
  font-size: 0.86rem;
  font-weight: 400;
  line-height: 1.55;
  color: #1c1917;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: text;
  flex: 1;
}
.co-list-text:hover { background: #fff0f1; }

/* Section group header */
.co-section-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.co-section-group-title {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #a8a29e;
  padding: 0 2px;
}

/* Module body */
.co-module-body {
  padding: 10px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Module field row (objective, weekly task, assessment) */
.co-module-field {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 14px 8px 24px;
  border-bottom: 1px solid #f5f5f4;
}
.co-module-field:last-child { border-bottom: none; }

.co-field-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #a8a29e;
  flex-shrink: 0;
  width: 90px;
  padding-top: 3px;
}
.co-field-text {
  font-size: 0.86rem;
  font-weight: 400;
  color: #1c1917;
  line-height: 1.5;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: text;
  flex: 1;
  font-weight: 500;
}
.co-field-text:hover { background: #fff0f1; }

.co-module-task .co-field-text { color: #1c3170; font-style: italic; }
.co-module-assessment .co-field-text { color: #cc2229; font-weight: 700; }

/* Week badge in module header */
.co-module-week {
  font-size: 0.72rem;
  font-weight: 600;
  color: #78716c;
  padding: 10px 14px;
  margin-left: auto;
  flex-shrink: 0;
  white-space: nowrap;
  cursor: text;
}
.co-module-week:hover { background: #fff0f1; }

/* Assessment plan table */
.co-assessment-table {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid #e7e5e4;
  border-radius: 8px;
  overflow: hidden;
}
.co-assessment-row {
  display: flex;
  align-items: center;
  background: #fafaf9;
  border-bottom: 1px solid #f0efee;
}
.co-assessment-row:last-child { border-bottom: none; }
.co-assessment-row:nth-child(even) { background: #fff; }

.co-assessment-item {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 500;
  color: #1c1917;
  padding: 8px 12px;
  cursor: text;
  border-radius: 0;
}
.co-assessment-item:hover { background: #fff0f1; }

.co-assessment-weight {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1c3170;
  padding: 8px 14px;
  cursor: text;
  flex-shrink: 0;
  min-width: 60px;
  text-align: right;
}
.co-assessment-weight:hover { background: #fff0f1; }

/* Block (multi-line) textarea for editing paragraphs */
.co-edit-textarea {
  width: 100%;
  min-height: 80px;
  border: none;
  outline: 2px solid #cc2229;
  border-radius: 4px;
  font-size: 0.87rem;
  font-weight: 400;
  font-family: inherit;
  color: #1c1917;
  background: #fff;
  padding: 6px 8px;
  resize: vertical;
  line-height: 1.65;
}

/* ── LESSON PLAN EDITOR ── */
#view-lesson-plan.active {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
}

.lp-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.lp-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e7e5e4;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lp-sidebar-top {
  padding: 14px 16px;
  border-bottom: 1px solid #e7e5e4;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lp-select-group { display: flex; flex-direction: column; gap: 5px; }

.lp-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #78716c;
}

.lp-select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #e7e5e4;
  border-radius: 8px;
  font-size: 0.8rem;
  color: #1c1917;
  background: #fafaf9;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
.lp-select:focus { border-color: #1c3170; background: #fff; }

.lp-plans-section {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.lp-plans-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #78716c;
  padding: 12px 16px 6px;
  flex-shrink: 0;
  border-top: 1px solid #f0efee;
}

.lp-plans-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0 8px;
}

.lp-plan-group { margin-bottom: 4px; }

.lp-plan-group-header {
  font-size: 0.68rem;
  font-weight: 700;
  color: #a8a29e;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 16px 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lp-plan-item {
  display: flex;
  align-items: center;
  padding: 6px 12px 6px 24px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.12s, border-color 0.12s;
  gap: 6px;
}
.lp-plan-item:hover { background: #fff0f1; border-left-color: #cc2229; }
.lp-plan-item.active { background: #fff0f1; border-left-color: #cc2229; }

.lp-plan-item-label {
  flex: 1;
  font-size: 0.78rem;
  color: #292524;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lp-plan-item-del {
  background: none;
  border: none;
  color: #c7c3bf;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color 0.1s, background 0.1s;
  opacity: 0;
}
.lp-plan-item:hover .lp-plan-item-del { opacity: 1; }
.lp-plan-item-del:hover { color: #cc2229; background: #ffd0d2; }

/* Right editor area */
.lp-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f5f5f4;
  overflow: hidden;
  min-width: 0;
}

.lp-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #a8a29e;
  text-align: center;
  padding: 40px;
}
.lp-placeholder-icon { font-size: 3rem; line-height: 1; }
.lp-placeholder p { font-size: 0.9rem; line-height: 1.6; }

.lp-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.lp-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid #e7e5e4;
  flex-shrink: 0;
  gap: 12px;
}

.lp-breadcrumb {
  font-size: 0.82rem;
  font-weight: 600;
  color: #57534e;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-lp-save {
  padding: 7px 20px;
  background: #1c3170;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}
.btn-lp-save:hover { background: #cc2229; }

.lp-sections {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-height: 0;
  padding: 12px;
  gap: 12px;
}

.lp-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e7e5e4;
  overflow: hidden;
  min-height: 160px;
}

.lp-section-label {
  padding: 10px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #57534e;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #f0efee;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  background: #fafaf9;
}

.lp-textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  padding: 12px 14px;
  font-size: 0.88rem;
  font-family: inherit;
  color: #1c1917;
  line-height: 1.65;
  background: #fff;
}
.lp-textarea::placeholder { color: #c7c3bf; }

/* ── PLANNER BODY ── */
#view-planner.active {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
}

.planner-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── SIDEBAR ── */
.sidebar {
  width: 268px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e7e5e4;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-top {
  padding: 14px 16px;
  border-bottom: 1px solid #e7e5e4;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #1c1917;
}

.sidebar-hint {
  font-size: 0.72rem;
  color: #a8a29e;
  margin-top: 2px;
}

.curriculum-list {
  overflow-y: auto;
  flex: 1;
  padding: 6px 0;
}

.loading-text {
  padding: 16px;
  color: #a8a29e;
  font-size: 0.85rem;
}

/* ── LESSON SECTION ── */
.lesson-section { border-bottom: 1px solid #f5f5f4; }

.lesson-header-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 10px 9px 0;
  border-left: 3px solid var(--lesson-color, #6366f1);
  cursor: grab;
  user-select: none;
  transition: background 0.12s;
}
.lesson-header-row:hover { background: #fafaf9; }
.lesson-header-row:active { cursor: grabbing; }

.toggle-icon {
  font-size: 0.55rem;
  color: #a8a29e;
  flex-shrink: 0;
  margin-left: 10px;
}

.lesson-name-text {
  flex: 1;
  font-size: 0.79rem;
  font-weight: 700;
  color: #292524;
  min-width: 0;
}

.drag-grip {
  font-size: 0.9rem;
  color: #c7c3bf;
  flex-shrink: 0;
  margin-right: 6px;
  letter-spacing: -2px;
}

/* ── TOPIC CHIPS ── */
.topic-list {
  padding: 4px 10px 8px 20px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.topic-list.collapsed { display: none; }

.topic-chip {
  padding: 5px 12px;
  background: var(--lesson-color, #6366f1);
  color: #fff;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: grab;
  user-select: none;
  opacity: 0.85;
  transition: opacity 0.1s, transform 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topic-chip:hover { opacity: 1; transform: translateX(3px); }
.topic-chip:active { cursor: grabbing; opacity: 0.65; }

/* ── CALENDAR SECTION ── */
.cal-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  overflow: hidden;
  background: #f5f5f4;
  min-width: 0;
}

/* Nav bar */
.cal-nav-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

.cal-month-label {
  flex: 1;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1c1917;
}

.cal-nav-btn {
  width: 30px;
  height: 30px;
  background: none;
  border: 1px solid #e7e5e4;
  border-radius: 6px;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  color: #57534e;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
  padding: 0;
}
.cal-nav-btn:hover { background: #cc2229; color: #fff; border-color: #cc2229; }

.cal-today-btn {
  padding: 5px 14px;
  background: #fff0f1;
  color: #a81b21;
  border: 1px solid #ffd0d2;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s;
}
.cal-today-btn:hover { background: #cc2229; color: #fff; border-color: #cc2229; }

/* Day header row */
.cal-day-headers {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  flex-shrink: 0;
}
.cal-day-headers > div {
  text-align: center;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #78716c;
  padding: 3px 0;
}

/* ── CALENDAR GRID (week-based) ── */
.cal-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  overflow: hidden;
}

.cal-week {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── SPAN ROW (multi-day module bars) ── */
.span-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  min-height: 4px;
  padding: 1px 0;
  gap: 0;
  flex-shrink: 0;
}

.cal-span {
  grid-row: 1;
  display: flex;
  align-items: center;
  height: 26px;
  border-radius: 4px;
  margin: 2px 2px;
  padding: 0;
  gap: 0;
  overflow: hidden;
  color: #fff;
  font-size: 0.67rem;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

/* Continuation indicators — flat edges where span crosses week boundary */
.cal-span.span-cont-left  { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: 0; }
.cal-span.span-cont-right { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: 0; }

/* Resize handles */
.span-resize {
  width: 14px;
  min-width: 14px;
  height: 100%;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 3px;
  cursor: ew-resize;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: -1px;
  transition: background 0.1s;
}
.span-resize::before { content: '⋮'; }
.span-resize:hover { background: rgba(0, 0, 0, 0.35); color: #fff; }

.span-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 4px;
}

.span-del {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color 0.1s, background 0.1s;
}
.span-del:hover { color: #fff; background: rgba(0, 0, 0, 0.2); }

/* ── DAY ROW ── */
.day-row {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  min-height: 0;
}

/* ── DAY CELLS ── */
.cal-cell {
  background: #fff;
  border: 1px solid #e7e5e4;
  border-radius: 8px;
  padding: 5px 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: border-color 0.12s, background 0.12s;
}

.cal-other-month {
  background: #fafaf9;
  border-color: #f0efee;
}
.cal-other-month .cal-day-num { color: #d4d0cc; }

.cal-cell.today {
  border-color: #cc2229;
  border-width: 2px;
}

.cal-cell.drag-over {
  background: #fff0f1;
  border-color: #cc2229;
  border-style: dashed;
  border-width: 2px;
}

.cal-day-num {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: #a8a29e;
  margin-bottom: 3px;
  line-height: 1;
  flex-shrink: 0;
}

.cal-cell.today .cal-day-num {
  background: #cc2229;
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.66rem;
}

.cal-items {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  min-height: 0;
}

.cal-items::-webkit-scrollbar { width: 3px; }
.cal-items::-webkit-scrollbar-track { background: transparent; }
.cal-items::-webkit-scrollbar-thumb { background: #d4d0cc; border-radius: 2px; }

/* ── TOPIC CHIPS ON CALENDAR ── */
.cal-chip {
  display: flex;
  align-items: flex-start;
  gap: 3px;
  border-radius: 4px;
  padding: 3px 4px 3px 7px;
  font-size: 0.66rem;
  color: #fff;
  cursor: grab;
  user-select: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}
.cal-chip:active { cursor: grabbing; opacity: 0.7; }

.cal-chip-text {
  flex: 1;
  font-weight: 500;
  white-space: normal;
  word-break: break-word;
  line-height: 1.3;
}

.cal-chip-del {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color 0.1s, background 0.1s;
}
.cal-chip-del:hover { color: #fff; background: rgba(0, 0, 0, 0.2); }

/* ── FEEDBACK INDICATOR on calendar cells ── */
.cal-feedback-dot {
  display: flex;
  gap: 3px;
  margin-top: 1px;
  flex-shrink: 0;
}
.cal-feedback-dot span {
  font-size: 0.55rem;
  line-height: 1;
  opacity: 0.75;
}

/* ── DAY NUMBER: clickable ── */
.cal-day-num {
  cursor: pointer;
  border-radius: 50%;
  padding: 1px 3px;
  transition: background 0.12s, color 0.12s;
}
.cal-day-num:hover { background: #fff0f1; color: #cc2229; }
.cal-cell.today .cal-day-num:hover { background: #a81b21; }

/* ── MODAL OVERLAY ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 49, 112, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }

.modal-card {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #f0efee;
  flex-shrink: 0;
  gap: 12px;
}

.modal-header-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-date-label {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1c1917;
}

.modal-course-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: #cc2229;
  background: #fff0f1;
  border: 1px solid #ffd0d2;
  border-radius: 10px;
  padding: 1px 8px;
  width: fit-content;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: #a8a29e;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.modal-close:hover { background: #fef2f2; color: #cc2229; }

/* Existing feedback items */
.modal-existing {
  overflow-y: auto;
  max-height: 220px;
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid #f0efee;
}
.modal-existing:empty,
.modal-existing:has(.modal-empty) {
  padding: 10px 20px;
}

.modal-empty {
  font-size: 0.8rem;
  color: #a8a29e;
  text-align: center;
  padding: 4px 0;
}

.modal-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #fafaf9;
  border: 1px solid #e7e5e4;
  border-radius: 10px;
  padding: 10px 12px;
}

.modal-item-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }

.modal-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-item-text {
  font-size: 0.83rem;
  color: #292524;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

.modal-item-photo {
  max-width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: 6px;
}

.modal-item-meta {
  font-size: 0.68rem;
  color: #a8a29e;
}

.modal-item-del {
  background: none;
  border: none;
  color: #c7c3bf;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color 0.1s, background 0.1s;
}
.modal-item-del:hover { color: #cc2229; background: #fff0f1; }

/* Action panels */
.modal-panels {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  flex: 1;
}

.modal-panel {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid #f5f5f4;
}
.modal-panel:last-child { border-bottom: none; }

.modal-panel-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #57534e;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.modal-textarea {
  width: 100%;
  border: 1px solid #e7e5e4;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
  color: #1c1917;
  line-height: 1.5;
  transition: border-color 0.15s;
}
.modal-textarea:focus { border-color: #cc2229; }

.btn-modal-action {
  align-self: flex-end;
  padding: 7px 18px;
  background: #1c3170;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-modal-action:hover:not(:disabled) { background: #cc2229; }
.btn-modal-action:disabled { opacity: 0.45; cursor: not-allowed; }

.modal-file-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #f5f5f4;
  border: 1px dashed #d4d0cc;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  color: #78716c;
  transition: border-color 0.15s, background 0.15s;
}
.modal-file-label:hover { border-color: #1c3170; background: #f0f4ff; color: #1c3170; }

.modal-file-input { display: none; }

.modal-photo-preview {
  border-radius: 8px;
  overflow: hidden;
  line-height: 0;
}
.modal-photo-preview img {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: 8px;
}
.modal-photo-preview.hidden { display: none; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .planner-body { flex-direction: column; overflow: visible; }
  #view-planner.active { height: auto; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid #e7e5e4; max-height: 280px; }
  .cal-section { overflow-y: visible; }
  .course-grid { grid-template-columns: repeat(2, 1fr); }
  .mode-grid   { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .course-grid { grid-template-columns: repeat(2, 1fr); }
  .login-card { padding: 32px 24px; margin: 16px; }
}
