/* =========================================================================
   Calc II Tracker — one stylesheet.
   Aesthetic: calm, neutral, single blue accent, hairline borders, soft
   shadows, gentle 150–200ms transitions. Light by default, auto dark mode.
   ========================================================================= */

:root {
  /* Neutral palette */
  --bg:        #fbfbfd;   /* near-white page */
  --surface:   #ffffff;   /* cards */
  --surface-2: #f5f5f7;   /* subtle fills */
  --line:      #e6e6ea;   /* hairline borders */
  --text:      #1d1d1f;   /* primary text */
  --text-2:    #6e6e73;   /* secondary text */
  --text-3:    #a1a1a6;   /* tertiary / hints */

  /* Single accent */
  --accent:    #0071e3;
  --accent-700:#0a5fc0;
  --accent-soft:#eaf3fe;

  /* Semantic (used sparingly) */
  --green:     #1a8c4a;
  --green-soft:#e7f5ed;
  --amber:     #b25e00;
  --amber-soft:#fdf0e1;
  --red:       #c0392b;
  --red-soft:  #fdecea;

  /* Depth */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,.06), 0 1px 4px rgba(0,0,0,.04);
  --radius:    12px;
  --radius-sm: 8px;
  --ease:      cubic-bezier(.4,0,.2,1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #000000;
    --surface:   #1c1c1e;
    --surface-2: #2c2c2e;
    --line:      #2e2e30;
    --text:      #f5f5f7;
    --text-2:    #a1a1a6;
    --text-3:    #6e6e73;
    --accent:    #2997ff;
    --accent-700:#2389e6;
    --accent-soft:#10314f;
    --green-soft:#10301d;
    --amber-soft:#33240f;
    --red-soft:  #3a1714;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 6px 24px rgba(0,0,0,.5);
  }
}

/* --- Base ---------------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; font-weight: 600; }
h1 { font-size: 1.9rem; line-height: 1.15; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-700); }
.muted { color: var(--text-2); }
small { font-size: .82em; }

/* --- Top bar ------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 0 24px;
  height: 56px; display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--text); color: var(--bg);
  display: grid; place-items: center; font-size: 18px; font-weight: 600;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text strong { font-size: .95rem; }
.brand-text small { color: var(--text-3); font-size: .7rem; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a {
  color: var(--text-2); font-size: .9rem; font-weight: 500;
  padding: 7px 12px; border-radius: 8px; transition: background .15s var(--ease), color .15s var(--ease);
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { color: var(--text); background: var(--surface-2); }
.nav .nav-quiet { color: var(--text-3); }

/* --- Layout shell -------------------------------------------------------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 32px 24px 64px; }
.foot {
  max-width: 1080px; margin: 0 auto; padding: 24px;
  color: var(--text-3); font-size: .8rem; border-top: 1px solid var(--line);
}
.block { margin-top: 40px; }
.block-title {
  font-size: .8rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-2); margin-bottom: 14px; font-weight: 600;
}
.back {
  display: inline-block; margin-bottom: 16px; color: var(--text-2);
  font-size: .9rem; font-weight: 500;
}
.back:hover { color: var(--text); }

/* --- Hero / progress ----------------------------------------------------- */
.hero {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow-sm);
}
.hero-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.hero h1 { margin-bottom: 4px; }
.countdown {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 12px 18px; white-space: nowrap;
}
.countdown-num { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; }
.countdown-label { font-size: .78rem; color: var(--text-2); line-height: 1.25; }

.progress { margin-top: 22px; }
.progress-top { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: 8px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-fill {
  height: 100%; background: var(--accent); border-radius: 99px;
  transition: width .4s var(--ease);
}

/* --- Deadlines strip ----------------------------------------------------- */
.deadline-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.deadline {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-sm);
  border-left: 3px solid var(--line);
}
.deadline.soon { border-left-color: var(--amber); }
.deadline.past { border-left-color: var(--red); }
.deadline-name { font-weight: 600; font-size: .95rem; }
.deadline-due { color: var(--text-2); font-size: .82rem; }
.link-more { display: inline-block; margin-top: 14px; font-size: .9rem; font-weight: 500; }

