:root {
  --bg: #0a0a0f;
  --bg2: #12121a;
  --bg3: #1a1a28;
  --surface: #1e1e2e;
  --border: #2a2a3e;
  --text: #e0e0e8;
  --text2: #8888a0;
  --accent: #6c5ce7;
  --accent2: #a29bfe;
  --green: #00cec9;
  --orange: #fdcb6e;
  --red: #ff7675;
  --blue: #74b9ff;
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, 'Pretendard', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app { display: flex; height: 100vh; }

/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
  font-size: 18px;
  color: var(--accent2);
  letter-spacing: -0.5px;
}

.sidebar-header .subtitle {
  font-size: 11px;
  color: var(--text2);
  margin-top: 4px;
}

.brain-card {
  margin: 16px;
  padding: 16px;
  background: var(--bg3);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.brain-level {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.brain-level .lv {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent);
}

.brain-level .label {
  font-size: 12px;
  color: var(--text2);
}

.xp-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.xp-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 2px;
  transition: width 0.5s;
}

.brain-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.brain-stats .stat {
  text-align: center;
}

.brain-stats .stat .num {
  font-size: 16px;
  font-weight: 700;
  color: var(--green);
}

.brain-stats .stat .lbl {
  font-size: 10px;
  color: var(--text2);
}

.new-doc-btn {
  margin: 0 16px;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.new-doc-btn:hover { background: var(--accent2); }

.doc-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.doc-item {
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 4px;
}

.doc-item:hover { background: var(--bg3); }
.doc-item.active { background: var(--bg3); border-left: 3px solid var(--accent); }

.doc-item .title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-item .meta {
  font-size: 11px;
  color: var(--text2);
  margin-top: 3px;
}

.doc-item .type-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--border);
  color: var(--accent2);
}

/* Main */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}

.toolbar input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
}

.toolbar input:focus { outline: none; border-color: var(--accent); }

.toolbar select {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
}

.toolbar button {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.toolbar button:hover { border-color: var(--accent); color: var(--accent2); }
.toolbar button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.toolbar button.primary:hover { background: var(--accent2); }

.editor-area {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px;
  overflow-y: auto;
}

.editor-pane textarea {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 20px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.8;
  resize: none;
  font-family: inherit;
  min-height: 400px;
}

.editor-pane textarea:focus { outline: none; border-color: var(--accent); }

.editor-pane .topic-input {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.editor-pane .topic-input input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
}

.editor-pane .topic-input input:focus { outline: none; border-color: var(--accent); }

/* Analysis Panel */
.analysis-panel {
  width: 340px;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px;
  flex-shrink: 0;
}

.analysis-panel h3 {
  font-size: 14px;
  color: var(--accent2);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.score-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.score-card {
  text-align: center;
  padding: 12px 8px;
  background: var(--bg3);
  border-radius: 8px;
}

.score-card .score {
  font-size: 28px;
  font-weight: 800;
}

.score-card .score.high { color: var(--green); }
.score-card .score.mid { color: var(--orange); }
.score-card .score.low { color: var(--red); }

.score-card .label {
  font-size: 11px;
  color: var(--text2);
  margin-top: 4px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.stat-row .val { color: var(--blue); font-weight: 600; }

.suggestion-list { margin-top: 16px; }

.suggestion {
  padding: 12px;
  background: var(--bg3);
  border-radius: 8px;
  margin-bottom: 8px;
  border-left: 3px solid var(--border);
}

.suggestion.high { border-left-color: var(--red); }
.suggestion.medium { border-left-color: var(--orange); }
.suggestion.low { border-left-color: var(--blue); }

.suggestion .s-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.suggestion .s-detail {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.5;
}

/* Welcome */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 40px;
  text-align: center;
}

.welcome h2 {
  font-size: 28px;
  color: var(--accent2);
  margin-bottom: 12px;
}

.welcome p {
  color: var(--text2);
  max-width: 500px;
  line-height: 1.7;
  margin-bottom: 8px;
}

.doc-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 24px;
  width: 100%;
  max-width: 500px;
}

.doc-type-card {
  padding: 20px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.doc-type-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.doc-type-card .icon { font-size: 28px; margin-bottom: 8px; }
.doc-type-card .name { font-size: 13px; font-weight: 600; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 440px;
  max-width: 90vw;
}

.modal h3 {
  font-size: 18px;
  margin-bottom: 20px;
  color: var(--accent2);
}

.modal label {
  display: block;
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 6px;
  margin-top: 14px;
}

.modal input, .modal select, .modal textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}

.modal input:focus, .modal textarea:focus { outline: none; border-color: var(--accent); }

.modal .actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

.modal .actions button {
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.modal .actions button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
