/* CRYPTODAY student area: same tokens and title plates as the public home page. */
:root {
  --night: #01060E; --deck: #06101D; --deck-2: #0A1828; --rule: #1A2A40;
  --chrome: #EEF2F7; --chrome-hi: #FFFFFF; --chrome-lo: #9AA5B6; --text: #D3DBE7; --muted: #8F9CB1;
  --gold: #F7B500; --gold-hi: #FFE07A; --gold-deep: #B97F00; --on-gold: #160D00;
  --volt: #2F8CFF; --bull: #1ED67E; --bear: #FF4D63; --glass: rgba(1, 6, 14, 0.88);
  --font-display: "Montserrat", "Arial Black", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Manrope", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: radial-gradient(70% 50% at 100% 0%, rgba(47, 140, 255, 0.07), transparent 70%), var(--night);
  color: var(--text); font-family: var(--font-body); font-size: 1.0625rem; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
a { color: var(--gold-hi); text-underline-offset: 3px; }
a:hover { color: var(--chrome-hi); }
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 3px; border-radius: 6px; }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3 { text-wrap: balance; }
p { margin: 0 0 0.8rem; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap {
  width: 100%; max-width: 1120px; margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
@media (min-width: 720px) { .wrap { padding-left: max(32px, env(safe-area-inset-left, 0px)); padding-right: max(32px, env(safe-area-inset-right, 0px)); } }

.chrome, .gold { -webkit-background-clip: text; background-clip: text; color: transparent; padding-right: 0.08em; }
.chrome { background-image: linear-gradient(180deg, var(--chrome-hi) 0%, var(--chrome) 40%, var(--chrome-lo) 56%, var(--chrome-hi) 100%); }
.gold { background-image: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 52%, var(--gold-deep) 100%); }

/* Header */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--glass); border-bottom: 1px solid var(--rule); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.topbar-in { display: flex; align-items: center; gap: 0.75rem 1rem; min-height: 66px; flex-wrap: wrap; padding-block: 0.5rem; }
.brand { display: inline-flex; align-items: center; gap: 0.65rem; text-decoration: none; margin-right: auto; }
.brand img { width: 40px; height: 40px; filter: drop-shadow(0 0 10px rgba(247, 181, 0, 0.35)); }
.brand-text { display: grid; line-height: 1; }
.brand-name { font-family: var(--font-display); font-weight: 900; font-style: italic; font-size: 1.2rem; }
.brand-sub { font-family: var(--font-display); font-weight: 700; font-size: 0.56rem; letter-spacing: 0.3em; text-transform: uppercase; color: var(--gold); margin-top: 0.3rem; }
.app-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem 0.35rem; }
.app-nav a, .linkish {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 0.7rem; border-radius: 8px;
  color: var(--text); text-decoration: none; font: 600 0.95rem/1 var(--font-body); background: none; border: 0; cursor: pointer;
}
.app-nav a:hover, .linkish:hover { color: var(--gold-hi); }
.app-nav a[aria-current="page"] { color: var(--gold-hi); background: rgba(247, 181, 0, 0.1); }
.inline-form { display: inline; margin: 0; }

.app-main { flex: 1; padding-block: clamp(1.75rem, 5vw, 3.5rem) 3rem; }
.app-foot { border-top: 1px solid var(--rule); background: var(--deck); padding-block: 1.25rem; font-size: 0.85rem; color: var(--muted); }
.app-foot p { margin: 0; }

/* Title plate from the posters */
.plate {
  display: inline-flex; margin: 0 0 1.25rem 0.3em; padding: 0.45em 1em;
  font-family: var(--font-display); font-weight: 900; font-style: italic; text-transform: uppercase;
  font-size: clamp(1.45rem, 5.5vw, 2.3rem); line-height: 1;
  border: 2px solid transparent; border-radius: 12px; transform: skewX(-14deg);
  background: linear-gradient(var(--deck), var(--deck)) padding-box,
    linear-gradient(100deg, var(--gold-hi) 0%, var(--gold) 24%, var(--rule) 50%, var(--rule) 62%, var(--volt) 100%) border-box;
  box-shadow: -8px -6px 26px -12px var(--gold), 10px 8px 28px -14px var(--volt);
}
.plate-in { display: inline-flex; gap: 0.3em; transform: skewX(14deg); white-space: nowrap; }