/* --- Tags ---------------------------------------------------------------- */
.tag {
  display: inline-block; font-size: .68rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  padding: 3px 8px; border-radius: 6px; width: max-content;
}
.tag-lecture  { background: var(--surface-2); color: var(--text-2); }
.tag-quiz     { background: var(--amber-soft); color: var(--amber); }
.tag-exam     { background: var(--red-soft); color: var(--red); }
.tag-review   { background: var(--accent-soft); color: var(--accent); }
.tag-homework { background: var(--surface-2); color: var(--text-2); }

/* --- Schedule weeks ------------------------------------------------------ */
.week { margin-bottom: 22px; }
.week-label {
  font-size: .78rem; font-weight: 600; color: var(--text-3);
  margin-bottom: 8px; letter-spacing: .02em;
}
.week-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.day {
  display: flex; flex-direction: column; gap: 8px; min-height: 118px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px;
  color: var(--text); box-shadow: var(--shadow-sm);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease), border-color .15s var(--ease);
}
.day:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.day-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.day-date { font-size: .72rem; color: var(--text-3); font-weight: 600; }
.day-sec { font-size: .72rem; color: var(--accent); font-weight: 600; }
.day-title { font-size: .85rem; font-weight: 500; line-height: 1.3; flex: 1; }
.day-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.check-done { font-size: .7rem; color: var(--green); font-weight: 600; }
.day.is-done { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 25%, var(--line)); }
.day.type-exam { border-color: color-mix(in srgb, var(--red) 35%, var(--line)); }
.day.type-exam .day-title { color: var(--red); font-weight: 600; }
.day.type-quiz { background: color-mix(in srgb, var(--amber-soft) 60%, var(--surface)); }

/* --- Info cards ---------------------------------------------------------- */
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.info-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 18px; box-shadow: var(--shadow-sm);
}
.info-card h3 { font-size: .92rem; margin-bottom: 6px; }
.info-card p { margin: 0; color: var(--text-2); font-size: .88rem; }

