/* ===================================================
   1학년 6반 자리바꾸기 — 디즈니/지브리 감성 스타일
   =================================================== */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;600;700;800;900&display=swap');

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

:root {
  /* 지브리·디즈니 팔레트 */
  --sky:        #c8e6f5;
  --sky-deep:   #7bbfdc;
  --meadow:     #a8d5a2;
  --meadow-dk:  #5fa85a;
  --sun:        #f9e07a;
  --sun-dk:     #e8b930;
  --lavender:   #c9b8f0;
  --lavender-dk:#7c6aad;
  --rose:       #f4b8c8;
  --rose-dk:    #c0607a;
  --cream:      #fdf6e3;
  --parchment:  #f5ead0;

  /* 기능 색 */
  --male:       #5a9bd6;
  --male-bg:    #deeef9;
  --male-bdr:   #9acaec;
  --female:     #d45f8a;
  --female-bg:  #fce8f0;
  --female-bdr: #f0a0bf;
  --fixed:      #c8860a;
  --fixed-bg:   #fff3d0;
  --fixed-bdr:  #f0c060;
  --empty-bg:   #d8d0c8;
  --empty-bdr:  #b0a898;
  --empty-txt:  #888078;

  --bg:         #eaf4fb;
  --card:       #fffef8;
  --border:     #ddd5c8;
  --text:       #3a3228;
  --text-muted: #7a6e60;
  --radius:     16px;
  --shadow:     0 6px 28px rgba(100,80,50,.13);
  --shadow-sm:  0 2px 10px rgba(100,80,50,.09);
}

/* ── 배경 — 지브리 하늘 + 구름 ── */
body {
  font-family: 'Noto Sans KR', sans-serif;
  background-color: var(--sky);
  background-image:
    radial-gradient(ellipse 280px 120px at 15% 18%, rgba(255,255,255,.85) 0%, transparent 70%),
    radial-gradient(ellipse 200px 90px at 35% 12%, rgba(255,255,255,.7) 0%, transparent 70%),
    radial-gradient(ellipse 340px 130px at 72% 22%, rgba(255,255,255,.8) 0%, transparent 70%),
    radial-gradient(ellipse 180px 80px at 88% 10%, rgba(255,255,255,.65) 0%, transparent 70%),
    linear-gradient(180deg, #b8e0f5 0%, #cceeff 40%, #dff0d8 100%);
  min-height: 100vh;
  color: var(--text);
}

/* ── 헤더 — 마법 성문 느낌 ── */
.site-header {
  background: linear-gradient(135deg, #7bbfdc 0%, #9aaed4 45%, #b89fd4 100%);
  color: #fff;
  padding: 0;
  box-shadow: 0 4px 20px rgba(80,100,160,.3), 0 1px 0 rgba(255,255,255,.4) inset;
  position: relative;
  overflow: hidden;
}

/* 헤더 장식 별빛 */
.site-header::before {
  content: '✦ ✧ ✦ ✧ ✦ ✧ ✦ ✧ ✦ ✧ ✦ ✧ ✦ ✧ ✦ ✧ ✦';
  position: absolute;
  top: 6px; left: 0; right: 0;
  text-align: center;
  font-size: .7rem;
  color: rgba(255,255,255,.45);
  letter-spacing: 6px;
  pointer-events: none;
}
.site-header::after {
  content: '✦ ✧ ✦ ✧ ✦ ✧ ✦ ✧ ✦ ✧ ✦ ✧ ✦ ✧ ✦ ✧ ✦';
  position: absolute;
  bottom: 6px; left: 0; right: 0;
  text-align: center;
  font-size: .7rem;
  color: rgba(255,255,255,.35);
  letter-spacing: 6px;
  pointer-events: none;
}

.header-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 22px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  position: relative;
  z-index: 1;
}
.header-title {
  display: flex;
  align-items: center;
  gap: 16px;
}
.header-emoji {
  font-size: 2.6rem;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.25));
  animation: floatEmoji 3s ease-in-out infinite;
}
@keyframes floatEmoji {
  0%,100% { transform: translateY(0) rotate(-4deg); }
  50%      { transform: translateY(-6px) rotate(4deg); }
}
.header-title h1 {
  font-size: 1.7rem;
  font-weight: 900;
  line-height: 1.15;
  text-shadow: 0 2px 8px rgba(0,0,0,.2);
  letter-spacing: -.02em;
}
.header-title p {
  font-size: .82rem;
  opacity: .85;
  margin-top: 3px;
  letter-spacing: .04em;
}
.header-meta {
  font-size: .78rem;
  background: rgba(255,255,255,.22);
  border: 1px solid rgba(255,255,255,.35);
  padding: 7px 16px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
}

