* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --chalk: rgba(236, 229, 210, 0.94);
  --chalk-dim: rgba(210, 202, 182, 0.68);
  --board: #2d5a3d;
  --frame: #8b6914;
  --frame-dark: #6b4f0f;
}

body {
  font-family: 'Gaegu', 'Nanum Pen Script', cursive;
  background: var(--board);
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  color: var(--chalk);
  transition: background 0.4s;
}

body.font-0 { font-family: 'Gaegu', cursive; }
body.font-1 { font-family: 'Nanum Pen Script', cursive; }
body.font-2 { font-family: 'Black Han Sans', sans-serif; }
body.font-3 { font-family: 'Nanum Gothic', sans-serif; font-weight: 800; }

#app {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(255,255,255,0.03) 39px, rgba(255,255,255,0.03) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(255,255,255,0.02) 39px, rgba(255,255,255,0.02) 40px);
}

.chalkboard-frame {
  background: linear-gradient(180deg, #a07828 0%, var(--frame) 40%, var(--frame-dark) 100%);
  border-bottom: 4px solid #5a3e0a;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 3px 10px rgba(0,0,0,0.5);
  flex-shrink: 0;
}

.left-info {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.class-emblem {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  border: 2px solid rgba(255,255,255,0.2);
  flex-shrink: 0;
}

.class-emblem img { width: 100%; height: 100%; object-fit: cover; }

.class-meta { min-width: 0; }

.class-name {
  font-size: 1.9rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
}

.class-date { font-size: 1rem; color: rgba(255,255,255,0.85); }
.class-day { font-size: 1.15rem; color: #ffe97a; font-weight: 700; }

.class-switcher {
  margin-left: 10px;
  min-width: 160px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.18);
  color: #fff;
  font-family: 'Nanum Gothic', sans-serif;
  font-size: 0.85rem;
  outline: none;
}

.top-buttons { display: flex; gap: 10px; align-items: center; }

.top-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-family: inherit;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.emblem-btn { background: #4a9e6a; color: #fff; }
.font-btn { background: #3d8fb5; color: #fff; font-weight: 900; font-size: 1.3rem; }
.palette-btn { background: #b56e3d; color: #fff; }
.settings-btn { background: #6b6b8a; color: #fff; }
.logout-btn { background: #92554b; color: #fff; }
.top-btn:hover { transform: scale(1.08); }

.chalkboard-main {
  flex: 1;
  display: flex;
  min-height: 0;
}

.left-panel {
  width: 250px;
  flex-shrink: 0;
  padding: 12px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  min-width: 150px;
  max-width: 420px;
}

.left-panel.compact-panel .info-card {
  padding: 11px 11px 10px;
  border-radius: 14px;
}

.left-panel.compact-panel .card-label {
  font-size: 0.78rem;
  margin-bottom: 8px;
}

.left-panel.compact-panel .weather-content {
  flex-direction: column;
  align-items: flex-start;
}

.left-panel.compact-panel .weather-icon-big {
  width: 36px;
  height: 36px;
  font-size: 1.15rem;
}

.left-panel.compact-panel .temp-current {
  font-size: 1.05rem;
}

.left-panel.compact-panel .dust-row {
  flex-direction: column;
  gap: 4px;
}

.left-panel.compact-panel .meal-list,
.left-panel.compact-panel .activity-text,
.left-panel.compact-panel .temp-range {
  font-size: 0.8rem;
}

.left-panel.wide-panel .temp-current {
  font-size: 1.65rem;
}

.info-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.04)),
    rgba(28,58,44,0.72);
  border: 1px solid rgba(214,193,106,0.28);
  border-radius: 16px;
  padding: 14px 14px 13px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 10px 24px rgba(0,0,0,0.12);
  backdrop-filter: blur(6px);
}

.primary-card {
  border-color: rgba(214,193,106,0.45);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05)),
    rgba(38,77,57,0.8);
}

.card-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.9rem;
  color: rgba(243,234,215,0.86);
  margin-bottom: 10px;
}

.card-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--chalk-dim);
}