/* --- Homework list ------------------------------------------------------- */
.hw-list { display: flex; flex-direction: column; gap: 8px; }
.hw-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px 18px;
  box-shadow: var(--shadow-sm); cursor: pointer;
  border-left: 3px solid var(--line);
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.hw-item.flag-soon { border-left-color: var(--amber); }
.hw-item.flag-past { border-left-color: var(--red); }
.hw-item.flag-done { border-left-color: var(--green); }
.hw-item input { position: absolute; opacity: 0; pointer-events: none; }
.hw-check {
  flex: none; width: 22px; height: 22px; border-radius: 7px;
  border: 1.5px solid var(--text-3); display: grid; place-items: center;
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.hw-check::after { content: '✓'; color: #fff; font-size: .8rem; opacity: 0; transform: scale(.6); transition: .15s var(--ease); }
.hw-item.is-done .hw-check { background: var(--green); border-color: var(--green); }
.hw-item.is-done .hw-check::after { opacity: 1; transform: scale(1); }
.hw-main { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hw-name { font-weight: 600; font-size: .95rem; }
.hw-item.is-done .hw-name { color: var(--text-2); text-decoration: line-through; }
.hw-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hw-due { color: var(--text-2); font-size: .82rem; }
.hw-points { flex: none; font-weight: 700; font-size: 1rem; }
.hw-points small { color: var(--text-3); font-weight: 500; }
.pill { font-size: .68rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.pill-soon { background: var(--amber-soft); color: var(--amber); }
.pill-past { background: var(--red-soft); color: var(--red); }

/* --- Topic detail -------------------------------------------------------- */
.topic-eyebrow { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.done-toggle {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 99px; padding: 8px 16px; font-size: .9rem; font-weight: 500;
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.done-toggle input { display: none; }
.done-dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid var(--text-3); transition: .15s var(--ease);
}
.done-toggle.on { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 30%, var(--line)); }
.done-toggle.on .done-dot { background: var(--green); border-color: var(--green); }
.done-toggle.on .done-text { color: var(--green); }

.cols { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; margin-top: 24px; align-items: start; }
.col-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm);
}
.card-title { font-size: 1.05rem; margin-bottom: 16px; }
.empty { color: var(--text-3); font-size: .9rem; margin: 0 0 16px; }

/* Videos */
.video-list { display: flex; flex-direction: column; gap: 18px; margin-bottom: 18px; }
.video-embed {
  position: relative; padding-top: 56.25%; border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface-2);
}
.video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.video-meta a { font-weight: 500; font-size: .9rem; word-break: break-word; }
.add-video { display: flex; gap: 8px; flex-wrap: wrap; }
.add-video input[type=url] { flex: 2; min-width: 160px; }
.add-video input[type=text] { flex: 1; min-width: 120px; }

/* Inputs & buttons */
input[type=text], input[type=url], input[type=password], textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; width: 100%;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; line-height: 1.6; }
.btn {
  font: inherit; font-weight: 500; cursor: pointer;
  background: var(--accent); color: #fff; border: 0;
  border-radius: var(--radius-sm); padding: 10px 18px; white-space: nowrap;
  transition: background .15s var(--ease), transform .1s var(--ease);
}
.btn:hover { background: var(--accent-700); }
.btn:active { transform: scale(.98); }
.btn-ghost {
  background: transparent; color: var(--text-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 6px 12px; font: inherit; cursor: pointer;
  transition: .15s var(--ease);
}
.btn-ghost:hover { color: var(--red); border-color: var(--red); }
.btn-sm { font-size: .82rem; }
.inline { display: inline; }

/* Notes */
.notes-form { display: flex; flex-direction: column; gap: 12px; }
.notes-form .btn { align-self: flex-start; }

/* --- Drive-like file list ------------------------------------------------ */
.drive {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px; margin-bottom: 18px;
}
.dfile {
  display: flex; flex-direction: column; gap: 8px; text-align: left;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px; cursor: pointer;
  font: inherit; color: var(--text); box-shadow: var(--shadow-sm);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease), border-color .15s var(--ease);
}
.dfile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.dfile-thumb {
  position: relative; width: 100%; aspect-ratio: 4/3; border-radius: 8px;
  overflow: hidden; background: var(--surface-2); display: grid; place-items: center;
}
.dfile-thumb img { width: 100%; height: 100%; object-fit: cover; }
.dfile-badge { font-size: .8rem; font-weight: 700; letter-spacing: .04em; color: var(--text-2); }
/* Tint the icon tile by file family */
.dfile-thumb.kind-pdf    { background: var(--red-soft); }
.dfile-thumb.kind-pdf    .dfile-badge { color: var(--red); }
.dfile-thumb.kind-office { background: var(--accent-soft); }
.dfile-thumb.kind-office .dfile-badge { color: var(--accent); }
.dfile-thumb.kind-video  { background: var(--amber-soft); }
.dfile-thumb.kind-video  .dfile-badge { color: var(--amber); }
.dfile-thumb.kind-audio  { background: var(--green-soft); }
.dfile-thumb.kind-audio  .dfile-badge { color: var(--green); }
.dfile-name {
  font-weight: 600; font-size: .85rem; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.dfile-meta { font-size: .72rem; color: var(--text-3); }

/* --- File previewer popup ----------------------------------------------- */
.viewer {
  position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column;
  background: rgba(0,0,0,.92); animation: fade .2s var(--ease);
}
.viewer[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.viewer-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 16px; color: #fff;
}
.viewer-name {
  font-weight: 600; font-size: .95rem; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; flex: 1;
}
.viewer-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.vbtn {
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer;
  background: rgba(255,255,255,.14); color: #fff; border: 0; font: inherit;
  font-size: .85rem; font-weight: 500; padding: 8px 14px; border-radius: 8px;
  transition: background .15s var(--ease);
}
.vbtn:hover { background: rgba(255,255,255,.28); color: #fff; }
.vbtn-danger:hover { background: var(--red); }
.vbtn-close { width: 38px; height: 38px; padding: 0; justify-content: center; font-size: 1rem; }
.viewer-stage {
  flex: 1; display: grid; place-items: center; padding: 0 16px 16px; min-height: 0;
}
.v-img { max-width: 100%; max-height: 100%; border-radius: var(--radius-sm);
  box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.v-video { max-width: 100%; max-height: 100%; border-radius: var(--radius-sm); background: #000; }
.v-audio { width: min(560px, 90%); }
.v-frame {
  width: min(1000px, 100%); height: 100%; border: 0; border-radius: var(--radius-sm);
  background: #fff;
}
.v-none { text-align: center; color: #fff; display: flex; flex-direction: column;
  align-items: center; gap: 14px; }
.v-none-badge {
  font-size: 1.1rem; font-weight: 700; letter-spacing: .05em; color: #fff;
  background: rgba(255,255,255,.14); padding: 18px 24px; border-radius: 12px;
}
.viewer-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255,255,255,.14); color: #fff; font-size: 1.8rem; line-height: 1;
  display: grid; place-items: center; transition: background .15s var(--ease);
}
.viewer-nav:hover { background: rgba(255,255,255,.28); }
.viewer-prev { left: 16px; } .viewer-next { right: 16px; }
@media (max-width: 560px) {
  .viewer-nav { width: 40px; height: 40px; font-size: 1.4rem; }
  .vbtn { padding: 8px 10px; }
}

/* Upload dropzone */
.upload { display: flex; flex-direction: column; gap: 12px; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--line); border-radius: var(--radius);
  padding: 28px 16px; color: var(--text-2);
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dz-text { font-weight: 500; color: var(--text); font-size: .92rem; }
.dz-hint { font-size: .78rem; color: var(--text-3); }
.dz-text.has-files { color: var(--accent); }
.upload .btn { align-self: flex-start; }

/* --- Pager --------------------------------------------------------------- */
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; }
.pager-link {
  display: flex; flex-direction: column; gap: 2px; max-width: 46%;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 16px; box-shadow: var(--shadow-sm);
  transition: border-color .15s var(--ease);
}
.pager-link:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.pager-link small { color: var(--text-3); font-size: .72rem; }
.pager-link span { color: var(--text); font-weight: 500; font-size: .9rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager-right { text-align: right; align-items: flex-end; }

/* --- Login --------------------------------------------------------------- */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card {
  width: 100%; max-width: 360px; text-align: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 40px 32px; box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; gap: 14px;
}
.login-mark {
  width: 52px; height: 52px; margin: 0 auto 6px; border-radius: 14px;
  background: var(--text); color: var(--bg); display: grid; place-items: center;
  font-size: 28px; font-weight: 600;
}
.login-card h1 { font-size: 1.5rem; }
.login-sub { color: var(--text-2); font-size: .88rem; margin: -8px 0 8px; }
.login-card input { text-align: center; }
.login-card .btn, .login-card button { width: 100%; padding: 12px; }
.login-error {
  background: var(--red-soft); color: var(--red); font-size: .85rem;
  padding: 10px; border-radius: var(--radius-sm);
}

/* --- Responsive ---------------------------------------------------------- */
@media (max-width: 860px) {
  .cols { grid-template-columns: 1fr; }
  .week-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .wrap { padding: 20px 16px 48px; }
  .topbar-inner { padding: 0 16px; }
  .hero { padding: 20px; }
  h1 { font-size: 1.55rem; }
  .week-grid { grid-template-columns: 1fr; }
  .hero-head { flex-direction: column; }
  .countdown { width: 100%; justify-content: space-between; }
  .hw-points { font-size: .9rem; }
}
