:root {
  --ink: #293a53;
  --muted: #64738b;
  --paper: #fff7de;
  --paper-deep: #f7dfaa;
  --line: #c7934f;
  --mint: #55d9b8;
  --mint-deep: #159f86;
  --sky: #8ee2f3;
  --lavender: #bba6ee;
  --coral: #ff9b94;
  --gold: #ffc94d;
  --danger: #b8444d;
  --success: #188960;
  --shadow: 0 16px 40px rgba(46, 38, 53, .25);
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: #382f43 url("assets/magical-library.png") center / cover fixed no-repeat;
  font-family: "Trebuchet MS", Arial, sans-serif;
  line-height: 1.45;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(39, 41, 61, .26);
}

a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: clamp(30px, 4vw, 46px); line-height: 1.08; }
h2 { margin-bottom: 14px; font-size: 23px; }
h3 { margin-bottom: 4px; font-size: 18px; }

.shell {
  width: min(1320px, calc(100% - 28px));
  min-height: calc(100vh - 36px);
  margin: 18px auto;
  padding: 18px;
  border: 4px solid rgba(255, 255, 255, .65);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(119, 225, 239, .95), rgba(194, 247, 218, .96));
  box-shadow: var(--shadow);
}

.app-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr) 185px; gap: 18px; }
.app-layout.teacher-layout, .app-layout.student-layout { grid-template-columns: 190px minmax(0, 1fr); }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  margin-bottom: 12px;
  font-size: 18px;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 44px;
  border: 3px solid #fff;
  border-radius: 15px 15px 18px 18px;
  background: linear-gradient(145deg, #94dffc, #ad92e5);
  color: #fff;
  font-size: 25px;
  box-shadow: 0 5px 0 rgba(62, 88, 137, .26);
}

.sidebar { padding: 4px 0; }
.nav-list { display: grid; gap: 9px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 47px;
  padding: 8px 10px;
  border: 2px solid rgba(71, 128, 140, .18);
  border-radius: 12px;
  background: rgba(255, 255, 255, .48);
  font-weight: 800;
  text-decoration: none;
}
.nav-item.active { background: rgba(255,255,255,.82); box-shadow: 0 4px 0 rgba(45, 114, 125, .18); }
.nav-dot { width: 26px; height: 26px; border-radius: 8px; background: var(--mint); box-shadow: inset 0 -3px rgba(0,0,0,.1); }
.nav-item:nth-child(2) .nav-dot { background: var(--coral); }
.nav-item:nth-child(3) .nav-dot { background: var(--gold); }
.nav-item:nth-child(4) .nav-dot { background: var(--lavender); }