.meal-nav-btn {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.08);
  color: var(--chalk);
  cursor: pointer;
  font-family: inherit;
}

.meal-nav-btn:hover { background: rgba(255,255,255,0.16); }

.weather-content {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.weather-icon-big {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
  font-size: 1.5rem;
  flex-shrink: 0;
}

.weather-temps { display: flex; flex-direction: column; gap: 2px; }

.temp-current {
  font-size: 1.45rem;
  color: #fff4cc;
  font-weight: 700;
}

.temp-range,
.dust-row,
.meal-list,
.activity-text {
  font-size: 0.9rem;
  line-height: 1.5;
}

.dust-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--chalk-dim);
}

.meal-list { color: var(--chalk); }

.virtue-text {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff1b0;
  text-shadow: 0 2px 10px rgba(0,0,0,0.18);
}

.activity-text { color: var(--chalk); }

.panel-divider {
  width: 10px;
  flex-shrink: 0;
  cursor: col-resize;
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: center;
  user-select: none;
}

.panel-divider::before {
  content: '';
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  border-left: 2px dashed rgba(200,190,170,0.3);
  pointer-events: none;
  transition: border-color 0.2s;
}

.panel-divider:hover::before,
.panel-divider.dragging::before {
  border-color: rgba(255,233,122,0.7);
}

.letter-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px 18px 12px;
  position: relative;
  min-width: 0;
}

.letter-title {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--chalk-dim);
  margin-bottom: 8px;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
  flex-shrink: 0;
}

.letter-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-size: 2rem;
  line-height: 1.2;
  color: var(--chalk);
  text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
  overflow: hidden;
  padding: 6px 10px 2px;
}

.letter-content p {
  margin-bottom: 0.1em;
  text-align: center;
}

.letter-content .highlight {
  color: #ffe97a;
  border-bottom: 2px solid rgba(255,233,122,0.5);
  padding: 0 2px;
}

.letter-content.letter-editing {
  display: block;
  white-space: pre-wrap;
  outline: 2px dashed rgba(255,233,122,0.45);
  outline-offset: 8px;
  border-radius: 18px;
  padding: 12px 18px 8px;
}

.letter-placeholder {
  color: var(--chalk-dim);
  font-size: 1.3rem;
  text-align: center;
  line-height: 1.8;
}

.refresh-btn {
  position: absolute;
  bottom: 14px;
  right: 20px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--chalk);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.refresh-btn:hover { background: rgba(255,255,255,0.2); }
.refresh-btn.loading { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.mood-section {
  background: rgba(0,0,0,0.25);
  border-top: 2px dashed rgba(200,190,170,0.2);
  flex-shrink: 0;
}

.mood-toggle {
  text-align: center;
  padding: 6px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--chalk-dim);
  user-select: none;
}

.toggle-arrow { transition: transform 0.3s; display: inline-block; }

.mood-students {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px 12px;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.35s ease;
}

.mood-students.collapsed {
  max-height: 0 !important;
  padding-top: 0;
  padding-bottom: 0;
}

.student-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 5px 14px;
  color: var(--chalk);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.student-btn:hover { background: rgba(255,255,255,0.15); }

.student-mood-icon { width: 22px; height: 22px; cursor: pointer; }

.mood-selector {
  position: fixed;
  z-index: 1000;
  display: flex;
  gap: 6px;
  background: rgba(30,50,35,0.95);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 30px;
  padding: 8px 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  transform: translateY(-110%);
}

.mood-icon-wrapper {
  cursor: pointer;
  transition: transform 0.2s;
  font-size: 1.8rem;
  line-height: 1;
}

.mood-icon-wrapper:hover { transform: scale(1.15); }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.settings-modal,
.palette-modal {
  background: #1e3828;
  border-radius: 18px;
  width: 560px;
  max-width: calc(100vw - 24px);
  max-height: 88vh;
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.15);
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}

.palette-modal { width: 400px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--chalk);
  position: sticky;
  top: 0;
  background: #1e3828;
  z-index: 1;
}

