/* ─── Reset & base ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: #f5f3ee;
  color: #2c2c2c;
  min-height: 100vh;
}

/* ─── Nickname overlay ───────────────────────────────── */
#nickname-screen {
  position: fixed;
  inset: 0;
  background: rgba(30, 20, 10, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.nickname-card {
  background: #fff;
  border-radius: 12px;
  padding: 2.5rem 2rem;
  width: min(360px, 90vw);
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.nickname-card .logo {
  font-size: 2.5rem;
  letter-spacing: 4px;
}

.nickname-card h1 {
  font-size: 1.4rem;
  color: #1a1a1a;
}

.nickname-card p {
  font-size: 0.95rem;
  color: #666;
}

.nickname-card input {
  width: 100%;
  padding: 0.65rem 1rem;
  font-size: 1rem;
  border: 1.5px solid #ccc;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.2s;
}

.nickname-card input:focus {
  border-color: #4a7c59;
}

.nickname-card button {
  padding: 0.7rem 1.5rem;
  font-size: 1rem;
  background: #4a7c59;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.nickname-card button:hover:not(:disabled) {
  background: #3a6247;
}

.nickname-card button:disabled {
  background: #aaa;
  cursor: not-allowed;
}

/* ─── Header ─────────────────────────────────────────── */
header {
  background: #2c2c2c;
  color: #fff;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

header h1 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

#user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

#switch-user {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  padding: 0.3rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s;
}

#switch-user:hover {
  background: rgba(255,255,255,0.15);
}

/* ─── Day navigation ─────────────────────────────────── */
#day-nav {
  background: #e8e4db;
  border-bottom: 1px solid #d4cfc5;
  padding: 0.6rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}

/* Each week row */
.nav-week {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.nav-week-label {
  font-size: 0.72rem;
  color: #888;
  font-weight: 600;
  min-width: 2.8rem;
  letter-spacing: 0.02em;
}

.nav-week-btns {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

/* Individual day button (compact number style) */
.nav-btn {
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  font-size: 0.82rem;
  font-weight: 500;
  background: #fff;
  border: 1.5px solid #ccc;
  border-radius: 50%;
  cursor: pointer;
  color: #555;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.nav-btn:hover {
  border-color: #4a7c59;
  color: #4a7c59;
}

.nav-btn.active {
  background: #4a7c59;
  border-color: #4a7c59;
  color: #fff;
}

/* Answered: green fill with subtle indicator */
.nav-btn.answered {
  background: #e8f4ec;
  border-color: #4a7c59;
  color: #2d6040;
  font-weight: 700;
}

.nav-btn.answered::after {
  content: '✓';
  position: absolute;
  top: -4px;
  right: -4px;
  width: 12px;
  height: 12px;
  background: #4a7c59;
  color: #fff;
  border-radius: 50%;
  font-size: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.nav-btn.answered.active {
  background: #4a7c59;
  color: #fff;
}

/* Lecture days: slightly different style (bookmark icon) */
.nav-btn.lecture {
  border-style: dashed;
}

.nav-btn.lecture.answered {
  border-style: solid;
}

/* ─── Main content ───────────────────────────────────── */
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

#welcome-msg {
  text-align: center;
  padding: 4rem 1rem;
  color: #888;
  font-size: 1.05rem;
}

/* ─── Problem area ───────────────────────────────────── */
#problem-header {
  margin-bottom: 1rem;
}

#problem-day-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #1a1a1a;
}

/* ─── Board image ────────────────────────────────────── */
#board-image {
  display: block;
  width: 100%;
  max-width: 520px;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  margin: 0 auto 1.5rem;
}

/* ─── Problem text (markdown) ────────────────────────── */
#problem-text {
  background: #fff;
  border: 1px solid #e0dbd2;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.75rem;
  line-height: 1.85;
  font-size: 1rem;
}

#problem-text p { margin-bottom: 0.6em; }
#problem-text p:last-child { margin-bottom: 0; }

.loading { color: #999; font-style: italic; }

/* ─── Answer section ─────────────────────────────────── */
#answer-section,
#answered-section,
#video-section {
  background: #fff;
  border: 1px solid #e0dbd2;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

#answer-section h3,
#answered-section h3,
#video-section h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: #333;
  border-bottom: 1px solid #eee;
  padding-bottom: 0.5rem;
}

/* Choice question */
.choice-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.97rem;
  transition: background 0.15s;
  margin-bottom: 0.4rem;
}

.choice-label:hover {
  background: #f0ede6;
}

.choice-label input[type="radio"] {
  accent-color: #4a7c59;
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

/* Text question */
#answer-input textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.97rem;
  font-family: inherit;
  border: 1.5px solid #ccc;
  border-radius: 6px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.7;
}

#answer-input textarea:focus {
  border-color: #4a7c59;
}

/* Submit button */
#submit-btn {
  display: block;
  margin-top: 1rem;
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  background: #4a7c59;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
  font-weight: 600;
}

#submit-btn:hover:not(:disabled) {
  background: #3a6247;
}

#submit-btn:disabled {
  background: #b0b0b0;
  cursor: not-allowed;
}

/* Error message */
.error {
  color: #c0392b;
  font-size: 0.9rem;
  margin-top: 0.6rem;
}

/* ─── Answered display (read-only) ───────────────────── */
.answered-display {
  background: #f0ede6;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 0.97rem;
  color: #2c2c2c;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ─── Video section ──────────────────────────────────── */
#answer-video {
  width: 100%;
  border-radius: 6px;
  background: #000;
  display: block;
}

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 480px) {
  header {
    padding: 0.6rem 1rem;
  }

  header h1 {
    font-size: 1rem;
  }

  #problem-text,
  #answer-section,
  #answered-section,
  #video-section {
    padding: 1rem;
  }
}