/* ── 메인 ── */
.main-wrap {
  max-width: 920px;
  margin: 30px auto;
  padding: 0 16px 70px;
}

/* ── 탭 네비게이션 ── */
.tab-nav {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin-bottom: 26px;
  flex-wrap: wrap;
  border-bottom: 3px solid rgba(120,100,80,.15);
  padding-bottom: 0;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 11px 22px;
  border: 2px solid transparent;
  background: rgba(255,255,255,.55);
  color: var(--text-muted);
  font-family: inherit;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 14px 14px 0 0;
  border-bottom: 3px solid transparent;
  margin-bottom: -3px;
  transition: all .22s;
  backdrop-filter: blur(6px);
}
.tab-btn:hover  { color: var(--lavender-dk); background: rgba(255,255,255,.75); }
.tab-btn.active {
  color: var(--lavender-dk);
  background: var(--card);
  border-color: rgba(120,100,80,.15) rgba(120,100,80,.15) var(--card);
  border-bottom-color: var(--card);
  box-shadow: 0 -4px 12px rgba(150,130,200,.15);
  font-weight: 800;
}

.saved-tabs { display: flex; gap: 6px; flex-wrap: wrap; }

.tab-saved-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 11px 16px;
  border: 2px solid transparent;
  background: rgba(255,255,255,.5);
  color: var(--text-muted);
  font-family: inherit;
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 14px 14px 0 0;
  border-bottom: 3px solid transparent;
  margin-bottom: -3px;
  transition: all .22s;
  white-space: nowrap;
}
.tab-saved-btn:hover  { color: var(--meadow-dk); background: rgba(255,255,255,.7); }
.tab-saved-btn.active {
  color: var(--meadow-dk);
  background: var(--card);
  border-color: rgba(120,100,80,.15) rgba(120,100,80,.15) var(--card);
  border-bottom-color: var(--card);
  font-weight: 700;
}

