/* ═══════════════════════════════════════════════════════════════
   StudyAgent — "Smart Notebook" design system
   Paper ground · ink type · highlighter actions · sticker tabs
   Hard offset shadows, zero gradients, zero AI-app glow.
   ═══════════════════════════════════════════════════════════════ */
:root {
  --paper: #f7f2e7;      /* warm paper ground */
  --card: #fffdf6;       /* card surface */
  --ink: #191512;        /* ink */
  --mut: #7a7060;        /* pencil gray */
  --line: #191512;       /* borders are ink */
  --hi: #ffd60a;         /* highlighter yellow — the action color */
  --hi-soft: #fff3b0;
  --ok: #1a7f4e; --warn: #b97c0b; --bad: #c23b3b;
  --shadow: 3px 3px 0 var(--ink);
  --shadow-lg: 5px 5px 0 var(--ink);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow-x: hidden; }
body { background: var(--paper); color: var(--ink); font-family: 'Space Grotesk', system-ui, sans-serif; font-size: 15px; }
:root { color-scheme: light; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
::selection { background: var(--hi); }

h1, h2, .ac-name, .agent-title-font, .dl-head h2, .modal-head h2, .auth-card h1, .side-head b, .stat-tile .v {
  font-family: 'Fraunces', Georgia, serif;
}

input, select, textarea {
  font: inherit; font-size: 16px; line-height: 1.4; color: var(--ink); background: var(--card);
  border: 2px solid var(--ink); border-radius: 10px; padding: 10px 12px; width: 100%;
  min-width: 0;
}
input::placeholder, textarea::placeholder { color: #a89e8c; }
input:focus, select:focus, textarea:focus { outline: none; box-shadow: var(--shadow); transform: translate(-1px,-1px); }
textarea { resize: vertical; }
input, select, textarea, .btn { transition: transform .1s, box-shadow .1s; }

.err { color: var(--bad); font-size: 13px; margin: 6px 0; font-weight: 500; }
.hint { color: var(--mut); font-size: 13px; margin-bottom: 10px; line-height: 1.5; }
.center { text-align: center; margin: 8px 0; }
.center-block { display: block; margin: 10px auto 0; }
.mini-link { color: var(--mut); font-size: 12px; text-decoration: underline; text-underline-offset: 2px; }
.mini-link:hover { color: var(--ink); }

/* Buttons: physical objects. Lift on hover, press on click. */
.btn { border: 2px solid var(--ink); border-radius: 10px; padding: 9px 16px; font-weight: 600;
  background: var(--card); box-shadow: var(--shadow); }
.btn:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary { background: var(--hi); color: var(--ink); }
.btn.ghost { background: var(--card); }
.btn.full { width: 100%; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: default; transform: none; box-shadow: var(--shadow); }

/* ── Auth ── */
.auth { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: calc(20px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 15% 20%, rgba(255,214,10,.18), transparent 42%),
    radial-gradient(circle at 85% 80%, rgba(255,144,187,.12), transparent 40%),
    var(--paper); }
.auth-card { width: 100%; max-width: 370px; text-align: center; }
.logo-big { font-size: 54px; margin-bottom: 6px; }
.auth-card h1 { font-size: 40px; font-weight: 900; letter-spacing: -0.5px; }
.auth-card h1 span, .side-head b span {
  background: linear-gradient(transparent 55%, var(--hi) 55%, var(--hi) 92%, transparent 92%);
}
.tag { color: var(--mut); margin: 8px 0 26px; font-size: 15px; }
.auth-form { display: flex; flex-direction: column; gap: 11px; text-align: left;
  background: var(--card); border: 2px solid var(--ink); border-radius: 14px; padding: 20px; box-shadow: var(--shadow-lg); }

/* ── Layout ── */
.app { display: flex; height: 100vh; height: 100dvh; }
.sidebar { width: 264px; background: var(--paper); border-right: 2px solid var(--ink);
  display: flex; flex-direction: column; padding: calc(14px + env(safe-area-inset-top)) 12px calc(14px + env(safe-area-inset-bottom)); gap: 4px; overflow-y: auto; flex-shrink: 0; }
.side-head { display: flex; align-items: center; gap: 8px; padding: 4px 4px 14px; }
.side-head b { font-size: 19px; font-weight: 900; }
.side-head .mini-link { margin-left: auto; }
.logo-sm { font-size: 20px; }
.brand-btn { display: flex; align-items: center; gap: 7px; }
.brand-btn:hover { transform: rotate(-1deg); }
.side-label { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--mut);
  padding: 14px 6px 6px; font-weight: 700; }
.agent-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 10px; border-radius: 10px; font-weight: 500; color: var(--ink); border: 2px solid transparent; }
.agent-row:hover { border-color: var(--ink); background: var(--card); }
.agent-row.active { background: var(--card); border-color: var(--ink); box-shadow: var(--shadow); }
.agent-dot { width: 27px; height: 27px; border-radius: 8px; display: inline-flex; align-items: center;
  justify-content: center; font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
  border: 2px solid var(--ink); text-shadow: 0 1px 0 rgba(0,0,0,.35); }
