@font-face {
  font-family: "GyeonggiBatangLocal";
  src: url("./fonts/gyeonggi-batang-regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "BMJuaLocal";
  src: url("./fonts/bm-jua.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "BMHanna11Local";
  src: url("./fonts/bm-hanna-11yrs.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #432b33;
  --muted: #776b72;
  --line: #ffafc3;
  --line-soft: #ffd7e0;
  --paper: #fff9fb;
  --panel: #ffffff;
  --rose: #ee5079;
  --rose-deep: #c93a62;
  --mint: #39a978;
  --amber: #d88a19;
  --sky: #4177c8;
  --danger: #c44747;
  --shadow: 0 12px 30px rgba(185, 72, 106, 0.11);
  --writing-font: "GyeonggiBatangLocal", "GyeonggiBatang Regular", serif;
  --display-font: "BMJuaLocal", "BM JUA", "Pretendard", "Noto Sans KR", sans-serif;
  --brand-font: "BMHanna11Local", "BM HANNA 11yrs old", "BMJuaLocal", "Pretendard", "Noto Sans KR", sans-serif;
  font-family: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(255, 229, 236, 0.8), rgba(255, 249, 251, 0.92)),
    repeating-linear-gradient(0deg, transparent 0 42px, rgba(255, 175, 195, 0.18) 42px 43px);
}

body.student-shell {
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

textarea,
input,
select {
  width: 100%;
  border: 2px solid var(--line-soft);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--rose);
  box-shadow: 0 0 0 4px rgba(238, 80, 121, 0.12);
}

textarea {
  resize: vertical;
  line-height: 1.75;
}

.student-page,
.admin-page {
  width: min(1720px, calc(100vw - 64px));
  margin: 28px auto;
  border: 3px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  padding: 28px;
}

.topbar,
.admin-header,
.panel-heading,
.section-title,
.writing-tools,
.button-row,
.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar,
.admin-header {
  justify-content: space-between;
  border-bottom: 2px dashed var(--line-soft);
  padding-bottom: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  font-family: var(--brand-font);
  font-size: clamp(24px, 2.2vw, 34px);
  font-weight: 400;
  color: var(--rose);
}

.brand-date {
  font-family: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", system-ui, sans-serif;
  font-size: 16px;
  font-weight: 900;
  color: var(--rose-deep);
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff3f6;
}

.date-pill,
.status-chip,
.section-title span {
  border: 2px solid var(--line-soft);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--rose-deep);
  background: #fff7fa;
  font-weight: 800;
}

.welcome-pill {
  color: var(--rose-deep);
  font-weight: 900;
  white-space: nowrap;
}

.bell-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: var(--rose-deep);
  font-size: 19px;
}

.logout-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--rose-deep);
  font-family: "Pretendard", "Noto Sans KR", system-ui, sans-serif;
  font-size: 23px;
  font-weight: 900;
  line-height: 1;
}

.notification-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #e8355f;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.student-login-form {
  display: grid;
  grid-template-columns: 130px 150px auto;
  gap: 8px;
  align-items: center;
}

.student-login-form input {
  min-height: 42px;
  padding: 8px 10px;
}

.student-login-form button {
  min-height: 42px;
  padding: 8px 14px;
}

