/* ============================================================
   Design tokens (same palette as editor)
   ============================================================ */
:root {
  --bg: #f8f9fa;
  --sidebar-bg: #1e1e2e;
  --sidebar-text: #cdd6f4;
  --sidebar-hover: #2a2a3e;
  --sidebar-active: #313244;
  --topbar-bg: #ffffff;
  --topbar-border: #e5e7eb;
  --accent: #89b4fa;

  --tier1: #60a5fa;
  --tier2: #fbbf24;
  --tier3: #34d399;
  --sub:   #a78bfa;

  --font: system-ui, -apple-system, sans-serif;
  --radius: 6px;
  --topbar-h: 48px;
  --sidebar-w: 280px;
  --meta-h: 80px;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   Top bar
   ============================================================ */
#topbar {
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 10;
}

.logo { font-weight: 700; font-size: 15px; }
.topbar-sep { color: #aaa; margin: 0 6px; }
.topbar-title { color: #555; font-size: 14px; }

.btn-edit {
  padding: 6px 14px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #1e1e2e;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
}

/* ============================================================
   Layout
   ============================================================ */
#layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ============================================================
   Sidebar
   ============================================================ */
#sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-search {
  padding: 10px;
  border-bottom: 1px solid #2a2a3e;
}

.sidebar-search input {
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius);
  border: 1px solid #444;
  background: #2a2a3e;
  color: var(--sidebar-text);
  font-size: 13px;
  font-family: var(--font);
}

.sidebar-search input::placeholder { color: #666; }
.sidebar-search input:focus { outline: 2px solid var(--accent); border-color: transparent; }

.tier-group { margin-bottom: 4px; }

.tier-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #888;
}

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

.tier-dot.tier1 { background: var(--tier1); }
.tier-dot.tier2 { background: var(--tier2); }
.tier-dot.tier3 { background: var(--tier3); }
.tier-dot.sub   { background: var(--sub); }

.file-item {
  display: flex;
  align-items: center;
  padding: 7px 12px 7px 28px;
  font-size: 13px;
  cursor: pointer;
  border-radius: var(--radius);
  margin: 1px 6px;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item:hover  { background: var(--sidebar-hover); }
.file-item.active { background: var(--sidebar-active); color: #fff; }
.file-item.hidden { display: none; }

.empty-tier {
  padding: 4px 28px 8px;
  font-size: 11px;
  color: #555;
  font-style: italic;
}

/* ============================================================
   Main area
   ============================================================ */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Welcome state */
#welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px;
  color: #444;
}

#welcome h2 { font-size: 22px; font-weight: 600; }
#welcome > p { color: #777; font-size: 15px; }

.tier-guide {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 480px;
  margin-top: 8px;
}

.tier-guide-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.tier-guide-item .tier-dot {
  margin-top: 4px;
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}

.tier-guide-item strong { display: block; font-size: 14px; margin-bottom: 2px; }
.tier-guide-item p      { font-size: 13px; color: #777; }

/* Diagram view */
#diagram-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#diagram-view.hidden { display: none; }

#canvas-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#canvas { width: 100%; height: 100%; }

/* Zoom controls overlay */
#zoom-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#zoom-controls button {
  width: 32px;
  height: 32px;
  border: 1px solid #ddd;
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

#zoom-controls button:hover { background: #f0f0f0; }

/* Metadata panel */
#meta-panel {
  border-top: 1px solid #e5e7eb;
  background: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  min-height: 56px;
}

#meta-badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

#meta-badge.tier1 { background: #dbeafe; color: #1d4ed8; }
#meta-badge.tier2 { background: #fef3c7; color: #92400e; }
#meta-badge.tier3 { background: #d1fae5; color: #065f46; }
#meta-badge.sub   { background: #ede9fe; color: #5b21b6; }

#meta-details {
  display: flex;
  gap: 20px;
  font-size: 13px;
  color: #666;
}

#meta-description {
  font-size: 13px;
  color: #555;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hidden { display: none !important; }
