@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root{
  --paper: #eae7dd;
  --paper-line: #d6d2c4;
  --card: #f4f2ea;
  --ink: #182338;
  --ink-soft: #4d5468;
  --red: #b23a2e;
  --brass: #a9822c;
  --ruled: #b9c4d6;
  --radius: 3px;
  --shadow: 0 1px 0 rgba(24,35,56,.06), 0 8px 20px -12px rgba(24,35,56,.25);
  --important-bg: #fbf8ee;
  --code-bg: #fff;
}

[data-theme="dark"]{
  --paper: #12141a;
  --paper-line: #2a2d35;
  --card: #1e2028;
  --ink: #e4e2de;
  --ink-soft: #9a9eac;
  --red: #e85d4a;
  --brass: #d4a94c;
  --ruled: #3a3d45;
  --shadow: 0 1px 0 rgba(0,0,0,.3), 0 8px 20px -12px rgba(0,0,0,.6);
  --important-bg: #1c1e24;
  --code-bg: #282a32;
}

*{box-sizing:border-box;}
html{scroll-behavior:smooth;}

body{
  margin:0;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0 38px,
      var(--paper-line) 38px 39px
    ),
    var(--paper);
  color:var(--ink);
  font-family:'IBM Plex Sans', sans-serif;
  -webkit-font-smoothing:antialiased;
}

