/* ═══════════════════════════════════════
   VARIABLES & RESET
═══════════════════════════════════════ */
:root {
  --bg:          #0b0d14;
  --bg-2:        #101320;
  --bg-3:        #171b2d;
  --bg-4:        #1e2236;
  --surface:     #232840;
  --border:      rgba(255,255,255,0.07);
  --border-2:    rgba(255,255,255,0.12);

  --text:        #e4e8f5;
  --text-2:      #9aa3bf;
  --text-3:      #5d6480;

  --blue:        #3b7eff;
  --blue-dim:    rgba(59,126,255,0.12);
  --green:       #2dca72;
  --green-dim:   rgba(45,202,114,0.12);
  --amber:       #f0a429;
  --amber-dim:   rgba(240,164,41,0.12);
  --purple:      #a564f5;
  --purple-dim:  rgba(165,100,245,0.12);
  --cyan:        #17c6e8;
  --cyan-dim:    rgba(23,198,232,0.12);

  --sidebar-w:   290px;
  --topbar-h:    56px;
  --radius:      10px;
  --radius-sm:   6px;
  --transition:  0.18s ease;

  font-size: 15px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input { font: inherit; }

/* ═══════════════════════════════════════
   LAYOUT
═══════════════════════════════════════ */
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ═══════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 200;
  transition: transform var(--transition);
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #3b7eff22, #a564f522);
  border: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 1px;
}

/* Search */
.sidebar-search {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
}

.search-icon {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-3);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px 7px 32px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}

.search-input::placeholder { color: var(--text-3); }

.search-input:focus {
  border-color: rgba(59,126,255,0.5);
  background: var(--bg-4);
}

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-4) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-size: 13px;
  color: var(--text-2);
  user-select: none;
}

.nav-item:hover {
  background: var(--bg-3);
  color: var(--text);
}

.nav-item.active {
  background: var(--blue-dim);
  color: var(--blue);
}

.nav-item.active .nav-num {
  background: var(--blue);
  color: #fff;
}

.nav-num {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: var(--bg-4);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}

.nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.nav-item.coming-soon {
  opacity: 0.4;
  cursor: default;
}

.nav-item.coming-soon:hover {
  background: none;
  color: var(--text-2);
}

.sidebar-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-3);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════
   MAIN WRAP
═══════════════════════════════════════ */
.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
  flex-shrink: 0;
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 4px;
  flex-shrink: 0;
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-2);
  border-radius: 2px;
  transition: background var(--transition);
}

.hamburger:hover span { background: var(--text); }

.topbar-breadcrumb {
  font-size: 14px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main content */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-4) transparent;
}

.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 4px; }

/* ═══════════════════════════════════════
   WELCOME SCREEN
═══════════════════════════════════════ */
.welcome {
  max-width: 600px;
  margin: 60px auto 0;
  text-align: center;
}

.welcome-icon {
  font-size: 52px;
  margin-bottom: 20px;
  filter: grayscale(0.3);
}

.welcome-title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.welcome-desc {
  color: var(--text-2);
  font-size: 15px;
  line-height: 1.7;
  margin-bottom: 40px;
}

.welcome-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.welcome-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: left;
  transition: border-color var(--transition);
}

.welcome-card:hover { border-color: var(--border-2); }

.wc-icon {
  font-size: 22px;
  margin-bottom: 8px;
}

.wc-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}

.wc-sub {
  font-size: 12px;
  color: var(--text-3);
}

