:root {
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

html[data-theme="dark"],
html:not([data-theme]) {
  --bg: #0f1720;
  --panel: #16212c;
  --panel-2: #1d2a37;
  --line: #2a3a49;
  --text: #e8eef4;
  --muted: #9bb0c2;
  --accent: #4ade80;
  --accent-ink: #06281a;
  --topbar-from: #12202b;
  --topbar-to: #1a2c3a;
  --install-bg: #0b1218;
  --shot-bg: #0b1218;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #eef2f6;
  --panel: #ffffff;
  --panel-2: #e6ecf2;
  --line: #c9d4de;
  --text: #14202a;
  --muted: #5a6f82;
  --accent: #1f9d55;
  --accent-ink: #ffffff;
  --topbar-from: #f7fafc;
  --topbar-to: #eef4f8;
  --install-bg: #0b1218;
  --shot-bg: #e6ecf2;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.55;
  transition: background-color 0.2s ease, color 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: linear-gradient(90deg, var(--topbar-from), var(--topbar-to));
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.2px;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-btn {
  display: inline-flex;
  align-items: center;
  font: inherit;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
}

.header-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle {
  min-width: 38px;
  justify-content: center;
  padding: 6px 10px;
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  display: block;
}

.theme-toggle .icon-sun {
  display: none;
}

.theme-toggle .icon-moon {
  display: block;
}

html[data-theme="light"] .theme-toggle .icon-sun {
  display: block;
}

html[data-theme="light"] .theme-toggle .icon-moon {
  display: none;
}

.menu-toggle {
  display: none;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 1rem;
  cursor: pointer;
}

.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  align-items: start;
  min-height: calc(100vh - 57px);
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 57px;
  max-height: calc(100vh - 57px);
  overflow-y: auto;
  padding: 16px;
}

.sidebar-controls {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.field {
  display: grid;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field input,
.field select {
  font: inherit;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
}

.field input:focus,
.field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.count {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.app-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.app-list button {
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}

.app-list button:hover {
  background: var(--panel-2);
}

.app-list button[aria-current="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.content {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 28px clamp(20px, 4vw, 48px);
}

.placeholder h2,
.detail h2 {
  margin-top: 0;
}

.placeholder p {
  color: var(--muted);
}

.detail-text {
  font-size: 1.05rem;
  color: var(--muted);
}

.tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 14px 0;
}

.tags li {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 0.82rem;
}

.site-link {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.site-link:hover {
  text-decoration: underline;
}

.detail h3 {
  margin-top: 28px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.install {
  display: flex;
  gap: 10px;
  align-items: stretch;
  background: var(--install-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: #e8eef4;
}

.install pre {
  margin: 0;
  flex: 1;
  overflow-x: auto;
}

.install code {
  font-family: var(--mono);
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: #e8eef4;
}

.copy {
  align-self: flex-start;
  font: inherit;
  font-size: 0.85rem;
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
  font-weight: 600;
}

.copy:hover {
  filter: brightness(1.08);
}

.shot {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--shot-bg);
}

@media (max-width: 820px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .menu-toggle {
    display: block;
  }
  .sidebar {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar[hidden] {
    display: none;
  }
}