.lead { font-size: 1.12rem; color: var(--chrome); max-width: 40em; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.mono { font-family: var(--font-mono); font-size: 0.92rem; letter-spacing: 0.02em; }
.page-head { margin-bottom: 1.75rem; }
.crumb { color: var(--muted); font-size: 0.92rem; margin-bottom: 0.4rem; }
.crumb a { color: var(--muted); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em; min-height: 48px; padding: 0.65em 1.4em;
  border-radius: 12px; border: 1.5px solid transparent; cursor: pointer; text-decoration: none;
  font-family: var(--font-display); font-weight: 800; font-style: italic; font-size: 0.92rem; letter-spacing: 0.05em; text-transform: uppercase;
}
.btn-gold { color: var(--on-gold); background: linear-gradient(180deg, var(--gold-hi), var(--gold) 48%, var(--gold-deep)); box-shadow: 0 8px 26px -12px var(--gold); }
.btn-gold:hover { color: var(--on-gold); filter: brightness(1.06); }
.btn-ghost { color: var(--chrome); border-color: var(--chrome-lo); background: transparent; }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold-hi); }
.btn-sm { min-height: 38px; padding: 0.35em 0.9em; font-size: 0.78rem; }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-tg { color: var(--chrome-hi); border-color: var(--volt); background: rgba(47, 140, 255, 0.14); }
.btn-tg:hover { color: var(--chrome-hi); background: rgba(47, 140, 255, 0.26); }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0 0 1rem; }

/* Cards, notices, forms */
.card { background: var(--deck); border: 1px solid var(--rule); border-radius: 18px; padding: clamp(1.2rem, 3vw, 1.75rem); min-width: 0; }
.notice { padding: 0.85rem 1rem; border-radius: 12px; border: 1px solid; margin: 0 0 1.25rem; max-width: 46rem; }
.notice.ok { border-color: rgba(30, 214, 126, 0.45); background: rgba(30, 214, 126, 0.08); color: var(--chrome); }
.notice.err { border-color: rgba(255, 77, 99, 0.5); background: rgba(255, 77, 99, 0.09); color: var(--chrome); }
.notice.warn { border-color: rgba(247, 181, 0, 0.5); background: rgba(247, 181, 0, 0.08); color: var(--chrome); }
.notice p:last-child { margin-bottom: 0; }
.result .temp { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.result code { font-family: var(--font-mono); font-size: 1.15rem; color: var(--gold-hi); background: var(--night); padding: 0.3rem 0.6rem; border-radius: 8px; border: 1px solid var(--rule); }

.auth { max-width: 32rem; }
.auth.wide { max-width: 38rem; }
.form { display: grid; gap: 1.05rem; }
.field { display: grid; gap: 0.35rem; min-width: 0; }
.field label { font-weight: 700; font-size: 0.95rem; color: var(--chrome); }
.field small { color: var(--muted); font-size: 0.85rem; line-height: 1.45; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 50px; padding: 0.7rem 0.9rem; border-radius: 10px; border: 1px solid var(--rule);
  background: var(--night); color: var(--chrome); font: inherit;
}
.field input[type="file"] { padding: 0.65rem; min-height: auto; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(247, 181, 0, 0.22); }
.check { display: flex; gap: 0.7rem; align-items: flex-start; font-size: 0.95rem; line-height: 1.45; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 0.1rem; accent-color: var(--gold); flex: none; }
.form .btn { justify-self: start; }
.form-links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; margin: 0; font-size: 0.95rem; }
.inline-grid { display: grid; gap: 1rem; align-items: end; }
@media (min-width: 760px) { .inline-grid { grid-template-columns: 1fr 1fr auto; } .inline-grid > .btn { margin-bottom: 1px; } }
#lesson-upload .inline-grid { grid-template-columns: 1fr; }
@media (min-width: 760px) { #lesson-upload .inline-grid { grid-template-columns: 1.1fr 0.6fr 1.8fr; } }

/* Lessons dashboard */
.learn-grid { display: grid; gap: 1.5rem; }
@media (min-width: 940px) { .learn-grid { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; } }
.topics { display: grid; gap: 1rem; min-width: 0; }
.topic-block { background: var(--deck); border: 1px solid var(--rule); border-radius: 16px; padding: 1.1rem 1.2rem; }
.topic-head { display: flex; align-items: center; gap: 0.75rem; margin: 0 0 0.6rem; font-family: var(--font-display); font-weight: 800; font-style: italic; text-transform: uppercase; font-size: 1.05rem; color: var(--chrome); }
.topic-no { font-family: var(--font-mono); font-style: normal; font-size: 0.8rem; color: var(--on-gold); background: linear-gradient(180deg, var(--gold-hi), var(--gold)); border-radius: 6px; padding: 0.2rem 0.45rem; }
.lesson-list { list-style: none; margin: 0; padding: 0; }
.lesson-list li + li { border-top: 1px solid var(--rule); }
.lesson-list a { display: flex; align-items: baseline; gap: 0.75rem; padding: 0.75rem 0.2rem; color: var(--text); text-decoration: none; font-weight: 600; }
.lesson-list a:hover .l-title { color: var(--gold-hi); }
.lesson-list .l-title { flex: 1; min-width: 0; }
.lesson-list .l-pages { font-weight: 500; font-size: 0.9rem; white-space: nowrap; }
.l-week { flex: none; font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; color: var(--gold-hi); border: 1px solid rgba(247, 181, 0, 0.45); border-radius: 6px; padding: 0.15rem 0.4rem; white-space: nowrap; }
.topic-note { margin: -0.2rem 0 0.5rem; font-size: 0.92rem; }

/* The three parts of the course: Course Foundations, PDF Lessons, E-books */
.part-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; margin: 0 0 1.5rem; }
.part-tab {
  display: grid; align-content: start; gap: 0.3rem; min-width: 0; padding: 0.85rem 0.9rem; border-radius: 14px;
  background: var(--deck); border: 1.5px solid var(--rule); color: var(--text); text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.part-tab:hover { border-color: rgba(247, 181, 0, 0.55); color: var(--text); }
.part-tab[aria-current="page"] {
  border-color: var(--gold); background: linear-gradient(180deg, rgba(247, 181, 0, 0.14), rgba(247, 181, 0, 0.03)), var(--deck);
  box-shadow: 0 10px 28px -18px var(--gold);
}
.part-no { justify-self: start; font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600; color: var(--on-gold); background: linear-gradient(180deg, var(--gold-hi), var(--gold)); border-radius: 6px; padding: 0.15rem 0.4rem; }
.part-tab:not([aria-current="page"]) .part-no { color: var(--gold-hi); background: transparent; border: 1px solid rgba(247, 181, 0, 0.45); }
.part-name { font-family: var(--font-display); font-weight: 800; font-style: italic; text-transform: uppercase; font-size: 0.98rem; line-height: 1.2; color: var(--chrome); }
.part-tab[aria-current="page"] .part-name { color: var(--gold-hi); }
.part-count { font-size: 0.85rem; color: var(--muted); }
/* Phones: the three parts stack as full-width rows: number, name, count */
@media (max-width: 640px) {
  .part-tabs { grid-template-columns: 1fr; gap: 0.45rem; }
  .part-tab { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0.7rem; min-height: 52px; padding: 0.6rem 0.85rem; border-radius: 12px; }
  .part-count { white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) { .part-tab { transition: none; } }
.side-stack { display: grid; gap: 1rem; align-content: start; }
.empty { margin: 0; font-size: 0.95rem; }
.side { display: grid; gap: 0.6rem; }
.side-title { margin: 0 0 0.6rem; font-family: var(--font-display); font-weight: 800; font-style: italic; text-transform: uppercase; font-size: 1.05rem; color: var(--chrome); }
.side .btn { justify-self: start; }

/* Lesson viewer */
.lesson-title { margin: 0; font-family: var(--font-display); font-weight: 900; font-style: italic; text-transform: uppercase; font-size: clamp(1.4rem, 4.5vw, 2.2rem); line-height: 1.1; color: var(--chrome); }
.viewer { display: grid; gap: 1.25rem; max-width: 1100px; margin-inline: auto; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.page { margin: 0; aspect-ratio: 1 / 1.414; background: var(--deck-2); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; position: relative; }
.page canvas { display: block; width: 100%; height: 100%; }
.page figcaption { position: absolute; right: 0.6rem; bottom: 0.5rem; font-size: 0.78rem; color: var(--muted); background: rgba(1, 6, 14, 0.75); padding: 0.15rem 0.5rem; border-radius: 6px; }
.page[data-state="failed"] { cursor: pointer; display: grid; place-items: center; }
.page[data-state="failed"] figcaption { position: static; color: var(--chrome); font-size: 1rem; background: none; }
@media print { .no-print main, .no-print .viewer { display: none !important; } }

/* Community chat */
.chat { display: grid; gap: 0.9rem; padding: 0; overflow: hidden; }
.chat-bar { display: flex; justify-content: space-between; gap: 1rem; padding: 0.85rem 1.2rem; border-bottom: 1px solid var(--rule); font-size: 0.92rem; }
.chat-state { font-weight: 700; color: var(--muted); }
.chat-state[data-state="ok"] { color: var(--bull); }
.chat-state[data-state="warn"] { color: var(--gold-hi); }
.chat-state[data-state="off"] { color: var(--bear); }
.chat-log { list-style: none; margin: 0; padding: 0.25rem 1.2rem; height: min(58vh, 560px); overflow-y: auto; display: flex; flex-direction: column; gap: 0.7rem; overscroll-behavior: contain; }
.chat-empty { color: var(--muted); margin: auto; text-align: center; }
.msg { max-width: min(42rem, 92%); background: var(--deck-2); border: 1px solid var(--rule); border-radius: 14px 14px 14px 4px; padding: 0.6rem 0.85rem; }
.msg.mine { align-self: flex-end; border-radius: 14px 14px 4px 14px; border-color: rgba(247, 181, 0, 0.35); background: rgba(247, 181, 0, 0.07); }
.msg.staff { border-color: rgba(47, 140, 255, 0.5); }
.msg-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.6rem; font-size: 0.82rem; color: var(--muted); }
.msg-nick { font-weight: 800; color: var(--gold-hi); font-size: 0.9rem; }
.msg-del { margin-left: auto; background: none; border: 0; color: var(--muted); font: inherit; font-size: 0.8rem; cursor: pointer; text-decoration: underline; padding: 0.2rem; }
.msg-del:hover { color: var(--bear); }
.msg-body { margin: 0.25rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--chrome); }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 0.6rem; padding: 0 1.2rem; align-items: end; }
.chat-form textarea { width: 100%; min-height: 52px; max-height: 160px; resize: vertical; padding: 0.7rem 0.9rem; border-radius: 12px; border: 1px solid var(--rule); background: var(--night); color: var(--chrome); font: inherit; }
.chat-form textarea:focus { outline: none; border-color: var(--gold); }
.chat-rules { padding: 0 1.2rem 1rem; margin: 0; }