/* ═══════════════════════════════════════
   STAGE PAGE
═══════════════════════════════════════ */
.stage-page {
  max-width: 860px;
  margin: 0 auto;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.stage-header {
  margin-bottom: 32px;
}

.stage-number {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
}

.stage-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

/* ═══════════════════════════════════════
   BLOCKS
═══════════════════════════════════════ */
.block {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.block-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}

.block-header:hover { background: rgba(255,255,255,0.02); }

.block-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.block-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.block-count {
  font-size: 12px;
  color: var(--text-3);
  background: var(--bg-4);
  border-radius: 20px;
  padding: 1px 9px;
}

.block-chevron {
  width: 16px;
  height: 16px;
  color: var(--text-3);
  transition: transform var(--transition);
  flex-shrink: 0;
}

.block.collapsed .block-chevron { transform: rotate(-90deg); }

.block-body {
  padding: 0 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.block.collapsed .block-body { display: none; }

/* Block accent colors */
.block.norms   .block-dot { background: var(--blue); }
.block.ppvs    .block-dot { background: var(--green); }
.block.vs      .block-dot { background: var(--amber); }
.block.ksou    .block-dot { background: var(--purple); }
.block.docs    .block-dot { background: var(--cyan); }

.block.norms   { border-left: 3px solid var(--blue); }
.block.ppvs    { border-left: 3px solid var(--green); }
.block.vs      { border-left: 3px solid var(--amber); }
.block.ksou    { border-left: 3px solid var(--purple); }
.block.docs    { border-left: 3px solid var(--cyan); }

/* ═══════════════════════════════════════
   NORM ITEMS
═══════════════════════════════════════ */
.norm-item, .ppvs-item, .vs-item {
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.norm-article {
  font-size: 12px;
  font-weight: 700;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.ppvs-point {
  font-size: 12px;
  font-weight: 700;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.vs-case {
  font-size: 12px;
  font-weight: 600;
  color: var(--amber);
  margin-bottom: 6px;
}

.item-text {
  font-size: 13.5px;
  color: var(--text-2);
  line-height: 1.65;
}

/* ═══════════════════════════════════════
   KSOU TABS
═══════════════════════════════════════ */
.ksou-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.ksou-tab {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-4);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.ksou-tab:hover {
  background: var(--purple-dim);
  color: var(--purple);
  border-color: rgba(165,100,245,0.3);
}

.ksou-tab.active {
  background: var(--purple-dim);
  color: var(--purple);
  border-color: rgba(165,100,245,0.4);
  font-weight: 600;
}

.ksou-panel {
  display: none;
  flex-direction: column;
  gap: 10px;
}

.ksou-panel.active { display: flex; }

.ksou-court-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.ksou-court-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--purple);
}

.ksou-court-city {
  font-size: 12px;
  color: var(--text-3);
}

.ksou-case-item {
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.ksou-case-num {
  font-size: 12px;
  font-weight: 600;
  color: var(--purple);
  margin-bottom: 6px;
}

/* ═══════════════════════════════════════
   DOCUMENTS
═══════════════════════════════════════ */
.docs-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.doc-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  transition: border-color var(--transition);
}

.doc-item:hover { border-color: var(--border-2); }

.doc-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--cyan-dim);
  border: 1px solid rgba(23,198,232,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.doc-info {
  flex: 1;
  min-width: 0;
}

.doc-title {
  font-size: 13.5px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.3;
}

.doc-filename {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
  font-family: "SF Mono", "Fira Code", monospace;
}

.doc-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════
   ERROR SCREEN
═══════════════════════════════════════ */
.error-screen {
  max-width: 520px;
  margin: 80px auto;
  text-align: center;
}

.error-icon {
  font-size: 42px;
  margin-bottom: 20px;
}

.error-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.error-desc {
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 24px;
}

.error-code {
  display: inline-block;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 13px;
  color: var(--cyan);
}

/* ═══════════════════════════════════════
   WELCOME CARD ACCENT
═══════════════════════════════════════ */
.welcome-card.norms-color { border-color: rgba(59,126,255,0.2); }
.welcome-card.ppvs-color  { border-color: rgba(45,202,114,0.2); }
.welcome-card.vs-color    { border-color: rgba(240,164,41,0.2); }
.welcome-card.ksou-color  { border-color: rgba(165,100,245,0.2); }

/* ═══════════════════════════════════════
   OVERLAY (mobile)
═══════════════════════════════════════ */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 100;
  backdrop-filter: blur(2px);
}

.overlay.visible { display: block; }

/* ═══════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
  }

  .sidebar.open { transform: translateX(0); }

  .hamburger { display: flex; }

  .main-content { padding: 20px 16px; }

  .welcome { margin-top: 30px; }

  .welcome-grid { grid-template-columns: 1fr 1fr; }

  .ksou-tabs { gap: 4px; }

  .ksou-tab { font-size: 11px; padding: 4px 10px; }
}

@media (max-width: 480px) {
  .welcome-grid { grid-template-columns: 1fr; }
  .stage-title { font-size: 20px; }
}