.hub-dot { background: var(--ink); color: var(--hi); text-shadow: none; }
.agent-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.add-class { margin-top: 10px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--paper); }
.topbar { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  border-bottom: 2px solid var(--ink); background: var(--card); flex-wrap: wrap; }
.menu-btn { display: none; font-size: 20px; }
.top-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex-shrink: 1; overflow: hidden; }
.top-title b { font-size: 17px; font-family: 'Fraunces', Georgia, serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Integrity badges = stickers */
.int-badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px;
  white-space: nowrap; border: 1.5px solid var(--ink); }
.int-open { background: #d9f2e4; color: var(--ok); }
.int-cited { background: #ddeefc; color: #14567e; }
.int-restricted { background: var(--hi-soft); color: var(--warn); }
.int-banned { background: #fadcdc; color: var(--bad); }

.top-tabs { display: flex; gap: 6px; margin-left: auto; flex-shrink: 0; }
.tab { padding: 6px 14px; border-radius: 99px; color: var(--mut); font-weight: 600; font-size: 14px; border: 2px solid transparent; }
.tab:hover { color: var(--ink); }
.tab.active { border-color: var(--ink); color: var(--ink); background: var(--hi); }
.due-count { background: var(--ink); color: var(--hi); border-radius: 99px; font-size: 11px; padding: 1px 7px; }
.top-actions { display: flex; gap: 8px; }

/* ── Home dashboard ── */
.home { flex: 1; overflow-y: auto; padding: 24px 20px; max-width: 980px; width: 100%; margin: 0 auto; }
.home-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat-tile { background: var(--card); border: 2px solid var(--ink); border-radius: 13px; padding: 13px 15px; box-shadow: var(--shadow); }
.stat-tile .v { font-size: 27px; font-weight: 800; }
.stat-tile .v.warn { color: var(--warn); } .stat-tile .v.bad { color: var(--bad); }
.stat-tile .l { font-size: 11px; color: var(--mut); text-transform: uppercase; letter-spacing: .09em; font-weight: 700; margin-top: 2px; }
.home-label { padding-left: 2px; margin-top: 10px; }
.welcome-card { background: var(--hi-soft); border: 2px solid var(--ink); border-radius: 14px; padding: 18px 20px;
  box-shadow: var(--shadow); margin-bottom: 16px; }
.wc-title { font-size: 20px; font-weight: 800; margin-bottom: 6px; }
.wc-body { font-size: 14.5px; line-height: 1.5; margin-bottom: 10px; }
.wc-steps { padding-left: 20px; margin-bottom: 14px; font-size: 14px; line-height: 1.7; }
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.agent-card { text-align: left; background: var(--card); border: 2px solid var(--ink); border-radius: 14px;
  padding: 14px 15px; position: relative; display: block; width: 100%; box-shadow: var(--shadow);
  transition: transform .12s, box-shadow .12s; }
.agent-card:hover { transform: translate(-2px,-2px); box-shadow: var(--shadow-lg); }
.agent-card:active { transform: translate(1px,1px); box-shadow: 2px 2px 0 var(--ink); }
.agent-card.hub-card { background: var(--ink); color: var(--paper); }
.agent-card.hub-card .ac-sub { color: #b9b2a4; }
.agent-card.hub-card .ac-next { background: #2a251f; color: var(--hi); border-color: #2a251f; }
.ac-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ac-name { font-weight: 700; font-size: 16px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-sub { font-size: 12.5px; color: var(--mut); margin-bottom: 9px; }
.ac-next { font-size: 12.5px; background: var(--paper); border: 1.5px dashed rgba(25,21,18,.35); border-radius: 8px; padding: 6px 9px; }
.ac-next.none { color: var(--mut); }
.ac-badges { display: flex; gap: 6px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.ac-due { background: var(--hi); color: var(--ink); border: 1.5px solid var(--ink); font-size: 11px; font-weight: 700; border-radius: 99px; padding: 2px 8px; }
.ac-kill { position: absolute; top: 8px; right: 9px; color: var(--mut); font-size: 13px; padding: 3px 7px; border-radius: 7px; }
.ac-kill:hover { color: var(--bad); background: #fadcdc; }
.week-row { display: flex; align-items: center; gap: 10px; background: var(--card); border: 2px solid var(--ink);
  border-radius: 11px; padding: 9px 13px; margin-bottom: 8px; font-size: 13.5px; width: 100%; text-align: left;
  transition: transform .12s, box-shadow .12s; }
.week-row:hover { transform: translate(-1px,-1px); box-shadow: var(--shadow); }
.week-dot { width: 11px; height: 11px; border-radius: 4px; border: 1.5px solid var(--ink); flex-shrink: 0; }
.week-date { margin-left: auto; color: var(--mut); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ── Chat: a conversation on ruled paper ── */
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-log { flex: 1; overflow-y: auto; padding: 24px 18px; display: flex; flex-direction: column; gap: 14px;
  background-image: repeating-linear-gradient(transparent, transparent 31px, rgba(25,21,18,.055) 31px, rgba(25,21,18,.055) 32px); }
.msg { max-width: 720px; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; font-size: 14.5px; }
.msg.user { align-self: flex-end; background: var(--ink); color: var(--paper);
  padding: 10px 15px; border-radius: 14px 14px 4px 14px; box-shadow: var(--shadow); border: 2px solid var(--ink); }
.msg.agent { align-self: flex-start; background: var(--card); border: 2px solid var(--ink);
  padding: 12px 16px; border-radius: 14px 14px 14px 4px; box-shadow: var(--shadow); }
.msg.agent.thinking { color: var(--mut); font-style: italic; box-shadow: none; border-style: dashed; }
.msg .b { font-weight: 700; background: linear-gradient(transparent 60%, var(--hi) 60%, var(--hi) 95%, transparent 95%); }
.msg.user .b { background: none; color: var(--hi); }
.empty-chat { margin: auto; text-align: center; color: var(--mut); max-width: 440px; line-height: 1.65;
  background: var(--card); border: 2px dashed rgba(25,21,18,.4); border-radius: 16px; padding: 26px 22px; }
.empty-chat .big { font-size: 42px; margin-bottom: 8px; }
.empty-chat b { color: var(--ink); font-family: 'Fraunces', Georgia, serif; font-size: 17px; }
.chips { display: flex; gap: 8px; padding: 10px 18px 10px; flex-wrap: wrap; border-top: 2px solid var(--ink); background: var(--card); }
.chip { border: 1.5px solid var(--ink); border-radius: 99px; padding: 5px 13px; font-size: 13px;
  color: var(--ink); background: var(--paper); font-weight: 500; }
.chip:hover { background: var(--hi); transform: translate(-1px,-1px); box-shadow: 2px 2px 0 var(--ink); }
.composer { display: flex; gap: 10px; padding: 0 18px calc(16px + env(safe-area-inset-bottom)); align-items: flex-end; background: var(--card); }
.composer textarea { border-radius: 12px; max-height: 140px; flex: 1; width: auto; }
.send { width: 46px; height: 46px; border-radius: 12px; font-size: 19px; flex-shrink: 0; font-weight: 800; }

/* ── Deadlines ── */
.deadlines { flex: 1; overflow-y: auto; padding: 22px 18px; max-width: 860px; width: 100%; margin: 0 auto; }
.dl-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.dl-head h2 { font-size: 22px; font-weight: 800; }
.dl-group-label { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--mut);
  font-weight: 800; margin: 20px 0 8px; }
.dl-group-label.overdue { color: var(--bad); }
.dl-row { display: flex; align-items: center; gap: 12px; background: var(--card); border: 2px solid var(--ink);
  border-radius: 12px; padding: 11px 14px; margin-bottom: 9px; box-shadow: var(--shadow); }
.dl-row.done { opacity: .5; box-shadow: none; }
.dl-row.done .dl-title { text-decoration: line-through; text-decoration-thickness: 2px; }
.dl-check { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--ink); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; color: transparent; background: var(--card); }
.dl-check:hover { background: var(--hi-soft); }
.dl-row.done .dl-check { background: var(--hi); color: var(--ink); }
.dl-body { min-width: 0; flex: 1; }
.dl-title { font-weight: 600; font-size: 14px; }
.dl-meta { font-size: 12px; color: var(--mut); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.dl-course-tag { font-weight: 700; }
.dl-type { border: 1.5px solid rgba(25,21,18,.45); border-radius: 99px; padding: 0 8px; }
.dl-del { color: var(--mut); font-size: 13px; padding: 2px 6px; border-radius: 6px; }
.dl-del:hover { color: var(--bad); background: #fadcdc; }

/* Backdrop behind the mobile sidebar (hidden on desktop, where the sidebar is always shown). */
.scrim { display: none; }

/* ── Modals ── */
.overlay { position: fixed; inset: 0; background: rgba(25,21,18,.5); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 20px; overflow-y: auto; }
.modal { background: var(--card); border: 2px solid var(--ink); border-radius: 16px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px; padding: 20px; margin: 30px 0; display: flex; flex-direction: column; gap: 10px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { font-size: 20px; font-weight: 800; }
.x { color: var(--mut); font-size: 15px; padding: 4px 8px; border-radius: 7px; }
.x:hover { color: var(--ink); background: var(--paper); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dropzone { display: block; border: 2px dashed var(--ink); border-radius: 12px; padding: 22px;
  text-align: center; color: var(--mut); cursor: pointer; font-size: 14px; background: var(--paper); }
.dropzone:hover, .dropzone.drag { background: var(--hi-soft); color: var(--ink); }
.ac-deadlines { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.ac-dl { display: flex; gap: 8px; align-items: center; }
.ac-dl input[type=checkbox] { width: auto; accent-color: var(--ink); }
.ac-dl input[type=text] { flex: 2; padding: 7px 10px; font-size: 13px; }
.ac-dl input[type=date] { flex: 1; padding: 7px 10px; font-size: 13px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink);
  color: var(--paper); border-radius: 11px; padding: 11px 18px; border: 2px solid var(--ink);
  font-size: 14px; z-index: 99; box-shadow: var(--shadow); }

/* scrollbars, subtle */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(25,21,18,.25); border-radius: 6px; border: 2px solid var(--paper); }
::-webkit-scrollbar-thumb:hover { background: rgba(25,21,18,.45); }

/* ── Mobile ── */
@media (max-width: 760px) {
  .sidebar { position: fixed; inset: 0 30% 0 0; z-index: 40; transform: translateX(-103%);
    transition: transform .2s; box-shadow: 8px 0 0 rgba(25,21,18,.15); width: 78%; }
  .sidebar.open { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(25,21,18,.35);
    opacity: 0; pointer-events: none; transition: opacity .2s; }
  .sidebar.open + .scrim { opacity: 1; pointer-events: auto; }
  .menu-btn { display: block; }
  .top-title b { font-size: 15px; }
  .tab { padding: 5px 10px; font-size: 13px; }
  .top-actions { width: 100%; order: 9; }
  .top-actions .btn { flex: 1; text-align: center; }
  .msg { max-width: 92%; }
  .home, .deadlines { padding-left: 14px; padding-right: 14px; }
  .modal { max-width: 100%; }
  .overlay { padding: 12px; padding-top: calc(12px + env(safe-area-inset-top)); }
  .grid2 { grid-template-columns: 1fr; }
}

/* ── Pro / paywall ─────────────────────────────────────── */
.pro-btn { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 9px 10px; border-radius: 10px;
  border: 2px solid var(--ink); background: var(--ink); color: var(--paper); font-weight: 600; font-size: 13px; width: 100%; text-align: left; box-shadow: var(--shadow); }
.pro-btn:hover { transform: translate(-1px,-1px); }
.pro-btn.is-pro { background: var(--card); color: var(--ink); cursor: default; box-shadow: none; }
.pro-pill { background: var(--hi); color: var(--ink); font-size: 10px; letter-spacing: .08em; padding: 2px 6px; border-radius: 6px; border: 1.5px solid var(--ink); }
.paywall { max-width: 460px; }
.paywall h2 .hi { background: var(--hi); padding: 0 4px; border-radius: 4px; }
.pro-reason { background: var(--hi); border: 2px solid var(--ink); border-radius: 10px; padding: 9px 12px; font-weight: 600; font-size: 14px; margin-bottom: 12px; }
.pro-feats { list-style: none; margin: 4px 0 14px; display: grid; gap: 8px; }
.pro-feats li { display: grid; gap: 1px; padding-left: 26px; position: relative; font-size: 14px; }
.pro-feats li::before { content: "✓"; position: absolute; left: 0; top: 0; width: 18px; height: 18px; border: 2px solid var(--ink); border-radius: 6px; background: var(--hi); font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.pro-feats span { color: var(--mut); font-size: 12.5px; line-height: 1.4; }
.pro-plans { display: grid; gap: 10px; margin-bottom: 12px; }
.plan { position: relative; text-align: left; display: grid; gap: 2px; padding: 12px 14px; border: 2px solid var(--ink); border-radius: 12px; background: var(--card); box-shadow: var(--shadow); }
.plan b { font-size: 16px; }
.plan span { font-size: 12.5px; color: var(--mut); }
.plan.active { background: var(--hi); }
.plan.active span { color: var(--ink); }
.plan-badge { position: absolute; right: 12px; top: -10px; background: var(--ink); color: var(--paper) !important; font-size: 10px !important; letter-spacing: .06em; padding: 2px 8px; border-radius: 99px; text-transform: uppercase; font-weight: 700; }
.pro-legal { margin-top: 12px; text-align: center; }
.pro-legal p { font-size: 11px; color: var(--mut); line-height: 1.45; margin-top: 6px; }
.pro-legal a { color: var(--ink); text-decoration: underline; }