.topic-panel,
.hint-panel,
.write-panel,
.mailbox-panel,
.login-panel,
.admin-card,
.summary-grid article {
  border: 3px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.topic-panel {
  margin-top: 28px;
  padding: 36px;
  text-align: center;
  background: #fff1f5;
}

.compact-student-page {
  width: min(90vw, 1720px);
  height: calc(100dvh - clamp(16px, 3dvh, 28px));
  margin: clamp(8px, 1.5dvh, 14px) auto;
  padding: clamp(16px, 1.45vw, 28px);
  display: grid;
  grid-template-rows: auto minmax(118px, 0.27fr) minmax(0, 1fr);
  gap: clamp(8px, 1.1dvh, 12px);
  overflow: hidden;
}

.compact-topbar {
  padding-bottom: clamp(8px, 1.1dvh, 12px);
}

.compact-topic,
.compact-hint,
.compact-write-panel {
  margin-top: 0;
}

.compact-topic {
  position: relative;
  padding: clamp(16px, 2.4dvh, 26px) clamp(22px, 1.8vw, 34px);
}

.compact-topic h1 {
  padding-right: 0;
  font-size: clamp(28px, 3.05vw, 52px);
  line-height: 1.35;
}

.topic-helper-button {
  position: static;
  align-self: flex-end;
  margin-top: clamp(8px, 1.2dvh, 14px);
  min-width: 178px;
}

.compact-hint {
  padding: 14px 24px 16px;
}

.compact-hint p {
  margin-top: 10px;
  min-height: 82px;
  padding: 18px 20px;
  font-family: var(--writing-font);
  font-size: clamp(24px, 2.1vw, 34px);
  line-height: 1.55;
}

.compact-write-panel {
  min-height: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.compact-writing-form {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.compact-writing-form #writingText {
  min-height: 0;
  flex: 1;
}

.topic-panel h1 {
  margin: 0;
  font-family: var(--display-font);
  font-size: clamp(32px, 4vw, 58px);
  line-height: 1.55;
  font-weight: 400;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--rose);
  font-size: 16px;
  font-weight: 900;
}

.hint-panel,
.write-panel,
.mailbox-panel {
  margin-top: 20px;
  padding: 26px;
}

.hint-panel h2,
.write-panel h2,
.mailbox-panel h2,
.admin-card h2,
.login-panel h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.hint-panel p,
.empty-mailbox p,
.guide-text,
.admin-header p,
.form-message {
  color: var(--muted);
}

.hint-panel p {
  margin: 18px 0 0;
  min-height: 92px;
  border: 2px dashed var(--line-soft);
  border-radius: 8px;
  background: var(--paper);
  padding: 26px;
  font-size: clamp(20px, 2.4vw, 34px);
  line-height: 1.55;
}

.panel-heading,
.section-title {
  justify-content: space-between;
}

.writing-form {
  margin-top: 0;
}

.identity-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) 150px minmax(180px, 0.8fr);
  gap: 14px;
}

label span,
.text-label {
  display: block;
  margin-bottom: 8px;
  color: var(--rose-deep);
  font-weight: 900;
}

input,
select {
  min-height: 48px;
  padding: 10px 12px;
}

.text-label {
  margin-top: 6px;
}

#writingText {
  min-height: 290px;
  padding: clamp(20px, 2.4dvh, 26px) clamp(22px, 1.6vw, 30px);
  border-color: #ff789a;
  border-radius: 12px;
  font-family: var(--writing-font);
  font-size: clamp(22px, 1.75vw, 32px);
  line-height: 1.7;
}

#writingText:disabled {
  background: #fff7fa;
  color: #9a8b92;
}

.writing-tools {
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: clamp(8px, 1.1dvh, 12px);
}

.meter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meter-list span,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border-radius: 8px;
  padding: 6px 10px;
  background: #f5fbff;
  color: var(--sky);
  font-weight: 800;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 10px 18px;
  font-family: var(--display-font);
  font-weight: 400;
}

.primary-button {
  background: var(--rose);
  color: white;
}

.primary-button:hover {
  background: var(--rose-deep);
}

.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  filter: grayscale(0.2);
}

.secondary-button {
  border: 2px solid var(--line);
  background: white;
  color: var(--rose-deep);
}

.danger-button {
  border: 2px solid #f0b3b3;
  background: #fff5f5;
  color: var(--danger);
}

.wide-button {
  width: 100%;
  margin-top: 16px;
}

.compact button {
  min-height: 36px;
  padding: 6px 10px;
}

.mailbox-panel {
  min-height: 160px;
}

.inline-feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  margin-top: 6px;
  color: var(--muted);
  font-weight: 800;
}

.link-button {
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff7fa;
  color: var(--rose-deep);
  padding: 6px 10px;
  font-weight: 900;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(255, 248, 251, 0.72);
  backdrop-filter: blur(2px);
  z-index: 20;
}

.modal-card {
  width: min(760px, 100%);
  max-height: min(720px, calc(100vh - 48px));
  overflow: auto;
  border: 3px solid var(--line);
  border-radius: 12px;
  background: white;
  padding: 22px;
  box-shadow: var(--shadow);
}

.feedback-card,
.submission-text,
.feedback-json {
  border: 2px solid var(--line-soft);
  border-radius: 8px;
  background: var(--paper);
  padding: 16px;
}

