@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Noto+Sans+JP:wght@300;400;500;700&display=swap');

:root {
  /* Base */
  --white: #ffffff;
  --bg: #f4f6f9;
  --bg-soft: #eef1f6;

  /* Grays */
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Brand */
  --brand:        #2563eb;
  --brand-light:  #3b82f6;
  --brand-dim:    #eff6ff;
  --brand-border: #bfdbfe;

  /* Tier colors */
  --tier1-bg:  #fefce8; --tier1-border: #fde047; --tier1-text: #854d0e;
  --tier2-bg:  #eff6ff; --tier2-border: #93c5fd; --tier2-text: #1e40af;
  --tier3-bg:  #f0fdf4; --tier3-border: #86efac; --tier3-text: #166534;
  --tier4-bg:  #fdf4ff; --tier4-border: #d8b4fe; --tier4-text: #7e22ce;
  --tier5-bg:  #fff7ed; --tier5-border: #fdba74; --tier5-text: #9a3412;
  --tier-other-bg: #f8fafc; --tier-other-border: var(--gray-300); --tier-other-text: var(--gray-600);

  /* Layout */
  --header-h: 56px;
  --sidebar-w: 220px;
  --radius: 10px;
  --radius-lg: 16px;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.14);
  --shadow-inset: inset 0 1px 2px rgba(0,0,0,0.06);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Noto Sans JP', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--gray-800);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── Header ──────────────────────────────────────────────── */
.site-header {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  box-shadow: var(--shadow-xs);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  width: var(--sidebar-w);
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand) 0%, #7c3aed 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.header-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.title-main {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.title-badge {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  background: var(--brand-dim);
  color: var(--brand);
  border-radius: 100px;
  border: 1px solid var(--brand-border);
}

/* Search in header */
.header-search {
  flex: 1;
  max-width: 420px;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 11px;
  color: var(--gray-400);
  pointer-events: none;
  transition: color 0.15s;
  z-index: 1;
}

.search-wrap:focus-within .search-icon {
  color: var(--brand);
}

#company-search {
  width: 100%;
  height: 36px;
  padding: 0 36px 0 34px;
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  color: var(--gray-800);
  font-size: 0.83rem;
  font-family: inherit;
  outline: none;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-inset);
}

#company-search:focus {
  border-color: var(--brand-light);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12), var(--shadow-inset);
}

#company-search::placeholder {
  color: var(--gray-400);
}

.search-kbd {
  position: absolute;
  right: 8px;
  padding: 2px 6px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 5px;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--gray-400);
  pointer-events: none;
  font-family: inherit;
  box-shadow: var(--shadow-xs);
  transition: opacity 0.15s;
}

#company-search:focus ~ .search-kbd {
  opacity: 0;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-lg);
  max-height: 320px;
  overflow-y: auto;
  z-index: 300;
  box-shadow: var(--shadow-lg);
  display: none;
}

.search-results.active { display: block; }

.search-results::-webkit-scrollbar { width: 4px; }
.search-results::-webkit-scrollbar-thumb {
  background: var(--gray-200);
  border-radius: 2px;
}

.search-results-inner {
  padding: 6px;
}

.search-result-item {
  padding: 8px 10px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.1s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-result-item:hover { background: var(--gray-50); }

.search-result-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--brand-dim);
  border: 1px solid var(--brand-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
}

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

.search-result-name {
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--gray-800);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-cat {
  font-size: 0.7rem;
  color: var(--gray-500);
  margin-top: 1px;
  display: block;
}

.search-divider {
  height: 1px;
  background: var(--gray-100);
  margin: 4px 10px;
}

/* Mobile menu btn */
.mobile-menu-btn {
  display: none;
  margin-left: auto;
  padding: 8px;
  background: transparent;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  cursor: pointer;
  color: var(--gray-600);
  transition: all 0.15s;
}
.mobile-menu-btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

/* ─── App Body ────────────────────────────────────────────── */
.app-body {
  display: flex;
  min-height: 100vh;
  padding-top: var(--header-h);
}

