:root {
  color-scheme: light;
  --canvas: #f7f5ef;
  --surface: #fff;
  --ink: #2f2620;
  --muted: #675d53;
  --line: #e5ded3;
  --field-line: #a79b8d;
  --amber: #f4ac38;
  --amber-hover: #eea224;
  --amber-pale: #fff0d4;
  --amber-deep: #804900;
  --error: #9b2424;
  --success: #27583d;
  --radius: .8rem;
  --content-width: 87.5rem;
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  font-size: 100%;
  line-height: 1.6;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
h1, h2, h3, label { word-break: keep-all; overflow-wrap: anywhere; }
h1 { font-size: clamp(1.8rem, 4vw, 2.65rem); letter-spacing: -.055em; line-height: 1.2; }
h2 { font-size: 1.25rem; line-height: 1.35; letter-spacing: -.025em; }
h3 { font-size: 1.0625rem; line-height: 1.45; }
a { color: #683900; text-underline-offset: .18em; }
img { display: block; max-width: 100%; }
form { margin: 0; }
button, input, select, textarea { color: inherit; font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: .17rem solid var(--amber-deep); outline-offset: .18rem; }

.skip-link {
  position: fixed;
  z-index: 10;
  top: .5rem;
  left: .5rem;
  padding: .5rem .9rem;
  transform: translateY(-150%);
  color: var(--ink);
  background: var(--surface);
}
.skip-link:focus { transform: translateY(0); }

.site-top { position: sticky; z-index: 4; top: 0; }
.appbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.appbar-inner, .delegation-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-inline: clamp(1rem, 4vw, 2.5rem);
}
.appbar-inner:not(:has(.account)) {
  max-width: var(--content-width);
  margin-inline: auto;
}
.appbar-inner { min-height: 4.75rem; }
.brand { display: inline-block; flex: 0 1 13.75rem; min-width: 0; }
.brand img { width: 100%; height: auto; }
.account { display: flex; align-items: center; flex-shrink: 0; gap: .7rem; }
.account-name { font-weight: 700; }
.account-role {
  padding-inline-start: .7rem;
  border-inline-start: 1px solid var(--line);
  color: var(--muted);
  font-size: .875rem;
}
.delegation { border-bottom: 1px solid #deb46a; background: #fff2d8; color: #462c14; }
.delegation-inner { padding-block: .55rem; }
.delegation p { color: var(--muted); font-size: .875rem; }
.delegation form { flex-shrink: 0; }

.layout-authenticated { display: grid; grid-template-columns: 13.75rem minmax(0, 1fr); }
.sidebar { background: var(--surface); border-inline-end: 1px solid var(--line); }
.workspace-label {
  display: grid;
  gap: .2rem;
  margin: 1.75rem 1.125rem 1rem;
  padding: .2rem .75rem 1rem;
  border-bottom: 1px solid var(--line);
}
.workspace-role { color: var(--muted); font-size: .875rem; font-weight: 650; }
.workspace-label strong { font-size: 1.1rem; overflow-wrap: anywhere; }
.nav { display: flex; flex-direction: column; gap: .3rem; padding: 0 1.125rem 1.25rem; }
.nav a {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  padding: .55rem .75rem;
  border-radius: .45rem;
  color: #4b3d30;
  font-size: .9375rem;
  text-decoration: none;
}
.nav a:hover { background: #f8f4ec; }
.nav a[aria-current] { background: var(--amber-pale); box-shadow: inset .18rem 0 #b86f13; color: #623e11; font-weight: 750; }
.main {
  width: 100%;
  max-width: var(--content-width);
  min-height: calc(100vh - 4.75rem);
  min-width: 0;
  margin-inline: auto;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 2.5rem) 3.5rem;
  scroll-margin-top: 10rem;
}
.main:focus { outline: none; }

.page-header, .panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.4rem;
}
.page-header p, .panel-head p { color: var(--muted); margin-top: .45rem; }
.page-header .page-context { margin: 0 0 .55rem; color: var(--amber-deep); font-size: .875rem; font-weight: 700; }
.page-actions, .actions, .form-actions, .filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .65rem;
}
.form-actions { margin-top: .35rem; }
.filter-bar { align-items: flex-end; margin-bottom: 1rem; }
.muted, .secondary, .field-hint, .helptext { color: var(--muted); }
.panel {
  min-width: 0;
  padding: clamp(1rem, 2.5vw, 1.5rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.panel + .panel { margin-top: 1rem; }
.panel > h2 + *, .panel > h3 + * { margin-top: .75rem; }
.panel h2 + p, .panel h3 + p { color: var(--muted); }
.empty-state, .empty {
  padding: 1.35rem .75rem;
  text-align: center;
  color: var(--muted);
}

.button, a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  min-height: 2.75rem;
  padding: .4rem 1rem;
  border: 1px solid transparent;
  border-radius: .45rem;
  background: var(--amber);
  color: #332008;
  font-weight: 720;
  font-size: .9375rem;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
}
.button:hover { background: var(--amber-hover); }
.button-secondary, a.button-secondary { border-color: #b8aa98; background: var(--surface); color: var(--ink); }
.button-secondary:hover { background: #f8f2e7; }
.button-small, a.button-small { min-height: 2.4rem; padding: .45rem .675rem; font-size: .875rem; }
.button-danger, a.button-danger { border-color: #d6a398; background: #fff4f2; color: var(--error); }
.button-danger:hover { background: #fce7e3; }
.button:disabled { cursor: default; opacity: .65; }

.notice {
  padding: .7rem .9rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--surface);
}
.notice.success { color: var(--success); background: #eaf5ee; border-color: #bad5c3; }
.notice.warning { color: #673c00; background: var(--amber-pale); border-color: #e2bd7b; }
.notice.error { color: var(--error); background: #fff3f1; border-color: #e3b0a9; }
.messages { display: grid; gap: .55rem; margin-bottom: 1.25rem; }
.status, .badge {
  display: inline-flex;
  align-items: center;
  padding: .15rem .55rem;
  border-radius: .3rem;
  background: #efece6;
  color: #54493e;
  font-size: .875rem;
  font-weight: 700;
}
.status.active, .badge-success { background: #e7f2eb; color: var(--success); }
.status.pending, .badge-warning { background: var(--amber-pale); color: #6c4206; }
.status.rejected, .badge-danger { background: #fbece9; color: var(--error); }

.form-stack { display: grid; gap: 1.05rem; }
.form-stack > .button { justify-self: start; }
fieldset { min-width: 0; }
fieldset.field { margin: 0; padding: 0; border: 0; }
.field { display: grid; gap: .35rem; }
.field label, .field legend { color: var(--ink); font-size: .9375rem; font-weight: 700; }
.field legend { margin-bottom: .35rem; padding: 0; }
.field-hint, .helptext { font-size: .875rem; }
.field-hint ul, .helptext ul, .errorlist { padding-inline-start: 1.15rem; }
.checkbox-line { display: flex; align-items: flex-start; gap: .5rem; }
.checkbox-line input { flex: 0 0 auto; margin-top: .3rem; }
:is(.panel, .field, .filter-bar) :is(input, textarea, select):not([type="radio"], [type="checkbox"], [type="hidden"], [type="submit"], [type="button"]) {
  width: 100%;
  min-height: 2.75rem;
  min-width: 0;
  padding: .45rem .65rem;
  border: 1px solid var(--field-line);
  border-radius: .42rem;
  background-color: var(--surface);
}
:is(.panel, .field, .filter-bar) textarea { resize: vertical; }
:is(.panel, .field, .filter-bar) select:not([multiple]) {
  appearance: none;
  padding-inline-end: 1.65rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-size: .3rem .3rem;
  background-repeat: no-repeat;
  background-position: calc(100% - .95rem) 53%, calc(100% - .65rem) 53%;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--amber-deep); min-width: 1.05rem; min-height: 1.05rem; }
.field-invalid :is(input, textarea, select)[aria-invalid] { border-color: var(--error); }
.errorlist, .field-error { color: var(--error); font-size: .875rem; }
.notice.error .errorlist { color: inherit; }
.panel form > p + p { margin-top: .75rem; }
.panel form > p label { display: block; font-weight: 700; margin-bottom: .25rem; }

.record-form {
  display: grid;
  gap: 1rem;
  max-width: 66rem;
}
.record-section {
  display: grid;
  grid-template-columns: minmax(9rem, .72fr) minmax(0, 2.2fr);
  gap: clamp(1rem, 3vw, 2.25rem);
  padding: clamp(1rem, 3vw, 1.9rem);
  border-radius: 1rem;
}
.record-section + .record-section { margin-top: 0; }
.record-section > header {
  align-self: start;
  padding-inline-start: .85rem;
  border-inline-start: .2rem solid var(--amber);
}
.record-section > header p { margin-top: .35rem; color: var(--muted); font-size: .875rem; }
.record-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 1.15rem 1rem;
  min-width: 0;
}
.record-fields > :is(fieldset, .notice, .record-wide, .field:has(textarea)) { grid-column: 1 / -1; }
.record-fields > :only-child { grid-column: 1 / -1; }
.record-form .field {
  gap: .45rem;
  min-width: 0;
}
.record-form .field :is(input:not([type="checkbox"], [type="radio"], [type="hidden"]), select, textarea) {
  min-height: 3rem;
  padding-inline-start: .8rem;
  border-radius: .6rem;
  background-color: #fffefa;
}
.record-form .field :is(input, select, textarea):focus-visible { background-color: var(--surface); }
.record-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: .65rem;
  padding-top: .35rem;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .9375rem; }
th, td { padding: .7rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th { background: #f8f5ef; color: #574939; font-size: .875rem; font-weight: 750; }
tbody tr:last-child > * { border-bottom-color: transparent; }
tbody tr:hover { background: #fdfaf4; }
.table-wrap input:not([type="radio"], [type="checkbox"], [type="hidden"]) { min-width: 7rem; }
.table-wrap .button, .table-wrap .status, .table-wrap .badge { white-space: nowrap; }
.detail-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
  gap: .85rem 1.5rem;
}
.detail-facts dt { color: var(--muted); font-size: .875rem; }
.detail-facts dd { margin-top: .2rem; font-weight: 650; overflow-wrap: anywhere; }
.quote-actions { margin-top: 1rem; }

.workspace-header { margin-bottom: 1.55rem; }
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffefa;
}
.metric { padding: 1rem 1.2rem; border-inline-end: 1px solid var(--line); }
.metric:last-child { border-inline-end: 0; }
.metric dt { color: var(--muted); font-size: .875rem; font-weight: 700; }
.metric dd { margin-top: .12rem; font-size: 2rem; font-weight: 750; line-height: 1.25; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metric .metric-caption { margin-top: .35rem; color: var(--muted); font-size: .875rem; font-weight: 400; }
.home-section { margin-top: 1.9rem; }
.home-section h2 { margin-bottom: .65rem; }
.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12.5rem), 1fr));
  gap: .8rem;
  padding: 0;
  list-style: none;
}
.action-card {
  display: flex;
  height: 100%;
  min-height: 4.35rem;
  flex-direction: column;
  justify-content: center;
  gap: .25rem;
  padding: .85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  text-decoration: none;
}
.action-card:hover { border-color: #c58f48; background: #fffaf0; }
.action-card span { color: var(--muted); font-size: .875rem; }
.connection-card { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.connection-card .badge { text-align: center; }
.pagination { margin-top: 1rem; }
.homework-feed { display: grid; gap: .65rem; margin: 0; padding: 0; list-style: none; }
.homework-link { padding: .9rem 1.1rem; }
.homework-link strong { overflow-wrap: anywhere; }
.homework-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; }
.homework-instructions { overflow-wrap: anywhere; white-space: pre-wrap; }
.homework-preview summary { cursor: pointer; font-weight: 700; }
.homework-preview .table-wrap { margin-top: .75rem; }
.homework-preview caption { color: var(--muted); padding-bottom: .35rem; text-align: left; }

.auth-panel {
  max-width: 27rem;
  margin: clamp(.75rem, 5vw, 3rem) auto 0;
  padding: clamp(1.4rem, 4vw, 2rem);
  border-top: .22rem solid var(--amber);
}
.auth-panel .form-stack > .button { justify-self: stretch; margin-top: .35rem; }
.auth-panel--voca { border-top-color: #486a53; }
.auth-panel--voca .page-header h1 { font-size: clamp(1.5rem, 5vw, 2rem); }
.auth-voca-brand {
  display: grid;
  min-height: 8rem;
  place-items: center;
  margin-bottom: 1.15rem;
  padding: .75rem 1rem;
  border-radius: .5rem;
  background: #f5ebd0 url("voca-login-room.webp") center / cover;
}
.auth-voca-brand img { width: min(16rem, 100%); height: auto; }
.demo-login { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.error-page h1 { font-size: clamp(1.45rem, 3vw, 1.9rem); }
.error-page p { margin-block: .55rem 1.25rem; color: var(--muted); }

@media (max-width: 57.5rem) {
  .layout-authenticated { grid-template-columns: 1fr; }
  .sidebar { border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .workspace-label { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: .35rem; padding: .5rem clamp(1rem, 4vw, 2.5rem); }
  .nav a[aria-current] { box-shadow: inset 0 -.15rem #b86f13; }
  .main { min-height: 70vh; }
}
@media (max-width: 48rem) {
  .record-section { grid-template-columns: 1fr; }
}
@media (max-width: 33rem) {
  .appbar-inner { min-height: 3.8rem; gap: .5rem; }
  .brand { flex-basis: 9.5rem; }
  .account { min-width: 0; flex-shrink: 1; gap: .4rem; }
  .account-name { display: none; }
  .account-role { padding-inline-start: 0; border: 0; font-size: .875rem; }
  .delegation-inner { gap: .55rem; }
  .delegation-inner strong { font-size: .875rem; }
  .delegation-inner p { font-size: .75rem; }
  .delegation .button { padding-inline: .55rem; white-space: nowrap; }
  .nav { gap: .2rem; }
  .nav a { min-height: 2.5rem; padding-inline: .5rem; font-size: .875rem; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { padding: .7rem .85rem; border-bottom: 1px solid var(--line); }
  .metric:nth-child(even) { border-inline-end: 0; }
  .metric:nth-child(even):last-child, .metric:last-child:not(:nth-child(even)), .metric:nth-last-child(2):nth-child(odd) { border-bottom: 0; }
  .metric dd { font-size: 1.6rem; }
  .record-fields { grid-template-columns: 1fr; }
  .record-actions .button { flex: 1 1 8rem; }
  th, td { padding-inline: .55rem; }
}