.mailbox-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.feedback-list {
  margin: 10px 0 0;
  padding-left: 20px;
}

.admin-page {
  max-width: 1480px;
}

.admin-header {
  align-items: flex-start;
}

.login-panel {
  width: min(560px, 100%);
  margin: 42px auto 0;
  padding: 28px;
}

.login-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 20px;
}

.hidden {
  display: none !important;
}

.admin-workspace {
  margin-top: 24px;
}

.admin-card {
  padding: 22px;
  margin-top: 18px;
}

.assignment-card form {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.toggle-row {
  flex-wrap: wrap;
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 800;
}

.toggle-label input {
  width: 20px;
  min-height: auto;
  height: 20px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 18px;
}

.summary-grid article {
  padding: 20px;
}

.summary-grid span {
  color: var(--muted);
  font-weight: 800;
}

.summary-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.table-wrap {
  overflow: auto;
  margin-top: 14px;
}

.submission-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

.submission-table th,
.submission-table td {
  border-bottom: 1px solid var(--line-soft);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.submission-table th {
  color: var(--rose-deep);
  background: #fff7fa;
}

.submission-table tr {
  cursor: pointer;
}

.submission-table tr:hover {
  background: #fff8fb;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
}

.admin-grid .admin-card {
  margin-top: 18px;
}

#feedbackText {
  margin-top: 12px;
  min-height: 170px;
  padding: 12px;
}

.submission-detail {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.submission-detail pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.state-ok {
  color: var(--mint);
}

.state-wait {
  color: var(--amber);
}

.state-muted {
  color: var(--muted);
}

.topic-panel.compact-topic,
.hint-panel.compact-hint,
.write-panel.compact-write-panel {
  margin-top: 0;
}

.topic-panel.compact-topic {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.write-panel.compact-write-panel {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

.topic-panel.compact-topic h1 {
  padding-right: 0;
  font-family: var(--writing-font);
  font-size: clamp(28px, 3.05vw, 52px);
  line-height: 1.35;
}

.hint-panel.compact-hint p {
  min-height: 82px;
  padding: 18px 20px;
  font-family: var(--writing-font);
  font-size: clamp(24px, 2.1vw, 34px);
  line-height: 1.55;
}

.write-panel.compact-write-panel .panel-heading {
  flex: 0 0 auto;
}

.write-panel.compact-write-panel .eyebrow {
  margin-bottom: 4px;
}

.write-panel.compact-write-panel h2 {
  font-size: 20px;
}

@media (max-height: 760px) and (min-width: 861px) {
  .brand {
    font-size: clamp(23px, 2.25vw, 31px);
  }

  .brand-date {
    font-size: 14px;
  }

  .student-login-form {
    grid-template-columns: 118px 136px auto;
  }

  .student-login-form input,
  .student-login-form button,
  .primary-button,
  .secondary-button,
  .danger-button {
    min-height: 38px;
    padding-top: 7px;
    padding-bottom: 7px;
  }

  .eyebrow {
    margin-bottom: 6px;
    font-size: 14px;
  }

  #writingText {
    line-height: 1.62;
  }
}

@media (max-width: 860px) {
  .student-page,
  .admin-page {
    width: min(100vw - 24px, 100%);
    margin: 12px auto;
    padding: 16px;
    border-radius: 14px;
  }

  .topbar,
  .admin-header,
  .panel-heading,
  .writing-tools,
  .button-row {
    align-items: stretch;
    flex-direction: column;
  }

  .compact-student-page {
    height: auto;
    min-height: calc(100vh - 24px);
    overflow: visible;
  }

  .header-tools,
  .student-login-form {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .topic-panel.compact-topic h1 {
    padding-right: 0;
  }

  .topic-helper-button {
    position: static;
    width: 100%;
    margin-top: 14px;
  }

  .identity-grid,
  .mailbox-grid,
  .summary-grid,
  .admin-grid,
  .login-form {
    grid-template-columns: 1fr;
  }

  .topic-panel {
    padding: 24px 16px;
  }

  .hint-panel,
  .write-panel,
  .mailbox-panel,
  .admin-card {
    padding: 18px;
  }

  .button-row button,
  .primary-button,
  .secondary-button,
  .danger-button {
    width: 100%;
  }
}
