/* project.crowny.org — TOAU 729 PM */
:root {
  --bg: #1C1C1A; --bg2: #242422; --bg3: #2C2C2A;
  --text: #E8E6E3; --text-2: #A8A6A3; --text-3: #686664;
  --border: #3A3A38;
  --T: #27AE60; --O: #F39C12; --A: #E74C3C; --U: #888;
  --accent: #5B8DEF;
  --radius: 6px;
}
[data-theme="light"] {
  --bg: #F5F5F3; --bg2: #EAEAE8; --bg3: #E0E0DE;
  --text: #1C1C1A; --text-2: #555; --text-3: #999;
  --border: #D0D0CE;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, 'Pretendard', sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 13px; line-height: 1.5;
  display: flex; flex-direction: column; height: 100vh;
}

/* 헤더 */
.hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; height: 40px; border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
.logo { font-weight: 700; font-size: 14px; letter-spacing: -0.03em; }
.logo em { font-style: normal; color: var(--accent); }
.hdr-r { display: flex; gap: 8px; align-items: center; }
.hdr-r button {
  background: none; border: 1px solid var(--border); border-radius: 4px;
  color: var(--text-2); cursor: pointer; padding: 2px 8px; font-size: 11px;
}
.hdr-r button:hover { border-color: var(--text-3); }

/* 메인 레이아웃 */
.main { display: flex; flex: 1; overflow: hidden; }

/* 사이드바 */
.side {
  width: 220px; border-right: 1px solid var(--border);
  padding: 12px 0; overflow-y: auto; background: var(--bg2);
  flex-shrink: 0;
}
.side-title {
  padding: 4px 16px; font-size: 10px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.05em; margin-top: 8px;
}
.side-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 16px; cursor: pointer; font-size: 12px;
  border-left: 3px solid transparent; transition: all .15s;
}
.side-item:hover { background: var(--bg3); }
.side-item.active { background: var(--bg3); border-left-color: var(--accent); }
.side-item .dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}

/* 콘텐츠 */
.content { flex: 1; overflow-y: auto; padding: 20px; }

/* 카드 */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.card-title { font-weight: 600; font-size: 14px; margin-bottom: 8px; }

/* TOAU 뱃지 */
.toau-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 3px; font-size: 11px; font-weight: 600;
}
.toau-T { background: rgba(39,174,96,.15); color: var(--T); }
.toau-O { background: rgba(243,156,18,.15); color: var(--O); }
.toau-A { background: rgba(231,76,60,.15); color: var(--A); }
.toau-U { background: rgba(136,136,136,.15); color: var(--U); }

/* 4상 대시보드 */
.toau-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin-bottom: 16px;
}
.toau-card {
  text-align: center; padding: 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg2);
}
.toau-card .num { font-size: 28px; font-weight: 700; }
.toau-card .label { font-size: 10px; color: var(--text-3); margin-top: 2px; }

/* 트리 뷰 */
.tree-node {
  margin-left: 20px; border-left: 1px solid var(--border);
  padding-left: 12px; margin-top: 4px;
}
.tree-node-header {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border-radius: var(--radius); cursor: pointer; transition: background .15s;
}
.tree-node-header:hover { background: var(--bg3); }
.tree-toggle {
  width: 16px; font-size: 10px; color: var(--text-3); cursor: pointer;
  user-select: none;
}
.tree-name { font-size: 12px; font-weight: 500; }
.tree-progress {
  margin-left: auto; font-size: 10px; color: var(--text-3);
}
.tree-bar {
  width: 60px; height: 4px; background: var(--bg3); border-radius: 2px;
  overflow: hidden; margin-left: 6px;
}
.tree-bar-fill { height: 100%; border-radius: 2px; transition: width .3s; }

/* 폼 */
.form-group { margin-bottom: 12px; }
.form-label { font-size: 11px; color: var(--text-2); margin-bottom: 4px; display: block; }
input[type="text"], input[type="password"], input[type="email"], select, textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg); color: var(--text);
  font-size: 13px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 60px; }