/* ─── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  position: fixed;
  top: var(--header-h);
  left: 0;
  height: calc(100vh - var(--header-h));
  z-index: 100;
  overflow-y: auto;
  transition: transform 0.3s var(--ease);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb {
  background: var(--gray-200);
  border-radius: 2px;
}

.sidebar-nav { padding: 16px 10px; }

.nav-section { margin-bottom: 24px; }

.nav-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-400);
  padding: 0 8px;
  margin-bottom: 4px;
}

.nav-list { list-style: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  color: var(--gray-600);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 400;
  border-radius: 8px;
  transition: all 0.12s ease;
  cursor: pointer;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  font-family: inherit;
}

.nav-icon {
  display: flex;
  align-items: center;
  color: var(--gray-400);
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

.nav-item:hover .nav-icon {
  color: var(--gray-600);
}

.nav-item.active {
  background: var(--brand-dim);
  color: var(--brand);
  font-weight: 500;
}

.nav-item.active .nav-icon {
  color: var(--brand);
}

/* ─── Main Content ────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 36px 48px 60px;
  max-width: calc(900px + var(--sidebar-w));
  width: 100%;
}

.content-area {
  max-width: 760px;
  animation: contentIn 0.3s var(--ease) both;
}

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

/* ─── Category Header ─────────────────────────────────────── */
.category-header {
  margin-bottom: 28px;
}

.category-eyebrow {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--brand);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.category-eyebrow::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 2px;
  background: var(--brand);
  border-radius: 1px;
}

.category-header h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -0.04em;
  line-height: 1.15;
  margin-bottom: 12px;
}

.category-desc {
  font-size: 0.875rem;
  color: var(--gray-500);
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ─── Tier Group Cards ────────────────────────────────────── */
.tier-group {
  border-radius: var(--radius-lg);
  margin-bottom: 14px;
  overflow: hidden;
  border: 1.5px solid transparent;
  transition: box-shadow 0.15s, transform 0.15s;
}

.tier-group:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.tier-group.tier-1 { background: var(--tier1-bg); border-color: var(--tier1-border); }
.tier-group.tier-2 { background: var(--tier2-bg); border-color: var(--tier2-border); }
.tier-group.tier-3 { background: var(--tier3-bg); border-color: var(--tier3-border); }
.tier-group.tier-4 { background: var(--tier4-bg); border-color: var(--tier4-border); }
.tier-group.tier-5 { background: var(--tier5-bg); border-color: var(--tier5-border); }
.tier-group.tier-other { background: var(--tier-other-bg); border-color: var(--tier-other-border); }

.tier-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-bottom: 1px solid transparent;
}

.tier-group.tier-1 .tier-group-header { border-bottom-color: var(--tier1-border); }
.tier-group.tier-2 .tier-group-header { border-bottom-color: var(--tier2-border); }
.tier-group.tier-3 .tier-group-header { border-bottom-color: var(--tier3-border); }
.tier-group.tier-4 .tier-group-header { border-bottom-color: var(--tier4-border); }
.tier-group.tier-5 .tier-group-header { border-bottom-color: var(--tier5-border); }
.tier-group.tier-other .tier-group-header { border-bottom-color: var(--tier-other-border); }

.tier-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 9px;
  border-radius: 100px;
}

