/* ===== Layout & pages ===== */

/* Auth screen */
.auth-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg-sunken); padding: 20px; z-index: 50;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 32px 28px; text-align: center;
}
.login-logo {
  width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 12px;
  background: var(--primary); color: var(--primary-fg); display: flex; align-items: center; justify-content: center;
}
.login-logo svg.lucide { width: 24px; height: 24px; }
.login-title { font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.login-subtitle { font-size: 13.5px; color: var(--fg-muted); margin-bottom: 22px; }
.login-card .field { text-align: left; }
.login-card .btn { margin-top: 6px; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; height: 100%; display: flex; align-items: center;
  gap: 8px; padding: 0 16px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 14px; padding: 4px 6px; border-radius: var(--radius); }
.brand:hover { background: var(--bg-hover); }
.brand-icon { display: inline-flex; color: var(--fg); }
.view, .topbar-inner { max-width: 1200px; }
.topnav { display: flex; gap: 2px; margin-left: 8px; }
.topnav-link {
  display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: var(--radius);
  font-size: 13.5px; color: var(--fg-muted); font-weight: 500;
}
.topnav-link:hover { background: var(--bg-hover); color: var(--fg); }
.topnav-link.active { background: var(--bg-active); color: var(--fg); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 3px 8px 3px 3px; border-radius: 999px; }
.user-chip:hover { background: var(--bg-hover); }
.user-chip-name { font-size: 13.5px; font-weight: 550; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* View container */
.view { margin: 0 auto; padding: 24px 16px 80px; min-height: calc(100vh - var(--topbar-h)); }

/* Page header with banner (Notion style) */
.page-banner {
  height: 160px; border-radius: var(--radius-lg); margin: -8px -8px 0; position: relative;
}
.page-header { max-width: 900px; margin: 0 auto; }
.page-header .avatar-overlap { margin-top: -42px; margin-bottom: 8px; }
.page-title-row { display: flex; align-items: flex-start; gap: 10px; }
.page-title { font-size: 30px; font-weight: 700; line-height: 1.2; letter-spacing: -.01em; flex: 1; outline: none; border-radius: var(--radius-sm); padding: 2px 6px; margin-left: -6px; }
.page-title[contenteditable]:hover { background: var(--bg-hover); }
.page-title[contenteditable]:focus { background: var(--bg); box-shadow: 0 0 0 2px rgba(46,170,220,.3); }
.page-desc { font-size: 15px; color: var(--fg-muted); margin-top: 4px; padding: 2px 6px; margin-left: -6px; border-radius: var(--radius-sm); outline: none; min-height: 24px; }
.page-desc[contenteditable]:hover { background: var(--bg-hover); }
.page-desc[contenteditable]:focus { background: var(--bg); box-shadow: 0 0 0 2px rgba(46,170,220,.3); }
.page-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* Two column layout (content + sidebar) */
.layout-split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
.sidebar { position: sticky; top: calc(var(--topbar-h) + 16px); display: flex; flex-direction: column; gap: 18px; }

/* Course list (home) */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.course-card { padding: 16px; cursor: pointer; position: relative; display: flex; flex-direction: column; gap: 10px; }
.course-card-title { font-size: 16px; font-weight: 650; display: flex; align-items: center; gap: 6px; }
.course-card-title .star { color: var(--warning); }
.course-card-desc { font-size: 13px; color: var(--fg-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 0; }
.course-card-stats { display: flex; gap: 14px; align-items: center; margin-top: auto; }
.stat-block { display: flex; flex-direction: column; gap: 3px; }
.stat-label { font-size: 11.5px; color: var(--fg-faint); text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.stat-value { font-size: 14px; font-weight: 650; }
.course-card-menu { position: absolute; top: 8px; right: 8px; opacity: 0; transition: opacity .12s; }
.course-card:hover .course-card-menu { opacity: 1; }

/* Module card */
.module-list { display: flex; flex-direction: column; gap: 10px; }
.module-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; }
.module-card-head { display: flex; align-items: center; gap: 8px; }
.module-card-title { font-size: 15.5px; font-weight: 620; flex: 1; }
.module-card-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.module-card-meta { display: flex; align-items: center; gap: 14px; font-size: 12.5px; color: var(--fg-muted); }
.module-card-meta .progress { flex: 1; max-width: 180px; }
.completed-badge { color: var(--success); display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: 12.5px; }
.module-card.is-completed { opacity: .92; }

.section-title { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--fg-faint); margin: 26px 0 10px; display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.section-title:hover { color: var(--fg-muted); }
.section-title svg.lucide { width: 14px; height: 14px; transition: transform .15s; }
.section-collapsed svg.lucide.chev { transform: rotate(-90deg); }

/* Discipline / topic rows inside module page */
.discipline-block { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg); margin-bottom: 12px; overflow: hidden; }
.discipline-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--bg-sunken); border-bottom: 1px solid var(--border); }
.discipline-title { font-weight: 620; font-size: 14.5px; flex: 1; }
.topic-row { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--border); }
.topic-row:last-child { border-bottom: none; }
.topic-row:hover { background: var(--bg-hover); }
.topic-title { flex: 1; font-size: 14px; cursor: pointer; }
.topic-title.done { color: var(--fg-faint); text-decoration: line-through; }
.topic-date { font-size: 12px; color: var(--fg-muted); display: inline-flex; align-items: center; gap: 4px; }
.task-count-badge { font-size: 11.5px; color: var(--fg-faint); }

