:root {
  color-scheme: light;
  font: 15px/1.55 "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  --ink: #17203e;
  --muted: #536482;
  --violet: #5745cb;
  --line: #dde2f1;
  --paper: #f6f7fd;
  --white: #fff;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
a { color: var(--violet); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; color: #566078; background: #f0f1f7; border: 1px solid var(--line); border-radius: 8px; padding: .45rem .7rem; }
input, select { min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: .6rem .75rem; background: var(--white); color: var(--ink); }
:focus-visible { outline: 3px solid #7564ea; outline-offset: 2px; }
h1 { font-size: clamp(1.65rem, 4vw, 2.25rem); margin: 0 0 1rem; letter-spacing: -.035em; }
h2 { font-size: 1.13rem; margin: 0 0 .8rem; }
.shell { display: grid; grid-template-columns: 215px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--white); border-right: 1px solid var(--line); padding: 1.4rem 1rem; }
.admin .sidebar { background: #192441; border-color: #192441; }
.admin .sidebar a { color: #fff; }
.brand { display: inline-flex; gap: .55rem; align-items: center; font-size: 1.45rem; font-weight: 800; color: var(--ink); letter-spacing: -.045em; }
.brand span { color: #6453e0; font-size: 1.7rem; }
.admin .brand span { color: #aaa1ff; }
nav { display: grid; gap: .35rem; margin-top: 2rem; }
nav a { color: var(--ink); padding: .65rem .8rem; border-radius: 8px; font-weight: 700; }
nav a.active { background: #eae7ff; color: #3926ad; }
.admin nav a.active { background: #5544c8; color: white; }
.topbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; padding: 1rem clamp(1rem, 3vw, 2.5rem); background: var(--white); border-bottom: 1px solid var(--line); }
.search, .profile, .actions { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; }
.search input { width: clamp(155px, 28vw, 320px); }
main { width: min(100%, 1320px); margin: auto; padding: clamp(1rem, 3vw, 2.5rem); }
.card, .metrics > div { background: var(--white); border: 1px solid var(--line); border-radius: 13px; }
.card { padding: clamp(.9rem, 2vw, 1.4rem); margin-bottom: 1rem; min-width: 0; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.metrics > div { padding: .9rem 1rem; background: #efecff; font-weight: 650; }
.metrics > div:nth-child(2) { background: #e9efff; }
.metrics > div:nth-child(3) { background: #e8f6f3; }
.metrics > div:nth-child(4) { background: #ffedf2; }
.metrics strong { display: block; font-size: 1.55rem; margin-top: .1rem; }
.columns { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1rem; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .3rem .8rem; }
.item-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(155px, 100%), 1fr)); gap: .65rem; }
.item { display: grid; align-content: start; justify-items: start; gap: .45rem; padding: .85rem; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; background: #fafaff; overflow-wrap: anywhere; }
.item:hover { border-color: #897bea; text-decoration: none; }
.item-category, .muted { color: var(--muted); }
.pill { display: inline-block; background: #eeecfd; color: #4735ac; border-radius: 16px; padding: .15rem .55rem; font-size: .83rem; font-weight: 700; }
.pill.available { background: #e5f7ed; color: #155c3b; }
.filters { display: flex; align-items: end; gap: .8rem; flex-wrap: wrap; }
label { display: grid; gap: .35rem; font-weight: 650; }
.check { display: flex; align-items: center; padding: .55rem 0; }
.button, .secondary { border-radius: 8px; padding: .55rem .85rem; font-weight: 700; }
.button { background: var(--violet); color: white; border: 1px solid var(--violet); }
.secondary { background: #f5f4ff; color: #42329a; border: 1px solid var(--line); }
table { border-collapse: collapse; width: 100%; text-align: left; }
td, th { padding: .65rem .45rem; border-bottom: 1px solid var(--line); }
th { background: #f4f3fd; }
.error { padding: .75rem 1rem; background: #ffedf0; color: #82172e; border-radius: 8px; }
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login { max-width: 420px; padding: 2rem; }
.login .brand { margin-bottom: 1rem; }
.login form { display: grid; gap: .8rem; margin-top: .8rem; }
@media (max-width: 800px) {
  .shell, .columns { grid-template-columns: 1fr; gap: 0; }
  .sidebar { border-right: 0; padding: .65rem 1rem; }
  nav { display: flex; flex-wrap: wrap; margin-top: .5rem; }
}
@media (max-width: 480px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  td, th { padding: .45rem .2rem; }
}
.login-page { display: flex; align-items: center; justify-content: center; }
.login-page .login { width: min(100%, 430px); margin: 0; }
.account-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .7rem; margin: 1rem 0 0; }
.table-wrap { overflow-x: auto; }
.edit-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: .7rem; padding: .75rem 0; align-items: end; }
.edit-form textarea { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: .6rem; min-width: 0; }
details { padding: .55rem 0; border-bottom: 1px solid var(--line); }
summary { cursor: pointer; font-weight: 650; }
.notice-body { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Student dashboard */
.topbar-title { font-weight: 750; letter-spacing: -.02em; }
.student-home { background: #f4f6fc; }
.home-intro {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: clamp(1.5rem, 4vw, 2.7rem);
  margin-bottom: 1.65rem;
  border-radius: 20px;
  color: white;
  background: linear-gradient(113deg, #1b2855 0%, #3745a2 56%, #6252d2 100%);
  box-shadow: 0 12px 28px #303e801e;
}
.home-intro::before, .home-intro::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 24rem;
  height: 24rem;
  right: -5rem;
  top: -11rem;
  border: 1px solid #ffffff38;
  border-radius: 50%;
  background: #ffffff10;
  pointer-events: none;
}
.home-intro::after { right: -10rem; top: -4rem; width: 29rem; height: 29rem; }
.home-intro-content { max-width: 640px; }
.home-intro h1 { margin: 0 0 1.1rem; font-size: clamp(1.7rem, 4vw, 2.55rem); overflow-wrap: anywhere; }
.home-search { display: flex; gap: .45rem; width: min(100%, 540px); padding: .35rem; background: white; border-radius: 11px; }
.home-search input { flex: 1; border-color: transparent; }
.home-search button { flex-shrink: 0; }
.home-browse { display: inline-block; margin-top: .9rem; color: #fff; font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.home-section-head { margin-bottom: .6rem; }
.home-section-head h2 { margin-bottom: 0; }
.student-home .metrics { gap: .75rem; margin-bottom: 1.35rem; }
.student-home .metrics > div {
  --accent: #6654cf;
  border-top: 3px solid var(--accent);
  padding: .8rem 1rem .65rem;
  background: white;
  color: var(--muted);
}
.student-home .metrics > div:nth-child(2) { --accent: #447bd0; }
.student-home .metrics > div:nth-child(3) { --accent: #aa5378; }
.student-home .metrics > div:nth-child(4) { --accent: #268b80; }
.student-home .metrics strong { color: var(--ink); }
.home-columns { grid-template-columns: minmax(0, 2.35fr) minmax(0, 1fr); align-items: start; }
.home-columns .card { border-radius: 16px; box-shadow: 0 4px 18px #283c6210; }
.home-columns .section-head { padding-bottom: .45rem; }
.home-columns .section-head a, .home-section-head a { font-weight: 700; }
.home-columns .item-grid { grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); }
.item {
  grid-template-rows: auto auto 1fr auto;
  min-height: 144px;
  background: linear-gradient(155deg, #f2f0ff 0%, #fff 66%);
}
.item-category { font-size: .78rem; font-weight: 750; color: #5036a9; }
.item-name { font-size: 1.03rem; }
.item-description { font-size: .88rem; color: var(--muted); }
.item-footer { width: 100%; display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; justify-content: space-between; }
.item-arrow { font-weight: 750; color: var(--violet); }
.notice-panel > .muted { padding: .75rem 0; margin: 0; border-top: 1px solid var(--line); }
@media (max-width: 920px) {
  .home-columns { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 480px) {
  .home-search { flex-wrap: wrap; background: transparent; padding: 0; }
  .home-search input { flex: 1 1 100%; }
  .home-search button { width: 100%; }
}

/* Administrator dashboard */
.admin-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 245px), 1fr)); gap: .9rem; margin-bottom: 1rem; }
.admin-action { display: block; margin: 0; padding: 1.25rem; border-radius: 15px; color: var(--ink); }
.admin-action h2 { display: flex; justify-content: space-between; gap: .5rem; margin: 0 0 .45rem; }
.admin-action p { margin: 0; color: var(--muted); }
.admin-action:hover { border-color: #8474e1; text-decoration: none; }
.admin-action-primary { background: #eeeaff; border-color: #dad0ff; color: #3c2996; }

/* Browser appearance preferences */
.theme-options { display: flex; flex-wrap: wrap; gap: .35rem 1.5rem; padding: 0; margin: 0; border: 0; }
.theme-options legend { margin-bottom: .4rem; padding: 0; font-size: 1.13rem; font-weight: 700; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #121725;
  --white: #1c2435;
  --ink: #eef0f9;
  --muted: #b5bfd4;
  --violet: #b4a8ff;
  --line: #343e55;
  background: var(--paper);
}
[data-theme="dark"] .student-home { background: var(--paper); }
[data-theme="dark"] .admin .sidebar { background: #171f34; border-color: var(--line); }
[data-theme="dark"] nav a.active,
[data-theme="dark"] .secondary { background: #2e3151; color: #d6ceff; }
[data-theme="dark"] .admin nav a.active { background: #50409b; color: #fff; }
[data-theme="dark"] .button { background: #6955cf; border-color: #8c79ee; color: #fff; }
[data-theme="dark"] .home-intro { background: linear-gradient(113deg, #24315b, #493e91); }
[data-theme="dark"] .home-search { background: var(--white); }
[data-theme="dark"] .student-home .metrics > div,
[data-theme="dark"] .metrics > div { background: var(--white); }
[data-theme="dark"] .item { background: linear-gradient(155deg, #2c2d47, var(--white) 72%); }
[data-theme="dark"] .item-category { color: #c6b9ff; }
[data-theme="dark"] .pill { background: #373255; color: #d6ccff; }
[data-theme="dark"] .pill.available { background: #1c4138; color: #9de2c4; }
[data-theme="dark"] .admin-action-primary,
[data-theme="dark"] th { background: #2b2b46; border-color: #46436a; color: #e2dcff; }
[data-theme="dark"] .error { background: #462637; color: #ffbace; }
[data-theme="dark"] button:disabled { background: #242b3c; color: #a6aec4; }
[data-theme="dark"] .edit-form textarea { background: var(--white); color: var(--ink); }
