/* ===== Shared Design System — Education Tools v1.0 ===== */
/* Based on: Educational App UI Kit (Figma Community) */
/* Accent: #5B6ABF (보라-파랑) */

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css');
@import url('icons.css');

/* ── Design Tokens ── */
:root {
  /* Colors */
  --bg: #ffffff;
  --surface: #eef0f7;
  --surface-hover: #e4e7f2;
  --primary: #5B6ABF;
  --primary-light: #dee3f4;
  --primary-dark: #4A57A0;
  --primary-bg: #f0f1fa;
  --text: #3a3d4a;
  --text-light: #686c80;
  --text-muted: #9498a8;
  --border: #e2e5ef;
  --success: #4caf50;
  --success-light: #e8f5e9;
  --danger: #e74c3c;
  --danger-light: #fdecea;
  --warning: #f39c12;
  --warning-light: #fff8e1;

  /* Typography */
  --font: 'Pretendard Variable', 'Pretendard', 'Apple SD Gothic Neo', -apple-system, sans-serif;
  --fs-xl: 22px;
  --fs-lg: 17px;
  --fs-md: 15px;
  --fs-sm: 13px;
  --fs-xs: 11px;

  /* Spacing & Radius */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 30px;
  --gap: 12px;
  --pad: 16px;

  /* Layout */
  --app-max: 800px;
  --header-h: 48px;
  --tabbar-h: 56px;

  /* Shadow */
  --shadow-sm: 0 1px 3px rgba(91,106,191,.06);
  --shadow-md: 0 4px 12px rgba(91,106,191,.08);
}

/* ── Base Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: var(--fs-md);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── App Shell ── */
.app {
  max-width: var(--app-max);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── Header (미니멀) ── */
.header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 var(--pad);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 12px;
}
.header h1, .header .header-title {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-back {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: var(--text-light);
  font-size: 18px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.header-back:hover { background: var(--surface); }
.header-actions {
  margin-left: auto;
  display: flex; gap: 8px; align-items: center;
}

/* ── Bottom Tab Bar ── */
.bottom-tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max);
  height: var(--tabbar-h);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-tabbar .tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-family: var(--font);
  font-weight: 500;
  transition: color .2s;
  -webkit-tap-highlight-color: transparent;
  min-width: 48px;
}
.bottom-tabbar .tab-item .tab-icon {
  font-size: 22px;
  line-height: 1;
  transition: transform .15s;
}
.bottom-tabbar .tab-item.active {
  color: var(--primary);
}
.bottom-tabbar .tab-item.active .tab-icon {
  transform: scale(1.1);
}

/* ── Content Area ── */
.content {
  flex: 1;
  padding: var(--pad);
  padding-bottom: calc(var(--tabbar-h) + var(--pad) + env(safe-area-inset-bottom, 0));
  overflow-y: auto;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--pad);
  border: none;
}
.card + .card { margin-top: var(--gap); }
.card-title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.card-body { color: var(--text-light); font-size: var(--fs-sm); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .2s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(.97); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-bg); }

.btn-ghost {
  background: transparent;
  color: var(--text-light);
  padding: 8px 14px;
}
.btn-ghost:hover { background: var(--surface); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #c0392b; }

.btn-sm { padding: 6px 14px; font-size: var(--fs-xs); }
.btn-lg { padding: 14px 28px; font-size: var(--fs-md); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Chip / Pill (선택 칩) ── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 500;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text-light);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all .2s;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover { background: var(--surface-hover); }
.chip.active, .chip.selected {
  background: var(--primary-bg);
  color: var(--primary);
  border-color: var(--primary);
}

/* ── Input / Textarea ── */
.input, .textarea, .select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: var(--fs-sm);
  color: var(--text);
  background: var(--bg);
  transition: border-color .2s;
  outline: none;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--primary);
}
.textarea { resize: vertical; min-height: 80px; }
.select { appearance: none; cursor: pointer; }

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }

/* ── Modal (하단 시트) ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-sheet {
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: var(--app-max);
  max-height: 85vh;
  overflow-y: auto;
  padding: var(--pad);
  animation: slideUp .25s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 12px;
}
.modal-title {
  font-size: var(--fs-lg);
  font-weight: 600;
  margin-bottom: 12px;
}

/* ── Sub Tabs (가로 스크롤 칩) ── */
.sub-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.sub-tabs::-webkit-scrollbar { display: none; }
.sub-tabs .sub-tab {
  flex-shrink: 0;
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 500;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text-light);
  border: none;
  cursor: pointer;
  transition: all .2s;
  -webkit-tap-highlight-color: transparent;
}
.sub-tabs .sub-tab.active {
  background: var(--primary);
  color: #fff;
}

/* ── Progress Bar ── */
.progress {
  height: 10px;
  background: var(--bg);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 5px;
  transition: width .3s ease;
}

/* ── Divider ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--pad) 0;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(var(--tabbar-h) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  z-index: 1000;
  animation: fadeInUp .25s ease-out;
  max-width: calc(var(--app-max) - 32px);
  text-align: center;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ── Section Title ── */
.section-title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.section-desc {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-bottom: var(--gap);
}

/* ── Grid ── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap);
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: .5;
}
.empty-state p {
  font-size: var(--fs-sm);
  line-height: 1.5;
}

/* ── Fixed Bottom Bar (생성바 등) ── */
.fixed-bar {
  position: fixed;
  bottom: var(--tabbar-h);
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max);
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 10px var(--pad);
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Responsive ── */
@media (max-width: 520px) {
  :root {
    --pad: 14px;
    --fs-xl: 20px;
    --fs-lg: 16px;
  }
}

@media (max-width: 520px) {
  :root {
    --app-max: 100%;
  }
}

/* ── Utility ── */
.text-primary { color: var(--primary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }
.fw-600 { font-weight: 600; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }
