:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --ink: #18202c;
  --muted: #687386;
  --line: #dce2ea;
  --accent: #3157d5;
  --accent-2: #0f8f72;
  --warn: #bc6c25;
  --shadow: 0 22px 55px rgba(24, 32, 44, .10);
  --font-korean: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-korean);
  overflow-x: hidden;
}

button, input {
  font: inherit;
  font-family: var(--font-korean);
}

button, a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid rgba(49, 87, 213, .35);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  min-height: 100vh;
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, .72);
  backdrop-filter: blur(16px);
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--ink);
  color: white;
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.search-wrap input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  padding: 12px 13px;
}

.section-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0;
}

.tab {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--muted);
  padding: 9px 10px;
  cursor: pointer;
  min-width: 0;
}

.tab.active {
  border-color: var(--accent);
  background: #edf2ff;
  color: var(--accent);
  font-weight: 700;
}

.doc-list {
  overflow: auto;
  padding-right: 3px;
  min-width: 0;
}

.doc-item {
  width: 100%;
  min-width: 0;
  display: block;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
}

.doc-item:hover {
  background: white;
  border-color: var(--line);
}

.doc-item.active {
  background: var(--ink);
  color: white;
}

.doc-item strong {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: keep-all;
  line-height: 1.35;
}

.doc-item span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.doc-item.active span {
  color: rgba(255, 255, 255, .68);
}

.reader {
  padding: 28px clamp(20px, 4vw, 56px) 48px;
  min-width: 0;
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.status-bar h1 {
  margin: 0;
  font-size: clamp(22px, 3vw, 36px);
  line-height: 1.15;
  letter-spacing: 0;
}

.status-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-actions button,
.status-actions a {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  padding: 10px 12px;
  text-decoration: none;
  cursor: pointer;
}

.status-actions button:hover,
.status-actions a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.document-card {
  max-width: 980px;
  min-width: 0;
  min-height: 68vh;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.document-meta {
  border-bottom: 1px solid var(--line);
  padding: 18px 24px;
  background: linear-gradient(90deg, #ffffff, #f5f7fb);
}

.document-meta h2 {
  margin: 0;
  font-size: clamp(24px, 3.4vw, 40px);
  line-height: 1.22;
  letter-spacing: 0;
}

.document-meta p {
  margin: 9px 0 0;
  color: var(--muted);
}

.document-body {
  padding: 30px clamp(20px, 4vw, 56px) 54px;
  font-size: 17px;
  line-height: 1.78;
}

.document-body.loading,
.empty-state {
  color: var(--muted);
}

.document-body h1,
.document-body h2,
.document-body h3 {
  line-height: 1.3;
  letter-spacing: 0;
}

.document-body h1 { font-size: 34px; margin: 0 0 22px; }
.document-body h2 { font-size: 27px; margin: 36px 0 14px; }
.document-body h3 { font-size: 21px; margin: 28px 0 10px; }

.document-body p,
.document-body li {
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.document-body blockquote {
  margin: 18px 0;
  padding: 14px 18px;
  border-left: 4px solid var(--accent-2);
  background: #f0f7f4;
  color: #2d5549;
}

.document-body a {
  color: var(--accent);
  font-weight: 700;
}

.document-body code {
  border-radius: 6px;
  background: #eef2f7;
  color: #0f172a;
  padding: 2px 6px;
  font-size: .92em;
}

.document-body pre {
  overflow: auto;
  border-radius: 12px;
  background: #111827;
  color: #e5e7eb;
  padding: 16px;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-box {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
  box-shadow: var(--shadow);
  padding: 30px;
}

.login-box h1 {
  margin: 0 0 10px;
}

.login-box p {
  color: var(--muted);
}

.login-box label {
  display: block;
  margin: 22px 0 8px;
  font-weight: 700;
}

.login-box input,
.login-box button {
  width: 100%;
  border-radius: 10px;
  padding: 12px;
}

.login-box input {
  border: 1px solid var(--line);
}

.login-box button {
  margin-top: 12px;
  border: 0;
  background: var(--ink);
  color: white;
  cursor: pointer;
}

.login-box .error {
  color: #b42318;
  font-weight: 700;
}

.login-box pre {
  overflow: auto;
  border-radius: 10px;
  background: #111827;
  color: #e5e7eb;
  padding: 14px;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .doc-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    max-height: 260px;
  }

  .status-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-actions {
    justify-content: flex-start;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-actions button,
  .status-actions a {
    text-align: center;
  }

  .status-actions a {
    grid-column: 1 / -1;
  }
}

@media (max-width: 480px) {
  .sidebar {
    padding: 18px 20px;
  }

  .reader {
    padding: 24px 20px 40px;
  }

  .section-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .document-meta,
  .document-body {
    padding-left: 20px;
    padding-right: 20px;
  }

  .document-body {
    font-size: 16px;
  }

}