/* Final project block */
.project-card { border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--bg-sunken); }
.project-card-head { display: flex; align-items: center; gap: 10px; }
.project-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--primary); color: var(--primary-fg); display: flex; align-items: center; justify-content: center; }
.project-icon svg.lucide { width: 20px; height: 20px; }
.project-due { font-size: 12.5px; color: var(--warning); display: inline-flex; align-items: center; gap: 5px; font-weight: 550; }
.criterion-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 13.5px; }
.ref-link { display: inline-flex; align-items: center; gap: 5px; color: var(--accent); font-size: 13px; }
.ref-link:hover { text-decoration: underline; }

/* Sidebar widgets */
.widget { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg); padding: 12px; }
.widget-title { font-size: 12.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--fg-faint); margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; }

/* Mini calendar */
.mini-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.mini-cal-title { font-weight: 620; font-size: 13px; }
.mini-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.mini-cal-dow { text-align: center; font-size: 10.5px; color: var(--fg-faint); font-weight: 600; padding: 2px 0; }
.mini-cal-day { text-align: center; font-size: 11.5px; padding: 4px 0; border-radius: 4px; position: relative; cursor: default; }
.mini-cal-day.other { color: var(--fg-faint); }
.mini-cal-day.today { background: var(--primary); color: var(--primary-fg); font-weight: 700; }
.mini-cal-day.has-event::after { content: ''; position: absolute; bottom: 1.5px; left: 50%; transform: translateX(-50%); width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.mini-cal-day.today.has-event::after { background: var(--primary-fg); }

/* Planner */
.planner-group-label { font-size: 11.5px; font-weight: 650; color: var(--fg-faint); text-transform: uppercase; letter-spacing: .03em; margin: 10px 0 4px; }
.planner-item { display: flex; align-items: flex-start; gap: 8px; padding: 6px 6px; border-radius: var(--radius); cursor: pointer; }
.planner-item:hover { background: var(--bg-hover); }
.planner-item-title { font-size: 13px; font-weight: 550; line-height: 1.35; }
.planner-item-path { font-size: 11.5px; color: var(--fg-faint); line-height: 1.3; }
.planner-item.dimmed { opacity: .45; }
.planner-empty { font-size: 13px; color: var(--fg-faint); padding: 8px 4px; }

/* Full calendar */
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-today-btn { font-size: 13px; font-weight: 550; padding: 4px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); }
.cal-today-btn:hover { background: var(--bg-hover); }
.week-grid { display: grid; grid-template-columns: 56px repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--bg); }
.week-head { padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--border); background: var(--bg-sunken); font-size: 12px; color: var(--fg-muted); font-weight: 600; }
.week-head .daynum { display: block; font-size: 17px; color: var(--fg); font-weight: 650; margin-top: 2px; }
.week-head.today-col { background: var(--selected); }
.week-head.today-col .daynum { color: var(--accent); }
.week-body { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; }
.event-pill {
  display: flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 7px; border-radius: 5px;
  margin: 2px 4px; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  color: #fff; font-weight: 550;
}
.event-pill:hover { filter: brightness(.92); }
.day-col { border-right: 1px solid var(--border); min-height: 120px; padding-bottom: 8px; }
.day-col:last-child { border-right: none; }
.time-gutter { font-size: 10.5px; color: var(--fg-faint); text-align: right; padding-right: 6px; }

/* Settings page */
.settings-section { max-width: 640px; margin: 0 auto 26px; }
.settings-section h2 { font-size: 17px; font-weight: 650; margin-bottom: 4px; }
.settings-section .sub { font-size: 13px; color: var(--fg-muted); margin-bottom: 14px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: none; }
.setting-row .label { font-size: 14px; font-weight: 550; }
.setting-row .desc { font-size: 12.5px; color: var(--fg-faint); }

/* Profile editor modal */
.banner-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.banner-option { height: 56px; border-radius: var(--radius); cursor: pointer; border: 2px solid transparent; }
.banner-option.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(46,170,220,.25); }
.icon-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-option { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius); border: 1px solid var(--border); cursor: pointer; }
.icon-option:hover { background: var(--bg-hover); }
.icon-option.selected { border-color: var(--accent); background: var(--selected); }
.color-dot { width: 26px; height: 26px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.color-dot.selected { border-color: var(--fg); }

/* Breadcrumbs */
.breadcrumbs { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--fg-muted); margin-bottom: 10px; flex-wrap: wrap; }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs .sep { color: var(--fg-faint); }

/* Editor nav tree */
.editor-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 24px; align-items: start; }
.tree { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 8px; background: var(--bg); }
.tree-node { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: var(--radius-sm); font-size: 13.5px; cursor: pointer; }
.tree-node:hover { background: var(--bg-hover); }
.tree-node.active { background: var(--selected); font-weight: 600; }
.tree-node .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-indent-1 { padding-left: 22px; }
.tree-indent-2 { padding-left: 38px; }
.tree-indent-3 { padding-left: 54px; }
.editor-panel { display: flex; flex-direction: column; gap: 16px; }
.list-editor-row { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); margin-bottom: 6px; }
.list-editor-row:hover { border-color: var(--border-strong); }
.list-editor-row .inline-edit { font-size: 14px; }

/* Responsive */
@media (max-width: 1024px) {
  .layout-split { grid-template-columns: 1fr; }
  .sidebar { position: static; order: -1; flex-direction: row; flex-wrap: wrap; }
  .sidebar .widget { flex: 1 1 260px; }
  .editor-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .view { padding: 14px 10px 70px; }
  .page-title { font-size: 24px; }
  .brand-name { display: none; }
  .user-chip-name { display: none; }
  .topnav-link span { display: none; }
  .course-grid { grid-template-columns: 1fr; }
  .week-grid { grid-template-columns: 44px repeat(7, minmax(0, 1fr)); font-size: 11px; }
  .modal-overlay { padding: 4vh 10px 20px; }
  .sidebar { flex-direction: column; }
}
