/* treedoc — modern Korean study portal */
* { box-sizing: border-box; }
:root {
  --bg: #fafaf7;
  --card: #ffffff;
  --line: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #16a34a;
  --primary-dark: #15803d;
  --danger: #dc2626;
}
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Pretendard', 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}
.topbar {
  background: white;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; }
.brand .muted { font-weight: 400; margin-left: 8px; }
.navlinks { display: flex; gap: 18px; flex: 1; }
.navlinks a { color: var(--muted); text-decoration: none; }
.navlinks a:hover { color: var(--text); }
.userbox { display: flex; gap: 12px; align-items: center; }

.content { max-width: 1200px; margin: 24px auto; padding: 0 24px; }
.muted { color: var(--muted); font-size: 13px; }

h1 { font-size: 28px; margin: 0 0 8px; }
h2 { font-size: 20px; margin: 32px 0 16px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
h3 { font-size: 16px; margin: 24px 0 12px; }

.hero { padding: 16px 0 24px; }
.hero h1 { font-size: 32px; }

.stat-row { display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 24px;
  flex: 1;
  min-width: 120px;
  text-align: center;
}
.stat-card strong { display: block; font-size: 28px; color: var(--primary); }
.stat-card span { color: var(--muted); font-size: 13px; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.subject-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 6px solid var(--primary);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  gap: 16px;
  text-decoration: none;
  color: var(--text);
  transition: transform .15s, box-shadow .15s;
}
.subject-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.06); }
.subject-card .icon { font-size: 32px; }
.subject-card .title { font-weight: 700; font-size: 17px; }
.subject-card .desc { margin-top: 2px; font-size: 13px; line-height: 1.4; }
.subject-card .meta { margin-top: 8px; font-size: 12px; }

.page-header { margin-bottom: 24px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-decoration: none;
  color: var(--text);
}
.list-item:hover { background: #f9fafb; }
.list-item .title { font-weight: 600; }
.list-item .desc { margin-top: 4px; font-size: 13px; }

.badges { display: flex; gap: 8px; }
.badge { padding: 4px 8px; border-radius: 4px; font-size: 12px; }
.badge.ok { background: #dcfce7; color: #15803d; }
.badge.pending { background: #fef3c7; color: #b45309; }

.add-form { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-top: 24px; }
.add-form form { display: flex; flex-direction: column; gap: 8px; }
.add-form input, .add-form textarea { padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }

.audio-box, .content-box {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 16px; margin-bottom: 16px;
}
.audio-box audio { width: 100%; }
.md { font-size: 15px; line-height: 1.7; }
.md h1,.md h2,.md h3 { margin-top: 1.2em; }
.md pre { background: #f3f4f6; padding: 12px; border-radius: 6px; overflow-x: auto; }
.md code { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; }

.materials { list-style: none; padding: 0; }
.materials li {
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}

.btn { padding: 10px 18px; border-radius: 6px; border: 1px solid var(--line); background: white; cursor: pointer; font: inherit; text-decoration: none; color: var(--text); display: inline-block; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-ghost { background: transparent; }

.login-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 36px; width: 360px; }
.login-card h1 { margin: 0 0 4px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.login-card input { padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.login-card .err { background: #fee2e2; color: var(--danger); padding: 8px 12px; border-radius: 6px; font-size: 13px; }