.content { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 74px; margin-bottom: 14px; }
.eyebrow { margin-bottom: 4px; color: #407a8b; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.topbar h1 { font-size: clamp(24px, 3vw, 34px); }
.progress {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 270px;
  padding: 6px 10px;
  border: 3px solid rgba(255,255,255,.8);
  border-radius: 999px;
  background: rgba(255,255,255,.55);
}
.progress-line { height: 9px; flex: 1; border-radius: 99px; background: linear-gradient(90deg, var(--mint) 0 46%, #d5c6ee 46%); box-shadow: inset 0 1px 3px rgba(0,0,0,.2); }
.star { color: #fff4a8; font-size: 22px; line-height: 1; text-shadow: 0 2px #d39436; }

.magic-panel, .panel, .notice {
  border: 4px solid var(--line);
  border-radius: 15px;
  background: var(--paper);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.65), 0 7px 0 rgba(129, 78, 40, .23);
}
.paper-panel { position: relative; padding: 24px; }
.paper-panel::before, .paper-panel::after { content: ""; position: absolute; top: -6px; width: 38px; height: 18px; border-radius: 0 0 18px 18px; background: #6b9b5d; }
.paper-panel::before { left: 20px; } .paper-panel::after { right: 20px; }
.panel, .notice { padding: 20px; }

.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 20px; margin-top: 18px; }
.book-card { display: grid; gap: 8px; text-decoration: none; transition: transform .18s ease; }
.book-card:hover, .book-card:focus-visible { transform: translateY(-7px) rotate(-1deg); }
.cover { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 2 / 3; overflow: hidden; border: 5px solid #f3c26c; border-left-width: 13px; border-radius: 9px 12px 12px 9px; background: linear-gradient(135deg, #67cbe1, #bd8ade 55%, #ffe06a); color: #fff; box-shadow: 0 9px 0 rgba(93, 61, 53, .2), 0 15px 25px rgba(62, 55, 78, .2); text-align: center; font-weight: 800; padding: 14px; }
.cover::after { content: ""; position: absolute; inset: 7px; border: 2px solid rgba(255,255,255,.6); border-radius: 6px; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover.small { width: 62px; min-width: 62px; } .cover.large { width: 155px; min-width: 155px; }
.book-meta h2 { margin-bottom: 1px; font-size: 16px; } .book-meta p, .book-meta span, .muted { margin: 0; color: var(--muted); font-size: 13px; }

.rewards { display: grid; align-content: start; gap: 11px; padding-top: 83px; }
.rewards-card { padding: 13px; border-radius: 14px; background: rgba(255,255,255,.72); box-shadow: 0 5px 0 rgba(50, 133, 121, .16); }
.rewards-card h2 { font-size: 15px; text-align: center; }
.badges { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.badge { display: grid; justify-items: center; gap: 3px; color: #4c6278; font-size: 10px; font-weight: 800; text-align: center; }
.badge-mark { width: 49px; height: 53px; border: 3px solid #e2a335; border-radius: 15px 15px 20px 20px; background: linear-gradient(145deg, #fff080, #ffbe59); box-shadow: 0 3px #cc8631; }

.button { min-height: 42px; padding: 9px 15px; border: 2px solid #2c9f84; border-radius: 999px; background: #fff; color: var(--ink); font: inherit; font-weight: 800; text-decoration: none; cursor: pointer; box-shadow: 0 4px 0 rgba(42, 112, 101, .22); }
.button.primary { border-color: #1b9e71; background: linear-gradient(#79e3aa, #32bf83); color: #fff; box-shadow: 0 5px 0 #198d62; }
.button.secondary, .button.icon-text { border-color: #9a86d0; background: #f9f5ff; }
.button.danger { border-color: #c85d63; background: #fff1f1; color: var(--danger); box-shadow: 0 4px 0 rgba(184, 68, 77, .18); }
.button.big { min-height: 52px; font-size: 17px; } .button:disabled { opacity: .55; cursor: not-allowed; }
.actions, .section-head, .entry-head, .link-row, .form-actions { display: flex; align-items: center; gap: 10px; } .section-head, .entry-head { justify-content: space-between; }

.dashboard { display: grid; grid-template-columns: minmax(300px, .86fr) minmax(0, 1.14fr); gap: 18px; margin: 18px 0; }
.form-grid { display: grid; gap: 13px; }
label, fieldset { display: grid; gap: 6px; color: #4c5b6a; font-size: 14px; font-weight: 800; }
input, textarea { width: 100%; border: 2px solid #baabd8; border-radius: 11px; background: #fffdf8; color: var(--ink); font: inherit; padding: 10px 11px; box-shadow: inset 0 2px 3px rgba(79, 62, 99, .08); }
textarea { resize: vertical; }
.notice.warning, .message.error { color: var(--danger); } .message.success { color: var(--success); } .hidden { display: none !important; }
.admin-list, .entries-list { display: grid; gap: 12px; }
.admin-work { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 12px; padding: 10px; border: 2px solid #e5c987; border-radius: 12px; background: rgba(255,255,255,.64); }
.admin-work.selected { border-color: var(--mint-deep); background: #effff4; }
.admin-work-body { min-width: 0; }
.work-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.work-title-row h3 { margin-bottom: 0; }
.status-pill { display: inline-grid; place-items: center; min-height: 24px; padding: 3px 9px; border: 2px solid #d8b264; border-radius: 999px; background: #fff0bd; color: #75582f; font-size: 12px; font-weight: 800; }
.link-row { align-items: stretch; margin-top: 9px; } .link-row input { min-width: 0; font-size: 13px; }
.work-actions { display: grid; grid-template-columns: repeat(2, minmax(120px, 1fr)); gap: 9px; margin-top: 10px; }
.work-actions .button { width: 100%; min-height: 40px; padding: 8px 10px; white-space: normal; }
.work-hero { display: flex; gap: 22px; align-items: center; margin: 16px 0; padding: 22px; border: 4px solid var(--line); border-radius: 15px; background: var(--paper); box-shadow: inset 0 0 0 3px rgba(255,255,255,.6), 0 7px 0 rgba(129, 78, 40, .23); }
.diary-form { max-width: 900px; }
.help-block { border: 2px dashed #ad9ac9; border-radius: 12px; padding: 11px; background: rgba(255,255,255,.58); } .help-block summary { cursor: pointer; font-weight: 800; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; padding-top: 10px; } .chip { border: 2px solid #e4bd72; border-radius: 999px; background: #fff0b5; padding: 7px 10px; cursor: pointer; }
.memo { margin: 10px 0 0; padding-left: 19px; color: var(--muted); }
.rating-group { border: 2px solid #baabd8; border-radius: 12px; padding: 11px; background: rgba(255,255,255,.7); } .rating-group label { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 400; } .rating-group input { width: auto; }
.entry-card { padding: 16px; border: 2px solid #e5c987; border-radius: 12px; background: rgba(255,255,255,.7); } .entry-head time { color: var(--muted); font-size: 13px; }
dl { display: grid; gap: 4px; margin: 12px 0 0; } dt { color: #8260b7; font-weight: 800; } dd { margin: 0 0 10px; white-space: pre-wrap; } .entry-image img { max-width: min(320px, 100%); margin-top: 12px; border-radius: 8px; }

.answer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.answer-card { display: grid; grid-template-columns: 46px minmax(0, 1fr); align-items: center; gap: 10px; min-height: 86px; padding: 12px; border: 2px solid #e1bf78; border-radius: 13px; background: rgba(255,255,255,.72); color: var(--ink); font: inherit; text-align: left; cursor: pointer; box-shadow: 0 3px 0 rgba(154, 112, 59, .16); transition: transform .16s ease, border-color .16s ease, background .16s ease; }
.answer-card:hover, .answer-card:focus-visible { border-color: var(--mint-deep); background: #f1fff9; outline: none; transform: translateY(-3px); }
.answer-avatar { display: grid; place-items: center; width: 46px; height: 46px; border: 3px solid #fff; border-radius: 50%; background: linear-gradient(145deg, #ffcf70, #ef9ab3); color: #fff; font-size: 21px; font-weight: 800; box-shadow: 0 3px 0 rgba(170, 105, 86, .2); }
.answer-card-copy { display: grid; min-width: 0; gap: 2px; }.answer-card-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.answer-card-copy small { color: var(--muted); font-size: 12px; }.answer-rating { grid-column: 2; color: #8560b5; font-size: 13px; font-weight: 800; }

.entry-dialog { width: min(680px, calc(100% - 28px)); max-height: min(760px, calc(100vh - 34px)); padding: 22px; border: 4px solid var(--line); border-radius: 17px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }.entry-dialog::backdrop { background: rgba(31, 45, 61, .55); backdrop-filter: blur(3px); }.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding-bottom: 13px; border-bottom: 2px dashed #d3b56f; }.dialog-head h2 { margin-bottom: 0; }.entry-date { margin: 14px 0 6px; color: var(--muted); font-size: 13px; }.entry-details { gap: 12px; }.entry-details > div { padding: 12px; border: 1px solid #e8cf93; border-radius: 10px; background: rgba(255,255,255,.62); }.entry-details dd { margin-bottom: 0; }
.teacher-comment-form { display: grid; gap: 10px; margin-top: 16px; padding: 14px; border: 2px dashed #d3b56f; border-radius: 13px; background: rgba(255,255,255,.55); }

.grades-list { display: grid; gap: 13px; margin-top: 16px; }
.grade-card { display: grid; grid-template-columns: minmax(0, 1fr) 76px; gap: 12px 16px; align-items: center; padding: 15px; border: 2px solid #e4bd72; border-radius: 14px; background: rgba(255,255,255,.7); box-shadow: 0 4px 0 rgba(154, 112, 59, .16); }
.grade-book { display: flex; align-items: center; min-width: 0; gap: 12px; }
.grade-book-icon { display: grid; place-items: center; flex: 0 0 auto; width: 48px; height: 48px; border: 3px solid #fff; border-radius: 15px; background: linear-gradient(145deg, #6edfc1, #a991ef); color: #fff; font-size: 22px; font-weight: 800; box-shadow: 0 4px 0 rgba(74, 93, 126, .22); }
.grade-book h2 { margin-bottom: 1px; font-size: 18px; }
.grade-book p { margin: 0; color: var(--muted); font-weight: 800; }
.grade-mark { display: grid; place-items: center; min-height: 54px; border: 3px solid #fff; border-radius: 17px; background: linear-gradient(145deg, #ffd96e, #ff9fa1); color: #fff; font-size: 23px; font-weight: 900; box-shadow: 0 4px 0 rgba(178, 106, 67, .22); text-align: center; }
.grade-comment { grid-column: 1 / -1; margin: 0; padding: 11px 13px; border-radius: 11px; background: #fff9e9; color: var(--ink); white-space: pre-wrap; }

.landing-page { width: min(1320px, calc(100% - 28px)); min-height: calc(100vh - 36px); margin: 18px auto; overflow: hidden; border: 4px solid rgba(255,255,255,.7); border-radius: 20px; background: #f8d17f; box-shadow: var(--shadow); }
.landing-nav { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; min-height: 84px; padding: 16px 5.5%; color: #fff; }
.landing-brand { display: flex; align-items: center; text-decoration: none; }.landing-brand .brand-mark { flex: 0 0 auto; background: linear-gradient(145deg, #8bbff3, #ac8be5); }
.landing-teacher { border: 2px solid rgba(255,255,255,.75); border-radius: 999px; padding: 9px 14px; color: #fff; font-size: 14px; font-weight: 800; text-decoration: none; background: rgba(77,50,38,.2); }
.landing-hero { position: relative; display: grid; grid-template-columns: minmax(300px, .82fr) minmax(420px, 1.18fr); min-height: min(650px, calc(100vh - 190px)); margin-top: -84px; overflow: hidden; padding: 145px 5.5% 70px; background: linear-gradient(135deg, #896143, #f8ce74 62%, #f6c86f); }.landing-hero::after { content: ""; position: absolute; inset: 0; z-index: 0; background: linear-gradient(90deg, rgba(44,28,27,.58), rgba(44,28,27,.12) 48%, transparent 72%); }
.landing-copy { position: relative; z-index: 1; align-self: center; max-width: 560px; color: #fff; }.landing-copy .eyebrow { color: #ffe8a6; }.landing-copy h1 { margin-bottom: 17px; font-size: clamp(43px, 5vw, 69px); line-height: 1.02; text-shadow: 0 3px 8px rgba(63,37,29,.38); }.landing-copy > p:not(.eyebrow) { max-width: 450px; margin-bottom: 25px; font-size: 19px; text-shadow: 0 2px 5px rgba(55,31,21,.45); }.landing-copy .actions { flex-wrap: wrap; }.landing-copy .button.secondary { border-color: rgba(255,255,255,.75); background: rgba(255,255,255,.86); }
.hero-art { position: absolute; inset: 0; z-index: 0; }.hero-art img { width: 100%; height: 100%; object-fit: cover; object-position: center; }.hero-note { display: flex; align-items: center; gap: 9px; margin-top: 28px; color: #fff7d5; font-size: 14px; font-weight: 800; }.hero-note span { display: grid; place-items: center; width: 23px; height: 23px; border-radius: 50%; background: var(--mint); color: #fff; font-size: 19px; line-height: 1; }
.landing-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: rgba(117,75,45,.18); }.landing-strip > div { display: grid; gap: 2px; padding: 19px 5.5%; background: #fff7df; }.landing-strip strong { color: #9163bc; font-size: 18px; }.landing-strip span { color: var(--muted); font-size: 14px; }

@media (max-width: 1100px) { .dashboard { grid-template-columns: 1fr; } }
@media (max-width: 980px) { .app-layout, .app-layout.teacher-layout, .app-layout.student-layout { grid-template-columns: 160px minmax(0,1fr); } .rewards { display: none; } }
@media (max-width: 720px) { body { background-position: 58% center; } .shell { width: calc(100% - 14px); margin: 7px auto; padding: 12px; border-radius: 14px; } .app-layout, .app-layout.teacher-layout, .app-layout.student-layout { display: block; } .sidebar { display: flex; align-items: center; gap: 10px; overflow-x: auto; padding-bottom: 12px; } .brand { min-width: 48px; margin: 0; } .nav-list { display: flex; gap: 8px; } .nav-item { min-width: max-content; } .topbar, .section-head, .entry-head, .actions, .link-row, .form-actions { align-items: stretch; flex-direction: column; } .progress { min-width: 0; width: 100%; } .paper-panel, .panel { padding: 17px; } .dashboard { grid-template-columns: 1fr; } .admin-work { grid-template-columns: 54px minmax(0, 1fr); } .cover.small { width: 54px; min-width: 54px; } .work-actions { grid-template-columns: 1fr; } .grade-card { grid-template-columns: 1fr; } .grade-mark { width: 78px; min-height: 50px; } .work-hero { align-items: flex-start; flex-direction: column; } .cover.large { width: 140px; min-width: 140px; } .library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; } .landing-page { width: calc(100% - 14px); min-height: calc(100vh - 14px); margin: 7px auto; border-radius: 14px; } .landing-nav { min-height: 68px; padding: 12px 18px; }.landing-brand .brand-mark { width: 38px; height: 36px; font-size: 19px; }.landing-teacher { padding: 7px 10px; font-size: 12px; }.landing-hero { display: block; min-height: 590px; margin-top: -68px; padding: 115px 22px 36px; }.landing-copy { max-width: 360px; }.landing-copy h1 { font-size: 42px; }.landing-copy > p:not(.eyebrow) { font-size: 16px; }.hero-art img { object-position: 63% center; }.landing-strip { grid-template-columns: 1fr; }.landing-strip > div { padding: 14px 22px; } }