::selection{ background:var(--red); color:#fff; }

a{ color:inherit; }

.wrap{
  max-width:1080px;
  margin:0 auto;
  padding:0 28px;
}

/* ---------- Header ---------- */
header.hero{
  position:relative;
  padding:72px 0 56px;
  border-bottom:2px solid var(--ink);
}
.eyebrow{
  font-family:'IBM Plex Mono', monospace;
  font-size:12.5px;
  letter-spacing:.14em;
  text-transform:uppercase;
  color:var(--ink-soft);
  display:flex;
  align-items:center;
  gap:10px;
}
.eyebrow::before{
  content:"";
  width:8px;height:8px;
  background:var(--red);
  border-radius:50%;
  display:inline-block;
}
.uni-logo{
  width:22px;
  height:22px;
  object-fit:contain;
  vertical-align:-5px;
}
h1.title{
  font-family:'Fraunces', serif;
  font-weight:700;
  font-size:clamp(2.4rem, 5.2vw, 4.1rem);
  line-height:1.02;
  margin:.4em 0 .3em;
  letter-spacing:-.01em;
}
h1.title em{
  font-style:italic;
  color:var(--red);
}
.hero-sub{
  max-width:560px;
  color:var(--ink-soft);
  font-size:1.05rem;
  line-height:1.6;
}
.stamp{
  position:absolute;
  right:28px; top:56px;
  width:118px; height:118px;
  border:2.5px solid var(--red);
  border-radius:50%;
  color:var(--red);
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  font-family:'IBM Plex Mono', monospace;
  font-size:11px;
  letter-spacing:.06em;
  text-transform:uppercase;
  transform:rotate(-11deg);
  opacity:.85;
  line-height:1.35;
  mix-blend-mode:multiply;
}
.stamp b{ display:block; font-size:15px; letter-spacing:.02em; }
@media (max-width:720px){ .stamp{ display:none; } }

.live-badge{
  position:absolute;
  left:28px; top:30px;
  display:inline-flex;
  align-items:center;
  gap:7px;
  font-family:'IBM Plex Mono', monospace;
  font-size:12px;
  color:var(--ink-soft);
  background:var(--card);
  border:1px solid var(--paper-line);
  padding:5px 12px 5px 10px;
  border-radius:20px;
}
.live-badge .dot{
  width:7px; height:7px;
  border-radius:50%;
  background:#3b9a56;
  box-shadow:0 0 0 0 rgba(59,154,86,.6);
  animation:pulse 2s infinite;
}
.live-badge #liveCount{ color:var(--ink); font-weight:600; }
@keyframes pulse{
  0%{ box-shadow:0 0 0 0 rgba(59,154,86,.55); }
  70%{ box-shadow:0 0 0 7px rgba(59,154,86,0); }
  100%{ box-shadow:0 0 0 0 rgba(59,154,86,0); }
}
@media (prefers-reduced-motion: reduce){
  .live-badge .dot{ animation:none; }
}

/* ---------- Nav / subject index ---------- */
nav.index{
  display:flex;
  gap:0;
  flex-wrap:wrap;
  border-bottom:1px solid var(--ink);
}
nav.index a{
  font-family:'IBM Plex Mono', monospace;
  font-size:13px;
  text-decoration:none;
  color:var(--ink-soft);
  padding:14px 20px;
  border-right:1px solid var(--paper-line);
  transition:background .15s ease, color .15s ease;
}
nav.index a:hover{ background:var(--ink); color:var(--paper); }

/* ---------- Semester picker ---------- */
.sem-block{
  padding:36px 0 8px;
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  gap:12px;
}
.sem-kicker{
  font-family:'IBM Plex Mono', monospace;
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.1em;
  color:var(--ink-soft);
  margin:0;
}
.sem-picker{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.sem-btn{
  font-family:'IBM Plex Mono', monospace;
  font-size:13px;
  padding:10px 18px;
  background:var(--card);
  border:1px solid var(--paper-line);
  border-radius:22px;
  color:var(--ink-soft);
  cursor:pointer;
  transition:all .15s ease;
}
.sem-btn:hover{ color:var(--ink); border-color:var(--ink-soft); }
.sem-btn.active{
  background:var(--ink);
  border-color:var(--ink);
  color:var(--paper);
}
.sem-btn.updating{
  opacity:.85;
}
.sem-title{
  font-family:'Fraunces', serif;
  font-weight:600;
  font-size:1.4rem;
  margin:6px 0 0;
}
.updating{
  border:1px dashed var(--paper-line);
  border-radius:var(--radius);
  padding:26px 22px;
  text-align:center;
}
.updating h3{
  font-family:'Fraunces', serif;
  font-size:1.2rem;
  margin:0 0 8px;
}
.updating p{
  font-family:'IBM Plex Mono', monospace;
  font-size:12px;
  color:var(--ink-soft);
  margin:0;
}

/* ---------- Search bar ---------- */
.search-wrap{
  padding:16px 0;
  display:flex;
  gap:10px;
  align-items:center;
}
.search-input{
  flex:1;
  font-family:'IBM Plex Mono', monospace;
  font-size:13px;
  padding:10px 16px 10px 36px;
  border:1px solid var(--paper-line);
  border-radius:var(--radius);
  background:var(--card);
  color:var(--ink);
  outline:none;
  transition:border-color .15s ease;
}
.search-input::placeholder{ color:var(--ink-soft); opacity:.7; }
.search-input:focus{ border-color:var(--red); }
.search-icon{
  position:absolute;
  left:12px; top:50%;
  transform:translateY(-50%);
  width:16px; height:16px;
  color:var(--ink-soft);
  pointer-events:none;
}
.search-wrap{ position:relative; }
.search-clear{
  background:none; border:none; cursor:pointer;
  font-family:'IBM Plex Mono', monospace;
  font-size:12px; color:var(--ink-soft);
  padding:4px 8px; border-radius:var(--radius);
  transition:color .15s;
}
.search-clear:hover{ color:var(--red); }

/* ---------- Year filter tabs ---------- */
.filter-bar{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  padding:0 0 14px;
  align-items:center;
}
.filter-label{
  font-family:'IBM Plex Mono', monospace;
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.08em;
  color:var(--ink-soft);
  margin-right:4px;
}
.filter-pill{
  font-family:'IBM Plex Mono', monospace;
  font-size:12px;
  padding:5px 14px;
  border:1px solid var(--paper-line);
  border-radius:20px;
  background:var(--card);
  color:var(--ink-soft);
  cursor:pointer;
  transition:all .15s ease;
  user-select:none;
}
.filter-pill:hover{ border-color:var(--ink-soft); color:var(--ink); }
.filter-pill.active{
  background:var(--ink);
  color:var(--paper);
  border-color:var(--ink);
}
.filter-pill.all-pill.active{
  background:var(--red);
  border-color:var(--red);
}

/* ---------- Dark mode toggle ---------- */
.theme-toggle{
  position:absolute;
  right:28px; top:30px;
  background:var(--card);
  border:1px solid var(--paper-line);
  border-radius:20px;
  padding:5px 14px;
  cursor:pointer;
  font-family:'IBM Plex Mono', monospace;
  font-size:12px;
  color:var(--ink-soft);
  display:flex;
  align-items:center;
  gap:6px;
  transition:all .15s ease;
}
.theme-toggle:hover{ border-color:var(--ink-soft); color:var(--ink); }
.theme-toggle svg{ width:14px; height:14px; }
[data-theme="dark"] .theme-toggle .icon-sun{ display:inline; }
[data-theme="dark"] .theme-toggle .icon-moon{ display:none; }
.theme-toggle .icon-sun{ display:none; }
.theme-toggle .icon-moon{ display:inline; }

/* ---------- Love button ---------- */
.love-btn{
  position:absolute;
  right:150px; top:30px;
  background:var(--card);
  border:1px solid var(--paper-line);
  border-radius:20px;
  padding:5px 12px;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:5px;
  transition:all .15s ease;
}
.love-btn:hover{ border-color:var(--red); transform:scale(1.05); }
.love-btn:active{ transform:scale(0.95); }
.love-emoji{ font-size:16px; line-height:1; }
.love-count{
  font-family:'IBM Plex Mono', monospace;
  font-size:12px;
  font-weight:600;
  color:var(--red);
}
@keyframes lovePulse{
  0%{ transform:scale(1); }
  50%{ transform:scale(1.3); }
  100%{ transform:scale(1); }
}
.love-btn.pulse .love-emoji{ animation:lovePulse .3s ease; }

.install-btn{
  position:absolute;
  right:28px; top:30px;
  background:var(--card);
  border:1px solid var(--paper-line);
  border-radius:20px;
  padding:5px 12px;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:5px;
  font-family:'IBM Plex Mono', monospace;
  font-size:12px;
  font-weight:600;
  color:var(--ink);
  transition:all .15s ease;
}
.install-btn:hover{ border-color:var(--red); transform:scale(1.05); }
.install-btn:active{ transform:scale(0.95); }

/* ---------- Love overlay ---------- */
.love-overlay{
  position:fixed; inset:0;
  background:rgba(178,58,46,.92);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:100;
  overflow:hidden;
  cursor:pointer;
}
.love-overlay.active{ display:flex; }
.love-overlay .big-love{
  font-size:clamp(4rem, 12vw, 8rem);
  animation:lovePopIn .5s cubic-bezier(.17,.89,.32,1.28);
  z-index:101;
  text-shadow:0 4px 30px rgba(0,0,0,.3);
}
@keyframes lovePopIn{
  0%{ transform:scale(0) rotate(-10deg); opacity:0; }
  100%{ transform:scale(1) rotate(0deg); opacity:1; }
}
@keyframes floatHeart{
  0%{ transform:translateY(0) rotate(0deg) scale(1); opacity:1; }
  100%{ transform:translateY(-100vh) rotate(40deg) scale(.4); opacity:0; }
}
.floating-heart{
  position:absolute;
  font-size:2rem;
  bottom:-60px;
  animation:floatHeart var(--dur, 3s) ease-out forwards;
  animation-delay:var(--delay, 0s);
  opacity:0;
}

@media (max-width:720px){
  .theme-toggle{ right:auto; left:28px; top:auto; bottom:20px; }
  .love-btn{ right:auto; left:150px; top:auto; bottom:20px; }
}

/* ---------- Subject card grid (list view) ---------- */
.subject-cards{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(280px, 1fr));
  gap:18px;
  padding:40px 0;
}
.subject-card{
  position:relative;
  background:var(--card);
  border:1px solid var(--paper-line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:28px 24px 24px;
  cursor:pointer;
  transition:transform .18s ease, box-shadow .18s ease;
  text-decoration:none;
  color:var(--ink);
  display:flex;
  flex-direction:column;
  gap:10px;
}
.subject-card:hover{
  transform:translateY(-4px) rotate(-.3deg);
  box-shadow:0 14px 28px -14px rgba(24,35,56,.35);
}
.subject-card::before{
  content:"";
  position:absolute;
  left:0; top:0; bottom:0;
  width:5px;
  border-radius:var(--radius) 0 0 var(--radius);
}
.subject-card-num{
  font-family:'IBM Plex Mono', monospace;
  font-size:12px;
  color:var(--ink-soft);
}
.subject-card h3{
  font-family:'Fraunces', serif;
  font-weight:600;
  font-size:1.4rem;
  margin:0;
}
.subject-card-count{
  font-family:'IBM Plex Mono', monospace;
  font-size:12px;
  color:var(--ink-soft);
}
.subject-card-arrow{
  margin-top:auto;
  font-size:13px;
  font-weight:500;
  color:var(--red);
  display:flex;
  align-items:center;
  gap:6px;
}

/* ---------- Back button ---------- */
.back-btn{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-family:'IBM Plex Mono', monospace;
  font-size:13px;
  color:var(--ink-soft);
  background:none;
  border:1px solid var(--paper-line);
  border-radius:20px;
  padding:6px 16px;
  cursor:pointer;
  margin:24px 0 0;
  transition:all .15s ease;
}
.back-btn:hover{ border-color:var(--ink); color:var(--ink); }

/* ---------- Subject sections ---------- */
section.subject{
  padding:64px 0 20px;
  border-bottom:1px solid var(--paper-line);
}
.subject-head{
  display:flex;
  align-items:baseline;
  gap:18px;
  margin-bottom:8px;
}
.subject-num{
  font-family:'IBM Plex Mono', monospace;
  font-size:13px;
  color:var(--ink-soft);
}
h2.subject-title{
  font-family:'Fraunces', serif;
  font-weight:600;
  font-size:1.9rem;
  margin:0;
}
.subject-short{
  font-family:'IBM Plex Mono', monospace;
  font-size:12px;
  padding:3px 9px;
  border:1px solid currentColor;
  border-radius:20px;
}

/* ---------- Booklet grid ---------- */
.grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(190px, 1fr));
  gap:16px;
  margin:28px 0 12px;
}
.booklet{
  position:relative;
  background:var(--card);
  border:1px solid var(--paper-line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  text-decoration:none;
  color:var(--ink);
  display:flex;
  flex-direction:column;
  overflow:hidden;
  transition:transform .18s ease, box-shadow .18s ease;
}
.booklet::before{
  /* stapled edge */
  content:"";
  position:absolute;
  left:0; top:0; bottom:0;
  width:5px;
  background:repeating-linear-gradient(
    to bottom, var(--ink-soft) 0 3px, transparent 3px 9px
  );
  opacity:.35;
  z-index:1;
}
.booklet::after{
  /* corner fold */
  content:"";
  position:absolute;
  top:0; right:0;
  width:0; height:0;
  border-style:solid;
  border-width:0 18px 18px 0;
  border-color:transparent var(--paper) transparent transparent;
  filter:drop-shadow(-1px 1px 1px rgba(0,0,0,.08));
  pointer-events:none;
}
.booklet:hover{
  transform:translateY(-4px) rotate(-.4deg);
  box-shadow:0 14px 28px -14px rgba(24,35,56,.35);
}
.new-badge{
  position:absolute;
  top:10px; right:10px;
  background:var(--red);
  color:#fff;
  font-family:'IBM Plex Mono', monospace;
  font-size:9px;
  font-weight:600;
  letter-spacing:.08em;
  text-transform:uppercase;
  padding:3px 7px;
  border-radius:3px;
  z-index:2;
  line-height:1;
}
.booklet-view{
  display:flex;
  flex-direction:column;
  gap:10px;
  padding:18px 16px 16px;
  text-decoration:none;
  color:inherit;
  flex:1;
}
.booklet-view .year{
  font-family:'Fraunces', serif;
  font-weight:700;
  font-size:1.7rem;
}
.booklet-view .exam-tag{
  font-family:'IBM Plex Mono', monospace;
  font-size:11px;
  color:var(--ink-soft);
  text-transform:uppercase;
  letter-spacing:.05em;
}
.booklet-view .kind{
  margin-top:auto;
  font-size:12px;
  color:var(--red);
  font-weight:500;
  display:flex;
  align-items:center;
  gap:6px;
}
.booklet-dl{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:5px;
  padding:9px 12px;
  font-size:12px;
  font-weight:500;
  font-family:'IBM Plex Mono', monospace;
  text-decoration:none;
  color:var(--ink-soft);
  background:var(--paper);
  border-top:1px solid var(--paper-line);
  transition:background .15s ease, color .15s ease;
}
.booklet-dl svg{
  width:13px;
  height:13px;
  flex-shrink:0;
}
.booklet-dl:hover{
  background:var(--ink);
  color:var(--paper);
}

/* ---------- Important-questions panel ---------- */
.important{
  position:relative;
  background:var(--important-bg);
  border:1px solid var(--paper-line);
  border-left:3px solid var(--red);
  border-radius:var(--radius);
  padding:18px 20px 14px;
  margin:26px 0 30px;
}
.important-head{
  display:flex;
  align-items:center;
  gap:8px;
  font-family:'IBM Plex Mono', monospace;
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.08em;
  color:var(--red);
  margin-bottom:12px;
}
.important-head svg{ width:14px; height:14px; flex-shrink:0; }
.important ol{
  margin:0;
  padding:0 0 0 1.35em;
  display:grid;
  gap:9px;
}
.important li{
  font-size:14.5px;
  line-height:1.5;
  color:var(--ink);
}
.important li::marker{
  font-family:'IBM Plex Mono', monospace;
  font-weight:500;
  color:var(--red);
}
.important .years{
  display:inline-flex;
  gap:5px;
  margin-left:8px;
  vertical-align:middle;
}
.important .years span{
  font-family:'IBM Plex Mono', monospace;
  font-size:10px;
  padding:1px 6px;
  border-radius:9px;
  background:var(--paper);
  border:1px solid var(--paper-line);
  color:var(--ink-soft);
  white-space:nowrap;
}
.important .years span.hot{
  background:var(--red);
  border-color:var(--red);
  color:#fff;
}

.empty{
  border:1px dashed var(--paper-line);
  border-radius:var(--radius);
  padding:22px 20px;
  color:var(--ink-soft);
  font-size:14px;
  line-height:1.65;
  background:repeating-linear-gradient(
    -45deg, transparent 0 10px, rgba(0,0,0,.02) 10px 20px
  );
}
.empty code{
  font-family:'IBM Plex Mono', monospace;
  background:var(--code-bg);
  border:1px solid var(--paper-line);
  padding:1px 6px;
  border-radius:3px;
}

/* ---------- Footer ---------- */
footer{
  padding:40px 0 60px;
  color:var(--ink-soft);
  font-size:13px;
  font-family:'IBM Plex Mono', monospace;
}
.footer-inner{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:12px;
}
.footer-text{
  font-size:12px;
  color:var(--ink-soft);
}
.visit-counter{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-size:11px;
  color:var(--ink-soft);
  background:var(--card);
  border:1px solid var(--paper-line);
  padding:5px 10px 5px 8px;
  border-radius:20px;
  width:fit-content;
}
.visit-counter svg{ color:var(--red); flex-shrink:0; }
.visit-counter span{ font-size:11px; letter-spacing:.04em; }
.tally-counter{
  display:inline-flex;
  gap:2px;
  margin-left:2px;
}
.tally-digit{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:18px;
  height:22px;
  background:var(--ink);
  color:var(--paper);
  font-family:'IBM Plex Mono', monospace;
  font-size:13px;
  font-weight:600;
  border-radius:3px;
  line-height:1;
}

/* ---------- Lightbox for images ---------- */
.lightbox{
  position:fixed; inset:0;
  background:rgba(15,20,30,.88);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:50;
  padding:30px;
}
.lightbox.open{ display:flex; }
.lightbox img{
  max-width:92vw;
  max-height:88vh;
  border-radius:2px;
  box-shadow:0 20px 60px rgba(0,0,0,.5);
}
.lightbox .close{
  position:absolute;
  top:22px; right:28px;
  color:#eee;
  font-family:'IBM Plex Mono', monospace;
  font-size:13px;
  cursor:pointer;
  border:1px solid rgba(255,255,255,.4);
  padding:6px 12px;
  border-radius:20px;
}

/* ---------- Page transitions ---------- */
.page-exit{ animation: fadeOut .25s ease forwards; }
@keyframes fadeOut{ to{ opacity:0; transform:translateY(-8px); } }

body{ animation: fadeIn .3s ease; }
@keyframes fadeIn{ from{ opacity:0; transform:translateY(8px); } to{ opacity:1; transform:none; } }

/* ---------- Reveal on scroll ---------- */
.subject{ opacity:0; transform:translateY(14px); transition:opacity .5s ease, transform .5s ease; }
.subject.visible{ opacity:1; transform:none; }

@media (max-width:480px){
  .subject-cards{
    grid-template-columns:1fr;
    gap:12px;
    padding:24px 0;
  }
  .subject-card{ padding:20px 18px 18px; }
  .grid{
    grid-template-columns:1fr 1fr;
    gap:10px;
  }
  .booklet-view{ padding:14px 12px 12px; }
  .booklet-view .year{ font-size:1.3rem; }
  .booklet-dl{ padding:7px 10px; font-size:11px; }
}

@media (prefers-reduced-motion: reduce){
  *{ transition:none !important; scroll-behavior:auto !important; }
}

:focus-visible{
  outline:2px solid var(--red);
  outline-offset:2px;
}

/* ---------- Discussion Section ---------- */
.discussion-section{
  max-width:700px;
  margin:40px auto 0;
  padding:0 0 60px;
}
.discussion-header{
  display:flex;
  align-items:center;
  gap:12px;
  margin-bottom:20px;
  flex-wrap:wrap;
}
.discussion-header h3{
  font-family:Fraunces,serif;
  font-size:1.5rem;
  color:var(--ink);
  margin:0;
}
.discussion-count{
  font-family:'IBM Plex Mono',monospace;
  font-size:12px;
  color:var(--ink-soft);
  background:var(--card);
  border:1px solid var(--paper-line);
  border-radius:12px;
  padding:2px 10px;
}
.discussion-sort{
  margin-left:auto;
  display:flex;
  gap:4px;
}
.sort-btn{
  background:var(--card);
  border:1px solid var(--paper-line);
  border-radius:14px;
  padding:4px 12px;
  font-family:'IBM Plex Mono',monospace;
  font-size:11px;
  color:var(--ink-soft);
  cursor:pointer;
  transition:all .15s ease;
}
.sort-btn:hover{ border-color:var(--ink-soft); }
.sort-btn.active{ background:var(--ink); color:var(--paper); border-color:var(--ink); }

.comment-form{
  background:var(--card);
  border:1px solid var(--paper-line);
  border-radius:12px;
  padding:16px;
  margin-bottom:20px;
  transition:opacity .2s;
}
.comment-name{
  width:100%;
  border:1px solid var(--paper-line);
  border-radius:8px;
  padding:8px 12px;
  font-family:'IBM Plex Mono',monospace;
  font-size:13px;
  background:var(--paper);
  color:var(--ink);
  margin-bottom:8px;
  box-sizing:border-box;
}
.comment-name:focus{ border-color:var(--ink); outline:none; }
.comment-text{
  width:100%;
  border:1px solid var(--paper-line);
  border-radius:8px;
  padding:10px 12px;
  font-family:'IBM Plex Mono',monospace;
  font-size:13px;
  background:var(--paper);
  color:var(--ink);
  resize:vertical;
  min-height:60px;
  box-sizing:border-box;
}
.comment-text:focus{ border-color:var(--ink); outline:none; }
.comment-form-footer{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-top:8px;
}
.comment-char-count{
  font-family:'IBM Plex Mono',monospace;
  font-size:11px;
  color:var(--ink-soft);
}
.comment-submit{
  background:var(--ink);
  color:var(--paper);
  border:none;
  border-radius:8px;
  padding:8px 20px;
  font-family:'IBM Plex Mono',monospace;
  font-size:13px;
  font-weight:600;
  cursor:pointer;
  transition:all .15s ease;
}
.comment-submit:hover{ opacity:.85; }
.comment-submit:disabled{ opacity:.4; cursor:not-allowed; }

.comment-list{ display:flex; flex-direction:column; gap:12px; }

.comment-card{
  background:var(--card);
  border:1px solid var(--paper-line);
  border-radius:12px;
  padding:14px 16px;
}
.comment-card.reply{ margin-left:24px; border-left:3px solid var(--paper-line); }
.comment-card-head{
  display:flex;
  align-items:center;
  gap:8px;
  margin-bottom:6px;
}
.comment-author{
  font-family:'IBM Plex Mono',monospace;
  font-size:13px;
  font-weight:600;
  color:var(--ink);
}
.comment-time{
  font-family:'IBM Plex Mono',monospace;
  font-size:11px;
  color:var(--ink-soft);
}
.comment-body{
  font-size:14px;
  color:var(--ink);
  line-height:1.5;
  margin-bottom:8px;
  word-wrap:break-word;
}
.comment-actions{
  display:flex;
  align-items:center;
  gap:12px;
}
.vote-btn{
  display:flex;
  align-items:center;
  gap:4px;
  background:none;
  border:1px solid var(--paper-line);
  border-radius:14px;
  padding:3px 10px;
  font-family:'IBM Plex Mono',monospace;
  font-size:12px;
  color:var(--ink-soft);
  cursor:pointer;
  transition:all .15s ease;
}
.vote-btn:hover{ border-color:var(--red); color:var(--red); }
.vote-btn.voted{ border-color:var(--red); color:var(--red); background:rgba(230,57,70,.08); }
.reply-btn{
  background:none;
  border:none;
  font-family:'IBM Plex Mono',monospace;
  font-size:12px;
  color:var(--ink-soft);
  cursor:pointer;
  padding:3px 0;
}
.reply-btn:hover{ color:var(--ink); }

.reply-form{
  margin-left:24px;
  margin-top:8px;
  display:flex;
  gap:8px;
}
.reply-form input{
  flex:1;
  border:1px solid var(--paper-line);
  border-radius:8px;
  padding:6px 10px;
  font-family:'IBM Plex Mono',monospace;
  font-size:12px;
  background:var(--paper);
  color:var(--ink);
}
.reply-form input:focus{ border-color:var(--ink); outline:none; }
.reply-form button{
  background:var(--ink);
  color:var(--paper);
  border:none;
  border-radius:8px;
  padding:6px 14px;
  font-family:'IBM Plex Mono',monospace;
  font-size:12px;
  cursor:pointer;
}

.comment-empty{
  text-align:center;
  padding:30px;
  color:var(--ink-soft);
  font-size:14px;
}

.locked-msg{
  text-align:center;
  padding:14px;
  margin-bottom:16px;
  background:var(--card);
  border:1px solid var(--paper-line);
  border-radius:12px;
  color:var(--ink-soft);
  font-family:'IBM Plex Mono',monospace;
  font-size:13px;
}

@media (max-width:480px){
  .discussion-header{ flex-direction:column; align-items:flex-start; }
  .discussion-sort{ margin-left:0; }
  .comment-card.reply{ margin-left:12px; }
  .reply-form{ margin-left:12px; }
}

/* ---------- Routine Button ---------- */
.routine-btn{
  display:inline-flex;align-items:center;gap:5px;
  padding:6px 14px;font-family:'IBM Plex Mono',monospace;font-size:12px;font-weight:500;
  background:var(--ink);color:var(--paper);border:1px solid var(--ink);border-radius:var(--radius);
  cursor:pointer;transition:all .15s ease;
}
.routine-btn:hover{ opacity:.85; }

/* ---------- Routine Modal ---------- */
.routine-modal{
  position:fixed;inset:0;z-index:1000;
  background:rgba(0,0,0,.5);backdrop-filter:blur(4px);
  display:flex;align-items:center;justify-content:center;
  opacity:0;pointer-events:none;transition:opacity .25s ease;
  padding:20px;
}
.routine-modal.open{ opacity:1;pointer-events:auto; }

.routine-dialog{
  background:var(--card);border:1px solid var(--paper-line);border-radius:16px;
  width:100%;max-width:960px;max-height:90vh;overflow:hidden;
  box-shadow:0 20px 60px rgba(0,0,0,.3);
  transform:translateY(12px);transition:transform .25s ease;
}
.routine-modal.open .routine-dialog{ transform:translateY(0); }

.routine-header{
  display:flex;justify-content:space-between;align-items:center;
  padding:16px 20px;border-bottom:1px solid var(--paper-line);
}
.routine-header h3{
  font-family:'Fraunces',serif;font-size:1.2rem;margin:0;
}
.routine-close{
  background:none;border:none;font-size:24px;cursor:pointer;color:var(--ink-soft);
  width:32px;height:32px;display:flex;align-items:center;justify-content:center;
  border-radius:50%;transition:all .15s;
}
.routine-close:hover{ background:var(--paper-line);color:var(--ink); }
.routine-copy{
  font-family:'IBM Plex Mono',monospace;font-size:11px;font-weight:500;
  padding:5px 12px;border-radius:var(--radius);border:1px solid var(--paper-line);
  background:var(--paper);color:var(--ink);cursor:pointer;transition:all .15s;
}
.routine-copy:hover{ background:var(--ink);color:var(--paper);border-color:var(--ink); }

/* ---------- Routine Tabs ---------- */
.routine-tabs{
  display:flex;gap:6px;padding:10px 20px 0;
  border-bottom:1px solid var(--paper-line);
}
.routine-tab-btn{
  font-family:'IBM Plex Mono',monospace;font-size:11px;font-weight:600;
  padding:7px 14px;background:transparent;border:none;
  border-bottom:2px solid transparent;color:var(--ink-soft);
  cursor:pointer;transition:all .15s ease;border-radius:6px 6px 0 0;
}
.routine-tab-btn:hover{ color:var(--ink);background:var(--paper); }
.routine-tab-btn.active{
  color:var(--ink);background:var(--paper);
  border-bottom-color:var(--red);font-weight:700;
}

/* ---------- Exam Routine ---------- */
.routine-exam-head{
  padding:14px 18px;margin-bottom:14px;border-radius:var(--radius);
  background:var(--paper);border:1px solid var(--paper-line);
}
.routine-exam-title{
  font-family:'Fraunces',serif;font-size:1.1rem;font-weight:700;
  margin-bottom:3px;
}
.routine-exam-sub{
  font-family:'IBM Plex Mono',monospace;font-size:11px;color:var(--ink-soft);
}
.routine-exam-note{
  margin-top:6px;font-family:'IBM Plex Mono',monospace;font-size:11px;font-weight:600;
  color:var(--red);
}
.exam-ad-col{
  font-size:11px;color:var(--ink-soft);white-space:nowrap;
}
.routine-exam-table tbody tr.exam-done{ opacity:.45; }
.routine-exam-table .exam-duration{
  font-size:11px;color:var(--ink-soft);white-space:nowrap;
}
.routine-exam-table td .exam-code{ margin-bottom:0; }
.routine-exam-table .routine-subject{ border-radius:8px; }

.routine-body{ padding:16px 20px;overflow-y:auto;max-height:calc(90vh - 60px); }

/* Clock bar */
.routine-clock{
  display:flex;align-items:center;gap:16px;flex-wrap:wrap;
  padding:14px 18px;margin-bottom:14px;border-radius:var(--radius);
  background:var(--paper);border:1px solid var(--paper-line);
}
.routine-clock-time{
  font-family:'IBM Plex Mono',monospace;font-size:28px;font-weight:700;
  color:var(--ink);letter-spacing:-.02em;
  font-variant-numeric:tabular-nums;
}
.routine-clock-date{ display:flex;flex-direction:column;gap:1px; }
.routine-ad-date{
  font-family:'IBM Plex Mono',monospace;font-size:12px;color:var(--ink-soft);
}
.routine-np-date{
  font-size:13px;font-weight:600;color:var(--ink);
}

/* Now bar */
.routine-now-bar{
  padding:14px 18px;margin-bottom:14px;border-radius:12px;
  background:var(--paper);border:2px solid var(--paper-line);
  transition:all .3s ease;overflow:hidden;position:relative;
}
.routine-now-bar.idle{
  opacity:.6;
}
.routine-now-bar.active{
  border-color:var(--sub-color);
  background:var(--sub-light);
  box-shadow:0 2px 20px color-mix(in srgb, var(--sub-color) 15%, transparent);
}
.routine-now-status{
  display:flex;align-items:center;gap:8px;margin-bottom:4px;
}
.routine-now-icon{
  font-size:10px;line-height:1;flex-shrink:0;
}
.routine-now-icon.live{
  color:var(--sub-color);
  animation:livePulse 1.5s ease infinite;
}
@keyframes livePulse{
  0%,100%{ opacity:1; transform:scale(1); }
  50%{ opacity:.5; transform:scale(1.3); }
}
.routine-now-label{
  font-family:'IBM Plex Mono',monospace;font-size:10px;font-weight:700;
  text-transform:uppercase;letter-spacing:.08em;
}
.routine-now-bar.active .routine-now-label{ color:var(--sub-color); }
.routine-now-bar.idle .routine-now-label{ color:var(--ink-soft); }

.routine-now-detail{ margin-bottom:8px; }
.routine-now-subject{
  font-family:'Fraunces',serif;font-size:1.3rem;font-weight:700;
  color:var(--ink);margin-bottom:6px;
}
.routine-now-meta{ display:flex;flex-wrap:wrap;gap:6px;align-items:center; }
.routine-code-tag{
  font-family:'IBM Plex Mono',monospace;font-size:10px;font-weight:700;
  padding:2px 8px;border-radius:4px;letter-spacing:.03em;
}
.routine-now-time{
  font-family:'IBM Plex Mono',monospace;font-size:11px;color:var(--ink-soft);
}
.routine-now-remaining{
  font-family:'IBM Plex Mono',monospace;font-size:11px;font-weight:600;
  color:var(--sub-color);padding:2px 8px;border-radius:4px;
  background:color-mix(in srgb, var(--sub-color) 10%, var(--paper));
}

/* Progress bar */
.routine-progress-track{
  height:4px;border-radius:2px;background:color-mix(in srgb, var(--sub-color) 15%, var(--paper));
  overflow:hidden;
}
.routine-progress-fill{
  height:100%;border-radius:2px;
  transition:width 60s linear;
}

/* Next preview */
.routine-next{
  display:flex;align-items:center;gap:8px;flex-wrap:wrap;
  padding:10px 18px;margin-bottom:14px;border-radius:var(--radius);
  background:var(--paper);border:1px solid var(--paper-line);
  font-family:'IBM Plex Mono',monospace;font-size:12px;
}
.routine-next-label{
  font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;
  color:var(--ink-soft);
}
.routine-next-subject{ font-weight:600; }
.routine-next-time{ color:var(--ink-soft); }

/* Routine table */
.routine-table-wrap{ overflow-x:auto; -webkit-overflow-scrolling:touch; margin:0 -4px; padding:0 4px; }
.routine-table{
  width:100%;border-collapse:separate;border-spacing:0;
  font-family:'IBM Plex Mono',monospace;
}
.routine-table thead th{
  padding:10px 12px 8px;font-size:11px;font-weight:700;
  text-transform:uppercase;letter-spacing:.06em;color:var(--ink-soft);
  text-align:center;white-space:nowrap;
  border-bottom:2px solid var(--paper-line);
}
.routine-table thead th:first-child{
  text-align:left;padding-left:14px;
}
.routine-table thead th span{
  display:block;font-size:9px;font-weight:400;opacity:.5;margin-top:1px;
  text-transform:none;letter-spacing:0;
}
.routine-table tbody tr{ transition:background .2s; }
.routine-table tbody tr.today-row{ background:color-mix(in srgb, var(--red) 4%, transparent); }
.routine-table tbody tr.today-row td:first-child::before{
  content:'';position:absolute;left:0;top:6px;bottom:6px;width:3px;
  border-radius:0 2px 2px 0;background:var(--red);
}
.routine-table td{
  padding:6px 8px;vertical-align:middle;
  border-bottom:1px solid var(--paper-line);
}
.routine-table .day-col{
  font-size:12px;font-weight:700;color:var(--ink-soft);
  text-transform:uppercase;letter-spacing:.05em;
  white-space:nowrap;padding-left:14px;position:relative;
  min-width:44px;
}
.routine-table tbody tr.today-row .day-col{ color:var(--red); }

.routine-cell{ padding:2px 0 !important; }
.routine-subject{
  padding:7px 10px;border-radius:8px;
  background:var(--paper);border:1px solid var(--paper-line);
  transition:all .2s ease;
}
.routine-now .routine-subject{
  background:color-mix(in srgb, var(--red) 5%, var(--paper));
  border-color:color-mix(in srgb, var(--red) 25%, var(--paper-line));
  box-shadow:0 0 0 1px color-mix(in srgb, var(--red) 8%, transparent);
}
.routine-name{ display:block;font-weight:600;margin-bottom:1px;font-size:12px;line-height:1.3; }
.routine-code{ display:block;font-size:10px;margin-bottom:2px;opacity:.7; }
.routine-type{
  display:inline-block;font-size:9px;font-weight:700;text-transform:uppercase;
  letter-spacing:.05em;padding:1px 5px;border-radius:3px;
}
.type-theory{ background:color-mix(in srgb, var(--ink) 8%, var(--paper)); color:var(--ink); }
.type-practical{ background:color-mix(in srgb, #3b9a56 10%, var(--paper)); color:#2a7a42; }

@keyframes cellGlow{
  0%,100%{ box-shadow:0 0 0 0 color-mix(in srgb, var(--red) 20%, transparent); }
  50%{ box-shadow:0 0 0 3px color-mix(in srgb, var(--red) 10%, transparent); }
}

@media (max-width:600px){
  .routine-dialog{ max-width:100%; max-height:95vh; border-radius:12px; }
  .routine-body{ padding:12px; }
  .routine-now-bar{ padding:12px; }
  .routine-clock{ padding:12px; gap:12px; }
  .routine-clock-time{ font-size:22px; }
  .routine-now-subject{ font-size:1.1rem; }
  .routine-now-bar.active .routine-now-meta{ gap:4px; }
  .routine-next{ font-size:11px; padding:8px 12px; }
  .routine-table thead th{ font-size:10px;padding:8px 6px 6px; }
  .routine-table thead th span{ font-size:8px; }
  .routine-table td{ padding:5px 4px; }
  .routine-table .day-col{ font-size:11px;padding-left:8px;min-width:36px; }
  .routine-subject{ padding:5px 7px; }
  .routine-name{ font-size:11px; }
  .routine-code{ font-size:9px; }
  .routine-type{ font-size:8px;padding:1px 4px; }
  .routine-tabs{ padding:8px 12px 0;gap:4px; }
  .routine-tab-btn{ font-size:10px;padding:6px 10px; }
  .routine-exam-head{ padding:12px; }
}

/* ---------- Print ---------- */
@media print{
  @page{ margin:1.5cm; }
  body > *:not(#routineModal){ display:none !important; }
  :root{
    --paper:#ffffff;--ink:#111111;--ink-soft:#555555;
    --paper-line:#dddddd;--card:#ffffff;--red:#b23a2e;
  }
  #routineModal{
    position:static !important;inset:auto !important;
    background:none !important;backdrop-filter:none !important;
    opacity:1 !important;pointer-events:none !important;
    padding:0 !important;display:block !important;
  }
  .routine-dialog{
    width:100% !important;max-width:100% !important;
    max-height:none !important;box-shadow:none !important;
    border:none !important;border-radius:0 !important;
    transform:none !important;overflow:visible !important;
  }
  .routine-header{ padding:0 0 10px;border-bottom:2px solid var(--ink); }
  .routine-header h3{ font-family:Verdana,sans-serif;font-size:18px; }
  .routine-body{ max-height:none !important;overflow:visible !important;padding:14px 0 0; }
  .routine-tabs,.routine-copy,.routine-close,.routine-now-bar,.routine-next{ display:none !important; }

  .routine-table thead{ display:table-header-group; }
  .routine-table tbody tr{ break-inside:avoid; page-break-inside:avoid; }
  .routine-table thead th{ border-bottom:2px solid var(--ink);color:var(--ink); }
  .routine-cell,.routine-table td,.routine-table .day-col{ padding:4px 6px; }
  .routine-subject{
    background:#ffffff !important;border-color:#dddddd !important;
    box-shadow:none !important;border-radius:4px !important;
  }
  .routine-clock,.routine-exam-head{
    background:#ffffff !important;border-color:#dddddd !important;box-shadow:none !important;
  }
  *{ -webkit-print-color-adjust:exact;print-color-adjust:exact; }
}
