:root {
  --bg: #f4f5f7;
  --surface: #fff;
  --border: #dfe1e6;
  --text: #172b4d;
  --muted: #5e6c84;
  --accent: #0052cc;
  --tip-bg: #e3fcef;
  --note-bg: #eae6ff;
  --warning-bg: #fffae6;
  --sidebar-w: 280px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.6; }

.search-wrap { position: relative; }
.sidebar-search { margin-bottom: 0.85rem; flex-shrink: 0; }
#search-input { width: 100%; padding: 0.45rem 0.75rem; border: 1px solid var(--border); border-radius: 4px; }
.search-results {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 50; background: var(--surface);
  border: 1px solid var(--border); border-radius: 4px; max-height: min(320px, 50vh); overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.search-results a { display: block; padding: 0.5rem 0.75rem; text-decoration: none; color: var(--text); border-bottom: 1px solid var(--bg); }
.search-results a:hover { background: var(--bg); }
.search-results .hint { font-size: 0.85rem; color: var(--muted); }

.layout { display: flex; min-height: 100vh; align-items: stretch; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: transparent;
  border-right: none; padding: 1rem 0.6rem 1rem 1rem; overflow: auto;
  position: sticky; top: 0; align-self: flex-start; max-height: 100vh;
  display: flex; flex-direction: column;
}
.splitter {
  width: 8px; flex-shrink: 0; cursor: col-resize; background: var(--border);
  position: sticky; top: 0; align-self: stretch;
  display: flex; align-items: center; justify-content: center;
}
.splitter-grip { color: #6b778c; font-size: 14px; line-height: 1; pointer-events: none; user-select: none; }
.layout:not(:has(.sidebar)) .splitter { display: none; }
.layout:not(:has(.sidebar)) .content { padding: 1rem; }
.splitter:hover, .splitter.dragging { background: #4c9aff; }
.layout.resizing, .layout.resizing * { cursor: col-resize !important; user-select: none; }
.sidebar-space { margin-bottom: 0.75rem; font-size: 0.9rem; }
.sidebar-space a { color: var(--accent); text-decoration: none; }
.content {
  flex: 1; min-width: 0;
  padding: 1.25rem 1.5rem 2rem;
  background: var(--bg);
  overflow: auto;
}
.article-sheet {
  width: 100%;
  max-width: 60rem;
  margin: 0 auto;
  padding: 2rem 2.5rem 2.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(9, 30, 66, 0.08);
  min-width: 0;
}

.breadcrumbs { font-size: 0.85rem; color: var(--muted); margin-bottom: 1rem; }
.breadcrumbs a { color: var(--accent); }
.page-title { margin-top: 0; }
.meta { font-size: 0.85rem; color: var(--muted); margin-bottom: 1.5rem; }

.page-tree ul { list-style: none; margin: 0; padding-left: 0.85rem; }
.page-tree > ul { padding-left: 0; }
.page-tree li { margin: 0.32rem 0; font-size: 0.9rem; line-height: 1.45; }
.page-tree li > ul { display: none; }
.page-tree li.open > ul { display: block; }
.tree-row { display: flex; align-items: flex-start; gap: 0.25rem; }
.page-tree a {
  color: var(--text); text-decoration: none; flex: 1; min-width: 0; overflow-wrap: anywhere;
  padding: 0.12rem 0;
}
.page-tree a:hover, .page-tree a.active { color: var(--accent); font-weight: 600; }
.page-tree .toggle {
  flex: 0 0 1.5rem; width: 1.5rem; height: 1.5rem; margin-top: 0;
  border: 0; padding: 0; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 1.05rem; line-height: 1.5rem; text-align: center;
}
.page-tree .toggle.spacer { cursor: default; visibility: hidden; }
.page-tree .toggle:hover { color: var(--accent); }

.wiki-content img { max-width: 100%; height: auto; }
.wiki-content iframe,
.wiki-content iframe.youtube-player {
  display: block;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border: 0;
  margin: 1rem 0;
}
.wiki-content { overflow-wrap: break-word; }
.wiki-content .table-wrap {
  overflow-x: auto;
  max-width: 100%;
  margin: 1rem 0;
  -webkit-overflow-scrolling: touch;
}
.wiki-content table,
.wiki-content table.confluenceTable {
  border-collapse: collapse;
  width: 100% !important;
  max-width: 100%;
  table-layout: auto;
  margin: 0;
}
.wiki-content table th,
.wiki-content table td,
.wiki-content table.confluenceTable th,
.wiki-content table.confluenceTable td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  word-break: break-word;
  overflow-wrap: anywhere;
  vertical-align: top;
}
.wiki-content pre, .wiki-content code { background: #f4f5f7; border-radius: 3px; font-size: 0.9em; }
.wiki-content pre { padding: 1rem; overflow-x: auto; }

.confluence-information-macro { border-radius: 4px; padding: 0.75rem 1rem; margin: 1rem 0; display: flex; gap: 0.5rem; }
.confluence-information-macro-tip { background: var(--tip-bg); }
.confluence-information-macro-note { background: var(--note-bg); }
.confluence-information-macro-warning { background: var(--warning-bg); }
.confluence-information-macro-information { background: #deebff; }

.expand-container .expand-control { cursor: pointer; color: var(--accent); font-weight: 600; }
.expand-container.collapsed .expand-content { display: none; }

.space-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.space-card {
  display: block; padding: 1.25rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; text-decoration: none; color: inherit;
}
.space-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,82,204,.15); }
.space-card h2 { margin: 0 0 0.25rem; font-size: 1.1rem; color: var(--accent); }
.space-key { font-size: 0.8rem; color: var(--muted); }
.count { font-size: 0.85rem; margin-top: 0.75rem; }
.btn { display: inline-block; padding: 0.5rem 1rem; background: var(--accent); color: #fff; border-radius: 4px; text-decoration: none; }
.child-pages ul, .attachments ul { padding-left: 1.25rem; }

@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100% !important; position: static; max-height: none; }
  .splitter { display: none; }
  .content { padding: 0.75rem; }
  .article-sheet { padding: 1.25rem 1rem 1.5rem; border-radius: 6px; }
}
