:root {
  --bg: #f4f6fb;
  --card-bg: #ffffff;
  --accent: #3460f3;
  --accent-light: rgba(52, 96, 243, 0.1);
  --text: #1f2430;
  --muted: #5f6673;
  --success: #1ea97c;
  --warning: #f39c12;
  --danger: #d64545;
  --border: #d8dce5;
  --radius: 16px;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Noto Sans KR', 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  gap: 1.5rem;
}

.app-header .brand h1 {
  margin: 0;
  font-size: 1.8rem;
}

.app-header .brand p {
  margin: 0.3rem 0 0;
  color: var(--muted);
}

#user-form {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#user-form label {
  font-weight: 600;
}

#user-form input {
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

#user-form button {
  padding: 0.7rem 1.4rem;
  background: var(--accent);
  color: white;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.intro {
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.stage-flow {
  display: flex;
  gap: 0.8rem;
  list-style: none;
  padding: 0;
  margin: 1rem 0 1.5rem;
  flex-wrap: wrap;
}

.stage-flow li {
  background: var(--accent-light);
  color: var(--accent);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-weight: 600;
}

.plan {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.module-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
  min-height: 320px;
}

.module-stage {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
  background: var(--accent-light);
  color: var(--accent);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.module-card h3 {
  margin: 0;
  font-size: 1.4rem;
}

.module-summary {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  min-height: 72px;
}

.module-meta {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.activity-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.activity-item {
  padding: 0.9rem;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: rgba(52, 96, 243, 0.04);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.activity-item h4 {
  margin: 0;
}

.activity-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.instructions {
  margin: 0;
  padding-left: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

button.primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

button.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

button.secondary[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}

.panel {
  background: var(--card-bg);
  padding: 2rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.form-field input,
.form-field select,
.form-field textarea {
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

#checklist-items {
  display: grid;
  gap: 1rem;
  margin: 1.5rem 0;
}

.checklist-item {
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.02);
}

.checklist-item legend {
  font-weight: 700;
  margin-bottom: 0.6rem;
}

.checklist-item label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-right: 1rem;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  min-width: 240px;
  max-width: 320px;
  background: var(--text);
  color: white;
  padding: 1rem 1.2rem;
  border-radius: 12px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.activity-item.is-complete {
  border-color: var(--success);
  background: rgba(30, 169, 124, 0.08);
}

.activity-item.is-skipped {
  border-color: var(--warning);
  background: rgba(243, 156, 18, 0.08);
}

.activity-status {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--success);
}

.activity-status.skipped {
  color: var(--warning);
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal[hidden] {
  display: none;
}

.modal-content {
  background: var(--card-bg);
  border-radius: var(--radius);
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 2rem;
}

.passage-text {
  background: rgba(52, 96, 243, 0.05);
  padding: 1.5rem;
  border-radius: 12px;
  line-height: 1.8;
  margin-bottom: 1.5rem;
  border-left: 4px solid var(--accent);
}

.question-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.question-item h4 {
  margin: 0 0 1rem;
  color: var(--accent);
}

.question-options {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin: 1rem 0;
}

.question-options label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.question-options label:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

.question-options input[type="radio"] {
  cursor: pointer;
}

.blank-input {
  display: inline-block;
  min-width: 150px;
  padding: 0.4rem 0.8rem;
  border: none;
  border-bottom: 2px solid var(--accent);
  background: transparent;
  font-size: 1rem;
  margin: 0 0.3rem;
}

.blank-input:focus {
  outline: none;
  border-bottom-color: var(--success);
}

.stage-content {
  margin-bottom: 2rem;
}

.stage-content h3 {
  color: var(--accent);
  margin-bottom: 1rem;
}

.hint-box {
  background: rgba(243, 156, 18, 0.1);
  border-left: 4px solid var(--warning);
  padding: 1rem;
  border-radius: 8px;
  margin: 1rem 0;
}

.mindmap-canvas {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 2rem;
  min-height: 300px;
  background: rgba(52, 96, 243, 0.02);
  margin: 1rem 0;
}

.mindmap-node {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  background: var(--accent-light);
  border: 2px solid var(--accent);
  border-radius: 999px;
  margin: 0.5rem;
  font-weight: 600;
}

.mindmap-branch {
  margin-left: 2rem;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
}

.submit-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.8rem 2rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 1rem;
  margin-top: 1rem;
}

.submit-btn:hover {
  opacity: 0.9;
}

.next-stage-btn {
  background: var(--success);
  color: white;
  border: none;
  padding: 0.8rem 2rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 1rem;
  margin-top: 1rem;
}

.result-box {
  background: rgba(30, 169, 124, 0.1);
  border-left: 4px solid var(--success);
  padding: 1.5rem;
  border-radius: 8px;
  margin: 1.5rem 0;
}

.result-box.incorrect {
  background: rgba(214, 69, 69, 0.1);
  border-left-color: var(--danger);
}

@media (max-width: 768px) {
  #user-form {
    width: 100%;
    justify-content: flex-start;
  }

  .plan {
    grid-template-columns: 1fr;
  }

  .modal-content {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .modal-body {
    padding: 1.5rem;
  }
}