.tier-group.tier-1 .tier-badge { background: #fde047; color: var(--tier1-text); }
.tier-group.tier-2 .tier-badge { background: #93c5fd; color: var(--tier2-text); }
.tier-group.tier-3 .tier-badge { background: #86efac; color: var(--tier3-text); }
.tier-group.tier-4 .tier-badge { background: #d8b4fe; color: var(--tier4-text); }
.tier-group.tier-5 .tier-badge { background: #fdba74; color: var(--tier5-text); }
.tier-group.tier-other .tier-badge { background: var(--gray-200); color: var(--gray-600); }

.tier-title {
  font-size: 0.8rem;
  font-weight: 600;
}

.tier-group.tier-1 .tier-title { color: var(--tier1-text); }
.tier-group.tier-2 .tier-title { color: var(--tier2-text); }
.tier-group.tier-3 .tier-title { color: var(--tier3-text); }
.tier-group.tier-4 .tier-title { color: var(--tier4-text); }
.tier-group.tier-5 .tier-title { color: var(--tier5-text); }
.tier-group.tier-other .tier-title { color: var(--gray-600); }

.tier-count {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--gray-400);
  background: rgba(255,255,255,0.7);
  border-radius: 100px;
  padding: 2px 8px;
}

/* Company list inside tier */
.tier-group ul {
  list-style: none;
  padding: 8px 0;
}

.tier-group ul li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px;
  font-size: 0.875rem;
  color: var(--gray-700);
  border-bottom: 1px solid rgba(0,0,0,0.04);
  transition: background 0.1s;
  cursor: default;
}

.tier-group ul li:last-child { border-bottom: none; }

.tier-group ul li:hover {
  background: rgba(255,255,255,0.6);
}

.tier-group ul li::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tier-group.tier-1 ul li::before { background: var(--tier1-text); opacity: 0.5; }
.tier-group.tier-2 ul li::before { background: var(--tier2-text); opacity: 0.5; }
.tier-group.tier-3 ul li::before { background: var(--tier3-text); opacity: 0.5; }
.tier-group.tier-4 ul li::before { background: var(--tier4-text); opacity: 0.5; }
.tier-group.tier-5 ul li::before { background: var(--tier5-text); opacity: 0.5; }
.tier-group.tier-other ul li::before { background: var(--gray-400); }

/* ─── Overview / Markdown Body ─────────────────────────────── */
.markdown-body h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -0.04em;
  line-height: 1.15;
  margin-bottom: 8px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--gray-100);
  margin-bottom: 32px;
}

.markdown-body h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-top: 36px;
  margin-bottom: 14px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.markdown-body h2::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 1em;
  background: var(--brand);
  border-radius: 2px;
}

.markdown-body p {
  font-size: 0.9rem;
  color: var(--gray-600);
  margin-bottom: 14px;
  line-height: 1.75;
}

.markdown-body ul {
  list-style: none;
  margin-bottom: 16px;
}

.markdown-body ul li {
  font-size: 0.875rem;
  color: var(--gray-700);
  padding: 5px 0 5px 18px;
  position: relative;
  border-bottom: 1px solid var(--gray-100);
}

.markdown-body ul li:last-child { border-bottom: none; }

.markdown-body ul li::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brand-light);
  opacity: 0.5;
}

/* ─── Tables ─────────────────────────────────────────────── */
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0 32px;
  font-size: 0.875rem;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  background: var(--white);
}

.markdown-body th {
  background: var(--gray-50);
  padding: 11px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1.5px solid var(--gray-200);
}

.markdown-body td {
  padding: 11px 16px;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
  background: var(--white);
  transition: background 0.1s;
}

.markdown-body tr:last-child td { border-bottom: none; }
.markdown-body tr:hover td { background: var(--gray-50); }

.table-link {
  color: var(--brand);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.1s;
  cursor: pointer;
}

.table-link:hover {
  color: var(--brand-light);
  text-decoration: underline;
}

/* ─── Search highlight ─────────────────────────────────────── */
.search-highlight {
  background: #fef9c3;
  color: #713f12;
  padding: 1px 3px;
  border-radius: 3px;
  font-style: normal;
  border: 1px solid #fde68a;
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .main-content { padding: 28px 24px 48px; }
}

@media (max-width: 768px) {
  .header-search { display: none; }

  .mobile-menu-btn { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0,0,0,0.12);
  }

  .main-content {
    margin-left: 0;
    padding: 24px 16px 48px;
    max-width: 100%;
  }

  .category-header h1,
  .markdown-body h1 {
    font-size: 1.5rem;
  }
}