.tab-del-btn {
  background: none; border: none;
  color: rgba(180,160,140,.6);
  cursor: pointer; font-size: .7rem;
  padding: 0 2px; transition: color .2s;
}
.tab-del-btn:hover { color: #e05050; }

/* ── 탭 콘텐츠 래퍼 ── */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── 컨트롤 패널 ── */
.control-panel {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

/* ── 버튼 — 지브리 마법서 버튼 ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 15px 36px;
  border: none;
  border-radius: 50px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: all .24s cubic-bezier(.36,1.56,.64,1);
  position: relative;
  overflow: hidden;
  letter-spacing: .02em;
}
.btn::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(255,255,255,.0);
  border-radius: inherit;
  transition: background .2s;
}
.btn:hover::after { background: rgba(255,255,255,.15); }
.btn:active { transform: scale(.96); }

.btn-primary {
  background: linear-gradient(135deg, #7bbfdc 0%, #9aaed4 50%, #b89fd4 100%);
  color: #fff;
  box-shadow: 0 6px 20px rgba(120,140,200,.4), 0 1px 0 rgba(255,255,255,.3) inset;
}
.btn-primary:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 12px 28px rgba(120,140,200,.5);
}

.btn-save {
  background: linear-gradient(135deg, #7ec87e 0%, #5ab05a 100%);
  color: #fff;
  box-shadow: 0 6px 20px rgba(80,160,80,.35), 0 1px 0 rgba(255,255,255,.3) inset;
}
.btn-save:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 12px 28px rgba(80,160,80,.45);
}

.btn-cancel {
  background: var(--parchment);
  color: var(--text-muted);
  border: 2px solid var(--border);
  box-shadow: none;
}
.btn-cancel:hover { background: #ede4cc; }

/* ── 카운트다운 ── */
.countdown-wrap {
  display: flex;
  justify-content: center;
  margin: 16px 0 30px;
}
.countdown-box {
  background: var(--card);
  border: 3px solid var(--lavender);
  border-radius: 28px;
  padding: 44px 70px;
  text-align: center;
  box-shadow: var(--shadow), 0 0 0 6px rgba(200,184,240,.18);
  min-width: 280px;
  position: relative;
  overflow: hidden;
}
/* 마법 파티클 장식 */
.countdown-box::before {
  content: '✨';
  position: absolute; top: 14px; right: 18px;
  font-size: 1.4rem;
  animation: twinkle 1.5s ease-in-out infinite;
}
.countdown-box::after {
  content: '⭐';
  position: absolute; bottom: 14px; left: 18px;
  font-size: 1.2rem;
  animation: twinkle 1.5s .5s ease-in-out infinite;
}
@keyframes twinkle {
  0%,100% { opacity:.6; transform:scale(1) rotate(0deg); }
  50%      { opacity:1; transform:scale(1.25) rotate(15deg); }
}
.countdown-label {
  font-size: .9rem;
  color: var(--text-muted);
  margin-bottom: 18px;
  font-weight: 600;
  letter-spacing: .04em;
}
.countdown-number {
  font-size: 5.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, #7bbfdc, #b89fd4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  animation: magicPulse 1s ease-in-out infinite;
}
@keyframes magicPulse {
  0%,100% { transform: scale(1); filter: brightness(1); }
  50%      { transform: scale(1.14); filter: brightness(1.15); }
}
.countdown-bar-wrap {
  margin-top: 22px;
  background: #e8e0d0;
  border-radius: 50px;
  height: 9px;
  overflow: hidden;
}
.countdown-bar {
  height: 100%;
  background: linear-gradient(90deg, #7bbfdc, #9aaed4, #b89fd4);
  border-radius: 50px;
  width: 100%;
  transition: width 1s linear;
}

/* ── 교실 래퍼 ── */
.classroom-wrap {
  animation: magicPopIn .55s cubic-bezier(.36,1.56,.64,1) both;
}
@keyframes magicPopIn {
  0%   { opacity:0; transform:scale(.65) translateY(40px); filter:blur(4px); }
  60%  { filter:blur(0); }
  100% { opacity:1; transform:scale(1) translateY(0); }
}

.classroom-label-top {
  text-align: center;
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  letter-spacing: .06em;
  font-weight: 500;
}

/* ── 교실 그리드 ── */
.classroom {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  max-width: 740px;
  margin: 0 auto;
  padding: 28px;
  background: linear-gradient(160deg, #fffef5 0%, #fdf5e0 100%);
  border: 3px solid rgba(200,180,140,.3);
  border-radius: 22px;
  box-shadow: var(--shadow), 0 0 0 8px rgba(248,240,220,.5);
  position: relative;
}

/* 열 구분선 */
.classroom::before,
.classroom::after {
  content: '';
  position: absolute;
  top: 18px; bottom: 18px;
  width: 2px;
  background: linear-gradient(180deg, transparent, rgba(180,160,120,.25) 20%, rgba(180,160,120,.25) 80%, transparent);
  border-radius: 2px;
  pointer-events: none;
}
.classroom::before { left: calc(28px + (100% - 56px) / 3 + 5px); }
.classroom::after  { left: calc(28px + (100% - 56px) * 2 / 3 + 5px); }

/* ── 좌석 카드 ── */
.seat {
  position: relative;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 10px 6px 8px;
  text-align: center;
  min-height: 74px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform .2s cubic-bezier(.36,1.56,.64,1), box-shadow .2s;
  cursor: default;
  animation: seatAppear .4s ease both;
}
@keyframes seatAppear {
  from { opacity:0; transform:scale(.75) translateY(12px); }
  to   { opacity:1; transform:scale(1) translateY(0); }
}
.seat:hover {
  transform: translateY(-4px) scale(1.04);
  box-shadow: 0 10px 24px rgba(100,80,50,.14);
  z-index: 2;
}

/* 남학생 — 하늘빛 */
.seat.male {
  border-color: var(--male-bdr);
  background: linear-gradient(145deg, #f0f8ff, var(--male-bg));
  box-shadow: 0 2px 8px rgba(90,155,214,.12), 0 1px 0 rgba(255,255,255,.8) inset;
}

/* 여학생 — 장미빛 */
.seat.female {
  border-color: var(--female-bdr);
  background: linear-gradient(145deg, #fff5f8, var(--female-bg));
  box-shadow: 0 2px 8px rgba(212,95,138,.12), 0 1px 0 rgba(255,255,255,.8) inset;
}

/* 고정석 — 황금빛 */
.seat.fixed {
  border-color: var(--fixed-bdr);
  background: linear-gradient(145deg, #fffbe8, var(--fixed-bg));
  box-shadow: 0 2px 10px rgba(200,134,10,.18), 0 0 0 3px rgba(240,192,96,.2), 0 1px 0 rgba(255,255,255,.8) inset;
}

/* 빈자리 — 부드러운 회색 */
.seat.empty-seat {
  border: 2px dashed var(--empty-bdr);
  background: linear-gradient(145deg, #ede8e0, var(--empty-bg));
  box-shadow: none;
  cursor: not-allowed;
  opacity: .75;
}
.seat.empty-seat:hover {
  transform: none;
  box-shadow: none;
}

/* 좌석 번호 */
.seat-num {
  font-size: .6rem;
  font-weight: 700;
  color: rgba(150,130,100,.6);
  position: absolute;
  top: 5px; left: 7px;
  line-height: 1;
}
.seat.fixed .seat-num   { color: rgba(180,120,20,.5); }
.seat.empty-seat .seat-num { color: var(--empty-txt); }

/* 이름 */
.seat-name {
  font-size: .88rem;
  font-weight: 700;
  line-height: 1.2;
  margin-top: 4px;
}
.seat.male   .seat-name { color: #2a6aaa; }
.seat.female .seat-name { color: #a03060; }
.seat.fixed  .seat-name { color: #8a5800; }
.seat.empty-seat .seat-name {
  color: var(--empty-txt);
  font-weight: 400;
  font-size: .74rem;
}

/* 성별 아이콘 */
.seat-gender { font-size: .68rem; margin-top: 3px; opacity: .75; }
.seat.male   .seat-gender { color: var(--male); }
.seat.female .seat-gender { color: var(--female); }

/* 고정 뱃지 */
.fixed-badge {
  position: absolute;
  top: 4px; right: 5px;
  font-size: .56rem;
  background: linear-gradient(135deg, #f0c060, #e8980a);
  color: #fff;
  padding: 2px 5px;
  border-radius: 6px;
  font-weight: 800;
  letter-spacing: .02em;
  box-shadow: 0 1px 4px rgba(200,130,0,.3);
}

/* ── 교탁 ── */
.teacher-desk {
  max-width: 740px;
  margin: 14px auto 0;
  background: linear-gradient(135deg, #fef6d0, #fde8a0);
  border: 3px solid #f0c050;
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  font-weight: 800;
  font-size: .95rem;
  color: #8a6000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 16px rgba(200,160,0,.18);
  letter-spacing: .04em;
}

/* ── 범례 ── */
.legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  margin-top: 22px;
  flex-wrap: wrap;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 500;
}
.legend-dot {
  width: 16px; height: 16px;
  border-radius: 5px;
  border: 2px solid transparent;
}
.legend-dot.male   { background: var(--male-bg); border-color: var(--male-bdr); }
.legend-dot.female { background: var(--female-bg); border-color: var(--female-bdr); }
.legend-dot.empty  { background: var(--empty-bg); border: 2px dashed var(--empty-bdr); }

/* ── 초기 안내 — 지브리 마법 광장 ── */
.empty-state {
  text-align: center;
  padding: 80px 20px;
}
.empty-icon {
  font-size: 4.5rem;
  margin-bottom: 24px;
  animation: magicBounce 2.4s cubic-bezier(.36,1.56,.64,1) infinite;
  display: inline-block;
  filter: drop-shadow(0 8px 14px rgba(120,100,200,.25));
}
@keyframes magicBounce {
  0%,100% { transform: translateY(0) rotate(-5deg) scale(1); }
  40%      { transform: translateY(-18px) rotate(5deg) scale(1.08); }
  70%      { transform: translateY(-8px) rotate(-2deg) scale(1.04); }
}
.empty-state h2 {
  font-size: 1.55rem;
  font-weight: 900;
  color: var(--lavender-dk);
  margin-bottom: 12px;
  text-shadow: 0 2px 8px rgba(150,130,200,.15);
}
.empty-state p { color: var(--text-muted); font-size: .95rem; font-weight: 500; }

/* ── 저장 뷰 ── */
.saved-view { padding: 10px 0; }
.saved-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 10px;
}
.saved-view-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 9px;
}
.btn-delete-save {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: 2px solid #f0c0c0;
  background: #fff5f5;
  color: #d04040;
  border-radius: 50px;
  font-family: inherit;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
}
.btn-delete-save:hover { background: #fee0e0; border-color: #e04040; }

/* ── 모달 ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(40,30,20,.45);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

.modal {
  background: var(--cream);
  border: 3px solid var(--lavender);
  border-radius: 24px;
  width: 100%;
  max-width: 420px;
  margin: 16px;
  box-shadow: 0 28px 60px rgba(80,60,120,.25);
  animation: slideUpMagic .28s cubic-bezier(.36,1.56,.64,1);
  position: relative;
  overflow: hidden;
}
/* 모달 상단 장식 */
.modal::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 5px;
  background: linear-gradient(90deg, #7bbfdc, #9aaed4, #b89fd4, #c9b8f0);
  border-radius: 24px 24px 0 0;
}
@keyframes slideUpMagic {
  from { transform:translateY(30px) scale(.94); opacity:0; }
  to   { transform:translateY(0) scale(1); opacity:1; }
}

.modal-header {
  padding: 24px 26px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--border);
}
.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--lavender-dk);
}
.modal-close {
  background: var(--parchment);
  border: 2px solid var(--border);
  border-radius: 50%;
  width: 34px; height: 34px;
  cursor: pointer;
  font-size: .85rem;
  color: var(--text-muted);
  transition: all .2s;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: #fee0e0; border-color: #e04040; color: #e04040; }

.modal-body { padding: 20px 26px; }
.modal-desc {
  color: var(--text-muted);
  font-size: .86rem;
  margin-bottom: 18px;
  font-weight: 500;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.form-row label {
  font-weight: 700;
  font-size: .88rem;
  width: 44px;
  flex-shrink: 0;
  color: var(--lavender-dk);
}
.form-row select {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-family: inherit;
  font-size: .9rem;
  color: var(--text);
  background: #fff;
  cursor: pointer;
  transition: border-color .2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23aaa' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
.form-row select:focus { outline: none; border-color: var(--lavender-dk); }

.form-preview {
  background: linear-gradient(135deg, #f0ecff, #e8f4ff);
  border: 2px solid var(--lavender);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: .86rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.form-preview strong { color: var(--lavender-dk); font-weight: 800; }

.modal-footer {
  padding: 14px 26px 22px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── 토스트 ── */
.toast {
  position: fixed;
  bottom: 32px; left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: linear-gradient(135deg, #3a3228, #5a4e40);
  color: #fdf6e3;
  padding: 14px 30px;
  border-radius: 50px;
  font-size: .88rem;
  font-weight: 700;
  z-index: 9999;
  opacity: 0;
  transition: all .38s cubic-bezier(.36,1.56,.64,1);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(40,30,20,.3);
  border: 2px solid rgba(255,255,255,.1);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── 반응형 ── */
@media (max-width: 660px) {
  .classroom { padding: 14px; gap: 7px; }
  .seat { min-height: 62px; padding: 8px 4px 6px; border-radius: 10px; }
  .seat-name { font-size: .78rem; }
  .btn { padding: 12px 24px; font-size: .9rem; }
  .countdown-box { padding: 32px 40px; }
  .countdown-number { font-size: 4.5rem; }
  .header-inner { padding: 18px 16px; }
}
