:root {
  --primary: #00a495;
  --primary-hover: #00897b;
  --bg-body: #f4f6f8;
  --bg-card: #ffffff;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --diff-add-bg: #e6ffec;
  --diff-add-text: #1a7f37;
  --diff-del-bg: #ffebe9;
  --diff-del-text: #cf222e;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
}

header {
  background-color: var(--primary);
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.logo {
  font-size: 1.35rem;
  font-weight: 800;
  color: white;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.logo span { font-size: 0.75rem; background: rgba(255,255,255,0.2); padding: 2px 6px; border-radius: 4px; font-weight: 500; }

.search-box { position: relative; flex: 1; max-width: 420px; }
.search-box input {
  width: 100%;
  padding: 9px 14px;
  border-radius: 6px;
  border: none;
  font-size: 0.95rem;
  outline: none;
  background: rgba(255,255,255,0.95);
}
.search-box input:focus { background: #ffffff; box-shadow: 0 0 0 3px rgba(255,255,255,0.3); }
.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  overflow: hidden;
  display: none;
  color: var(--text-main);
}
.search-dropdown.active { display: block; }
.search-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background-color: #f3f4f6; }
.score-badge { font-size: 0.75rem; color: var(--primary); font-weight: 600; background: #e0f2f1; padding: 2px 6px; border-radius: 4px; }

.user-actions { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.btn {
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-white { background: white; color: var(--primary); }
.btn-white:hover { background: #f0fdfa; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: white; border-color: var(--border); color: var(--text-main); }
.btn-outline:hover { background: #f9fafb; border-color: #d1d5db; }

.main-wrapper {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 860px) {
  .main-wrapper { grid-template-columns: 1fr; }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.doc-header {
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}
.doc-title { font-size: 1.85rem; font-weight: 800; color: #111827; letter-spacing: -0.02em; }
.doc-meta { font-size: 0.82rem; color: var(--text-muted); margin-top: 4px; }
.doc-toolbar { display: flex; gap: 6px; }
.doc-body { padding: 28px; min-height: 420px; font-size: 1rem; word-break: keep-all; }
.doc-body h2 { font-size: 1.35rem; margin: 24px 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--border); color: var(--primary-hover); }
.doc-body p { margin-bottom: 14px; }
.wiki-link { color: var(--primary); text-decoration: none; font-weight: 600; border-bottom: 1px dashed var(--primary); }
.wiki-link:hover { background: #e0f2f1; }

.editor-textarea {
  width: 100%;
  min-height: 360px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'Consolas', 'Pretendard', monospace;
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}
.editor-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,164,149,0.15); }
.editor-footer { margin-top: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.summary-input { flex: 1; min-width: 200px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem; }

.diff-container {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  font-family: 'Consolas', monospace;
  font-size: 0.88rem;
}
.diff-line { padding: 4px 12px; display: flex; gap: 12px; white-space: pre-wrap; word-break: break-all; }
.diff-line.eq { background: #ffffff; color: #374151; }
.diff-line.add { background: var(--diff-add-bg); color: var(--diff-add-text); }
.diff-line.del { background: var(--diff-del-bg); color: var(--diff-del-text); text-decoration: line-through; }
.diff-sign { width: 16px; font-weight: bold; user-select: none; }

.history-list { list-style: none; }
.history-item { padding: 14px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.history-item:last-child { border-bottom: none; }

.sidebar-header {
  padding: 14px 18px;
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.recent-list { list-style: none; }
.recent-item {
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  transition: background 0.1s;
}
.recent-item:last-child { border-bottom: none; }
.recent-item:hover { background: #f9fafb; }
.recent-item a { color: var(--text-main); text-decoration: none; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 175px; }
.recent-item a:hover { color: var(--primary); }
.recent-time { font-size: 0.76rem; color: var(--text-muted); white-space: nowrap; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-backdrop.active { display: flex; }
.modal {
  background: white;
  width: 100%;
  max-width: 380px;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}
.modal h3 { margin-bottom: 16px; font-size: 1.2rem; }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 4px; color: var(--text-muted); }
.form-group input { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.92rem; }
.error-msg { color: #dc2626; font-size: 0.8rem; margin-top: 6px; min-height: 18px; }