/* 버튼 */
.btn {
  padding: 6px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg2); color: var(--text); cursor: pointer; font-size: 12px;
  transition: all .15s;
}
.btn:hover { border-color: var(--text-3); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { opacity: .9; }
.btn-T { background: var(--T); color: #fff; border-color: var(--T); }
.btn-O { background: var(--O); color: #fff; border-color: var(--O); }
.btn-A { background: var(--A); color: #fff; border-color: var(--A); }
.btn-sm { padding: 3px 8px; font-size: 11px; }

/* 모달 */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; display: none;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; padding: 24px; width: 420px; max-height: 80vh;
  overflow-y: auto;
}
.modal h3 { font-size: 16px; margin-bottom: 16px; }

/* 테이블 */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--border); font-size: 12px; }
th { color: var(--text-3); font-weight: 500; font-size: 11px; }

/* 9레벨 표시 */
.level-bar {
  display: flex; gap: 2px; margin-top: 2px;
}
.level-bar span {
  width: 10px; height: 10px; border-radius: 2px;
  background: var(--border);
}
.level-bar span.filled { background: var(--accent); }

/* 보상 지갑 */
.wallet { display: flex; gap: 12px; }
.wallet-item {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600;
}
.wallet-mam { color: #E8D44D; }
.wallet-phone { color: #5B8DEF; }
.wallet-crowny { color: var(--T); }

/* 반응형 */
@media (max-width: 768px) {
  .side { display: none; }
  .toau-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ═══ 인사이트 ═══ */
.health-badge {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff;
}
.insight-card { max-height: 220px; overflow-y: auto; }
.insight-item {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px; border-radius: 4px; cursor: pointer;
  font-size: 11px; transition: background .15s;
}
.insight-item:hover { background: var(--bg3); }
.insight-danger { border-left: 2px solid var(--A); }
.insight-warn { border-left: 2px solid var(--O); }
.insight-success { border-left: 2px solid var(--T); }
.tree-tag {
  font-size: 8px; padding: 1px 4px; border-radius: 3px;
  font-weight: 600; margin-left: 4px;
}
.tree-tag-danger { background: rgba(231,76,60,.15); color: var(--A); }
.tree-tag-warn { background: rgba(243,156,18,.15); color: var(--O); }
.tree-tag-success { background: rgba(39,174,96,.15); color: var(--T); }
.tree-tag-attention { background: rgba(91,141,239,.15); color: var(--accent); }

/* ═══ 템플릿 갤러리 ═══ */
.tpl-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.tpl-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-align: center; cursor: pointer;
  background: var(--bg); transition: all .2s;
}
.tpl-card:hover { border-color: var(--accent); box-shadow: 0 0 12px rgba(91,141,239,.15); }
.tpl-card .tpl-icon { width: 48px; height: 48px; margin: 0 auto 8px; }
.tpl-card .tpl-icon svg { width: 48px; height: 48px; }
.tpl-card .tpl-name { font-weight: 600; font-size: 12px; margin-bottom: 4px; }
.tpl-card .tpl-desc { font-size: 10px; color: var(--text-3); line-height: 1.4; }
.tpl-card .tpl-meta { font-size: 9px; color: var(--text-3); margin-top: 6px; }
.tpl-card .tpl-tags { display: flex; gap: 3px; justify-content: center; margin-top: 6px; flex-wrap: wrap; }
.tpl-card .tpl-tag {
  font-size: 9px; padding: 1px 5px; border-radius: 3px;
  background: rgba(91,141,239,.1); color: var(--accent);
}

/* ═══ 온보딩 튜토리얼 ═══ */
.tutorial-overlay {
  position: fixed; inset: 0; z-index: 200;
}
.tutorial-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.5);
}
.tutorial-panel {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  width: 480px; max-width: 90vw; background: var(--bg2);
  border: 1px solid var(--accent); border-radius: 12px;
  padding: 24px; box-shadow: 0 8px 32px rgba(0,0,0,.3);
}
.tutorial-step-num {
  font-size: 10px; color: var(--accent); font-weight: 600;
  margin-bottom: 4px;
}
.tutorial-title {
  font-size: 16px; font-weight: 700; margin-bottom: 8px;
}
.tutorial-desc {
  font-size: 12px; color: var(--text-2); line-height: 1.6;
  margin-bottom: 12px; white-space: pre-line;
}
.tutorial-tip {
  font-size: 11px; color: var(--accent); padding: 8px 12px;
  background: rgba(91,141,239,.08); border-radius: 6px;
  margin-bottom: 12px;
}
.tutorial-concepts {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  margin-bottom: 12px;
}
.tutorial-concept {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; border-radius: 6px; border: 1px solid var(--border);
}
.tutorial-concept-key {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff; flex-shrink: 0;
}
.tutorial-concept-info { font-size: 11px; }
.tutorial-concept-name { font-weight: 600; }
.tutorial-concept-desc { color: var(--text-3); font-size: 10px; }
.tutorial-dots {
  display: flex; gap: 6px; justify-content: center; margin-bottom: 12px;
}
.tutorial-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--border);
}
.tutorial-dot.active { background: var(--accent); }
.tutorial-actions {
  display: flex; justify-content: space-between; align-items: center;
}

/* ═══ 헬프 패널 ═══ */
.help-panel {
  position: fixed; top: 0; right: 0; width: 380px; max-width: 90vw;
  height: 100vh; background: var(--bg2); border-left: 1px solid var(--border);
  z-index: 150; display: flex; flex-direction: column;
  box-shadow: -4px 0 16px rgba(0,0,0,.2);
}
.help-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.help-tabs {
  display: flex; border-bottom: 1px solid var(--border);
}
.help-tab {
  flex: 1; padding: 8px; text-align: center; cursor: pointer;
  font-size: 11px; color: var(--text-3);
  border-bottom: 2px solid transparent;
}
.help-tab.active { border-bottom-color: var(--accent); color: var(--text); }
.help-body {
  flex: 1; overflow-y: auto; padding: 16px;
}
.help-footer {
  padding: 8px 16px; border-top: 1px solid var(--border); text-align: center;
}
.help-section { margin-bottom: 16px; }
.help-section-title {
  font-weight: 600; font-size: 12px; margin-bottom: 6px;
  color: var(--accent);
}
.help-item {
  padding: 4px 0; font-size: 11px; color: var(--text-2);
  border-bottom: 1px solid rgba(255,255,255,.03);
}
.help-item code {
  font-family: 'SF Mono', monospace; font-size: 10px;
  padding: 1px 4px; background: var(--bg3); border-radius: 3px;
}
.help-phase-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 3px; font-size: 11px; font-weight: 600;
}

/* 비로그인 */
.auth-page {
  display: flex; align-items: center; justify-content: center;
  height: 100%; text-align: center;
}
.auth-box {
  width: 340px; padding: 32px; background: var(--bg2);
  border: 1px solid var(--border); border-radius: 8px;
}
.auth-box h2 { font-size: 18px; margin-bottom: 4px; }
.auth-box .sub { font-size: 11px; color: var(--text-3); margin-bottom: 20px; }
.auth-tabs { display: flex; gap: 0; margin-bottom: 16px; }
.auth-tab {
  flex: 1; padding: 8px; text-align: center; cursor: pointer;
  border-bottom: 2px solid var(--border); font-size: 12px; color: var(--text-3);
}
.auth-tab.active { border-bottom-color: var(--accent); color: var(--text); }
