* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  color: #24292f;
}

.app-container {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 320px;
  min-width: 320px;
  background: white;
  border-right: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.sidebar-header h1 {
  margin: 0 0 8px;
  font-size: 16px;
}

.meta {
  font-size: 11px;
  color: #6e7781;
  margin-bottom: 10px;
}

.controls input[type='search'] {
  width: 100%;
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid #d0d7de;
  font-size: 13px;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 4px 16px;
}

.tree-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-list .tree-list {
  padding-left: 14px;
}

.tree-node {
  margin: 0;
}

.tree-node.hidden {
  display: none;
}

.tree-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  background: none;
  border: 0;
  padding: 4px 8px;
  cursor: pointer;
  font: inherit;
  color: #24292f;
  text-align: left;
  border-radius: 4px;
  font-size: 13px;
}

.tree-toggle:hover {
  background: #f3f4f6;
}

.tree-toggle .caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 1em;
  line-height: 1;
  font-size: 10px;
  color: #6e7781;
  margin-right: 4px;
  transition: transform 0.1s;
}

.tree-node.collapsed > .tree-toggle .caret {
  transform: rotate(-90deg);
}

.tree-node.collapsed > .tree-list {
  display: none;
}

.tree-node-root {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid #eaeef2;
}

.tree-node-root:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.tree-node-root > .tree-toggle {
  font-size: 11px;
  font-weight: 600;
  color: #57606a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 8px;
}

.tree-node-root > .tree-toggle .caret {
  color: #57606a;
}

.tree-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: none;
  border: 0;
  padding: 4px 8px 4px 24px;
  cursor: pointer;
  font: inherit;
  color: #24292f;
  text-align: left;
  border-radius: 4px;
  font-size: 13px;
}

.tree-entry:hover {
  background: #f3f4f6;
}

.tree-entry.selected {
  background: #ddf4ff;
  color: #0969da;
  font-weight: 500;
}

.tree-entry .badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: #eaeef2;
  color: #57606a;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.tree-entry .badge.docs {
  background: #fff8c5;
  color: #9a6700;
}

.main-content {
  flex: 1;
  position: relative;
  background: white;
  overflow: hidden;
}

.story-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: white;
  display: none;
}

.story-iframe.active {
  display: block;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6e7781;
  font-size: 14px;
  padding: 0 20px;
  text-align: center;
}

.empty-state.hidden {
  display: none;
}

@media (max-width: 900px) {
  .app-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: 100%;
    max-height: 45vh;
    border-right: none;
    border-bottom: 1px solid #ddd;
  }

  .main-content {
    height: 55vh;
  }
}