/* Account */
.account-grid { display: grid; gap: 1.25rem; }
@media (min-width: 900px) { .account-grid { grid-template-columns: 1fr 1fr; align-items: start; } }
.details { margin: 0 0 1.25rem; display: grid; gap: 0.75rem; }
.details div { display: grid; gap: 0.15rem; }
.details dt { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.details dd { margin: 0; color: var(--chrome); font-weight: 600; overflow-wrap: anywhere; }
.tag { display: inline-block; font: 700 0.7rem/1 var(--font-body); letter-spacing: 0.06em; text-transform: uppercase; padding: 0.3rem 0.5rem; border-radius: 6px; background: rgba(143, 156, 177, 0.15); color: var(--muted); vertical-align: middle; }
.tag-public { background: rgba(247, 181, 0, 0.14); color: var(--gold-hi); }

/* Admin */
.subnav { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.subnav a { padding: 0.45rem 0.9rem; border-radius: 999px; border: 1px solid var(--rule); color: var(--text); text-decoration: none; font-weight: 600; font-size: 0.92rem; }
.subnav a:hover { border-color: var(--gold); color: var(--gold-hi); }
.admin-sec { margin-top: 2.5rem; display: grid; gap: 1rem; scroll-margin-top: 90px; }
.sec-title { margin: 0; font-family: var(--font-display); font-weight: 900; font-style: italic; text-transform: uppercase; font-size: 1.35rem; color: var(--chrome); }
.admin-sec > .muted { margin: -0.4rem 0 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: 14px; background: var(--deck); }
.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table th { text-align: left; font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding: 0.8rem 1rem; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--rule); vertical-align: middle; overflow-wrap: anywhere; }
.table tr:last-child td { border-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.actions form { margin: 0; }
.status { display: inline-block; padding: 0.25rem 0.55rem; border-radius: 999px; font-size: 0.78rem; font-weight: 700; background: rgba(143, 156, 177, 0.15); color: var(--muted); white-space: nowrap; }
.status.active, .status.published { background: rgba(30, 214, 126, 0.14); color: var(--bull); }
.status.disabled { background: rgba(255, 77, 99, 0.14); color: var(--bear); }
@media (max-width: 760px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 0.6rem 0; border-bottom: 1px solid var(--rule); }
  .table tr:last-child { border-bottom: 0; }
  .table td { border: 0; padding: 0.3rem 1rem; }
  .table td[data-label]:not(.actions)::before { content: attr(data-label); display: block; font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
}
.progress { display: grid; gap: 0.4rem; }
.progress .bar { height: 10px; border-radius: 999px; background: var(--night); border: 1px solid var(--rule); overflow: hidden; }
.progress .bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-deep), var(--gold), var(--gold-hi)); transition: width 0.3s ease; }

@media (prefers-reduced-motion: reduce) { .progress .bar span { transition: none; } }