.modal-header button {
  background: none;
  border: none;
  color: var(--chalk-dim);
  font-size: 1.3rem;
  cursor: pointer;
}

.settings-tabs {
  display: flex;
  gap: 4px;
  padding: 12px 22px 0;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 8px 18px;
  border: none;
  border-radius: 8px 8px 0 0;
  background: rgba(255,255,255,0.05);
  color: var(--chalk-dim);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.tab-btn.active {
  background: #ffe97a;
  color: #1e3828;
  font-weight: 700;
}

.tab-content {
  display: none;
  padding: 18px 22px 22px;
}

.tab-content.active { display: block; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  color: var(--chalk);
  font-size: 1rem;
}

.setting-sub {
  margin: -8px 0 14px;
  padding-left: 4px;
  font-size: 0.9rem;
  color: var(--chalk-dim);
}

.setting-group { margin-bottom: 18px; }
.setting-group > label,
.archive-section > label {
  display: block;
  color: var(--chalk-dim);
  font-size: 0.88rem;
  margin-bottom: 7px;
}

.text-input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--chalk);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
}

.text-input:focus { border-color: rgba(255,233,122,0.5); }

.grade-btns,
.virtue-grid,
.activity-examples {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.grade-btn,
.virtue-btn,
.activity-examples button {
  padding: 6px 14px;
  border-radius: 20px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--chalk);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
}

.grade-btn.active,
.virtue-btn.active {
  background: #4a9e6a;
  border-color: #4a9e6a;
  font-weight: 700;
}

.img-upload-area,
.student-upload,
.bg-upload-area {
  border: 2px dashed rgba(255,255,255,0.2);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  color: var(--chalk-dim);
  font-size: 0.9rem;
  margin-bottom: 10px;
  transition: border-color 0.2s;
}

.img-upload-area:hover,
.student-upload:hover,
.bg-upload-area:hover {
  border-color: rgba(255,233,122,0.4);
}

.student-upload button,
.btn-add,
.btn-save,
.btn-reset-s,
.btn-reset,
.btn-generate {
  cursor: pointer;
  font-family: inherit;
}

.student-upload button,
.btn-add {
  margin-top: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  background: #4a9e6a;
  border: none;
  color: #fff;
}

.student-count {
  font-size: 0.85rem;
  color: var(--chalk-dim);
  margin-bottom: 8px;
}

.student-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.student-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(74,158,106,0.3);
  border: 1px solid rgba(74,158,106,0.5);
  border-radius: 14px;
  padding: 3px 10px;
  font-size: 0.85rem;
  color: var(--chalk);
}

.student-tag button {
  background: none;
  border: none;
  color: var(--chalk-dim);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 0 0 4px;
}

.student-add-row,
.btn-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.btn-save {
  width: 100%;
  padding: 10px;
  background: #4a9e6a;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 1rem;
}

.btn-reset-s,
.btn-reset {
  padding: 10px 16px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  color: var(--chalk);
}

.btn-generate {
  width: 100%;
  padding: 13px;
  background: #ffe97a;
  border: none;
  border-radius: 10px;
  color: #1e3828;
  font-weight: 700;
  font-size: 1.05rem;
  margin-top: 8px;
}

.activity-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.activity-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.day-label {
  width: 24px;
  font-size: 1rem;
  font-weight: 700;
  color: #ffe97a;
  flex-shrink: 0;
}

.palette-section { padding: 16px 20px; }
.section-label { font-size: 0.88rem; color: var(--chalk-dim); margin-bottom: 10px; }

.color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.2s;
}

.color-dot:hover,
.color-dot.active {
  border-color: #ffe97a;
  transform: scale(1.15);
}

.toggle-switch { position: relative; display: inline-block; width: 46px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #555;
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider { background: #4a9e6a; }
input:checked + .slider:before { transform: translateX(22px); }

.archive-section {
  margin-top: 14px;
}

body.resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

body.resizing * { pointer-events: none !important; }
body.resizing #panelDivider { pointer-events: all !important; }

@media (max-width: 900px) {
  .left-panel { width: 210px !important; }
  .letter-content { font-size: 1.7rem; }
}
