/* SUNO Style Guide Viewer — dark mode shell */
:root {
  color-scheme: dark;
  --bg: #191919;
  --bg-subtle: #141414;
  --bg-sidebar: #1c1c1c;
  --bg-sidebar-panel: #242424;
  --bg-elevated: #2a2a2a;
  --bg-hover: rgba(255, 255, 255, 0.06);
  --bg-active: rgba(77, 171, 247, 0.16);
  --text: rgba(255, 255, 255, 0.9);
  --text-secondary: rgba(255, 255, 255, 0.62);
  --text-muted: rgba(255, 255, 255, 0.42);
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.16);
  --accent: #4dabf7;
  --accent-hover: #74c0fc;
  --sidebar-width: 300px;
  --topbar-height: 52px;
  --radius: 8px;
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.35);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica,
    "Apple Color Emoji", Arial, sans-serif, "Segoe UI Emoji";
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-subtle);
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0)
    env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 20;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.35);
}

.sidebar-header {
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border-strong);
  flex-shrink: 0;
  background: var(--bg-sidebar-panel);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #4c6ef5 0%, #7950f2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}

.sidebar-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.sidebar-home {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
  margin-bottom: 8px;
  transition: all 0.15s ease;
}

.sidebar-home + .search-wrap {
  margin-top: 4px;
}

.sidebar-home:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.sidebar-home.active {
  background: var(--bg-active);
  border-color: var(--accent);
  color: var(--accent);
}

.search-wrap {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

#search {
  width: 100%;
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(77, 171, 247, 0.2);
}

#search::placeholder {
  color: var(--text-muted);
}

.search-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  padding-left: 2px;
}

#nav-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 12px 20px;
}

.nav-group {
  margin-bottom: 8px;
  background: var(--bg-sidebar-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.nav-group-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--bg-elevated);
  border: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  padding: 12px 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.nav-group-toggle:hover {
  background: #333333;
}

.nav-group-toggle .arrow {
  display: block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 7px 0 7px 11px;
  border-color: transparent transparent transparent var(--accent);
  transition: transform 0.2s ease;
  flex-shrink: 0;
  margin-right: 2px;
}

.nav-group:not(.collapsed) .nav-group-toggle .arrow {
  transform: rotate(90deg);
}

.nav-group-name {
  flex: 1;
  min-width: 0;
}

.nav-group-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 10px;
}

.nav-group.collapsed .nav-group-items {
  display: none;
}

.nav-group-items {
  padding: 6px 8px 10px;
  background: var(--bg-sidebar-panel);
  border-top: 1px solid var(--border);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.12s;
  line-height: 1.35;
}

.nav-item:hover {
  background: var(--bg-hover);
}

.nav-item.active {
  background: var(--bg-active);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item-eng {
  font-weight: 500;
}

.nav-item-ko {
  color: var(--text-secondary);
  font-size: 12px;
}

.nav-item-count {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 7px;
  border-radius: 10px;
  margin-left: 6px;
}

.nav-item.active .nav-item-count {
  color: var(--accent);
  background: rgba(77, 171, 247, 0.2);
}

.nav-item.active .nav-item-ko {
  color: var(--accent);
  opacity: 0.85;
}

.nav-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Main area ── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  background: var(--bg-subtle);
}

#topbar {
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#topbar-toggle {
  display: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text);
  line-height: 1;
}

#topbar-toggle:hover {
  background: var(--bg-hover);
}

#breadcrumb {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.breadcrumb-home {
  color: var(--text-secondary);
  cursor: pointer;
  background: none;
  border: none;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.12s;
}

.breadcrumb-home:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.breadcrumb-sep {
  color: var(--text-muted);
  font-size: 12px;
}

#page-title-bar {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.12s;
}

.topbar-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

.topbar-btn kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 11px;
  font-family: inherit;
  margin-left: 4px;
  color: var(--text-secondary);
}

.frame-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  padding: 12px;
}

#content-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: var(--bg);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.frame-loading {
  position: absolute;
  inset: 12px;
  background: var(--bg);
  border-radius: 10px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-secondary);
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.frame-loading.show {
  opacity: 1;
  pointer-events: auto;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#nav-list::-webkit-scrollbar {
  width: 6px;
}

#nav-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

#nav-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}

@media (max-width: 900px) {
  :root {
    --sidebar-width: min(300px, 92vw);
    --topbar-height: 56px;
  }

  #topbar {
    padding-top: max(0px, env(safe-area-inset-top, 0));
  }

  .nav-item {
    min-height: 44px;
    padding: 10px 12px;
  }

  .sidebar-home {
    min-height: 44px;
  }

  #topbar-toggle {
    min-width: 44px;
    min-height: 44px;
  }

  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #topbar-toggle {
    display: block;
  }

  .frame-wrap {
    padding: 0;
  }

  #content-frame {
    border-radius: 0;
    border: none;
  }

  .frame-loading {
    inset: 0;
    border-radius: 0;
    border: none;
  }
}

@media (max-width: 480px) {
  #topbar {
    padding: 0 12px;
  }

  .topbar-btn span {
    display: none;
  }
}
