:root {
  color-scheme: dark;
  --bg: #090909;
  --panel: #171717;
  --panel-2: #1b1b1b;
  --surface: #171717;
  --text: #f4f4f5;
  --muted: #a2a2a7;
  --line: #303033;
  --accent: #f0f0f1;
  --accent-text: #161616;
  --soft: #282828;
  --soft-hover: #303030;
  --danger: #ff6b6b;
  --ok: #61d394;
  --logo-bg: #171717;
  --avatar-bg: #171717;
  --shadow: rgba(0, 0, 0, .22);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f6f7;
  --panel: #ffffff;
  --panel-2: #f9f9fa;
  --surface: #ffffff;
  --text: #18181a;
  --muted: #6e6e73;
  --line: #e3e3e6;
  --accent: #18181a;
  --accent-text: #ffffff;
  --soft: #eeeeef;
  --soft-hover: #e5e5e7;
  --danger: #c93b3b;
  --ok: #0f8a4b;
  --logo-bg: #ffffff;
  --avatar-bg: #ffffff;
  --shadow: rgba(0, 0, 0, .06);
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px 1fr;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: grid-template-columns .18s ease;
}

body.sidebar-collapsed {
  grid-template-columns: 72px 1fr;
}

body.is-public-home {
  grid-template-columns: 1fr;
}

body.is-public-home .sidebar {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px 10px 18px;
  overflow: hidden;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 0 28px;
}

.logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--logo-bg);
}

.logo-link {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  background: var(--logo-bg);
  text-decoration: none;
}

.logo-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.brand strong {
  display: block;
  font-size: 19px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand span, p, label, small { color: var(--muted); }
.brand span { display: block; font-size: 14px; font-weight: 700; }

section { margin: 24px 0; }

#packPanel {
  min-height: 0;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  margin: 18px 0;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; line-height: 1.15; letter-spacing: 0; }
h2 { font-size: 22px; line-height: 1.2; }
h3 { font-size: 17px; }

.primary-nav {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
}

.nav-label,
.section-title h2 {
  padding: 0 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 10px;
}

.title-actions {
  display: flex;
  gap: 4px;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  padding: 11px 12px;
  font: inherit;
  outline: none;
  margin: 7px 0;
}

input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted), transparent 25%); }
input:focus, textarea:focus { border-color: color-mix(in srgb, var(--text), var(--line) 55%); }

select {
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  padding: 0 14px;
  font: inherit;
  font-weight: 800;
  outline: none;
}

select:disabled {
  opacity: .48;
}

textarea {
  min-height: 86px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  padding: 10px 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

button.secondary {
  background: var(--soft);
  color: var(--text);
}

button.secondary:hover, .nav-action:hover, .icon-btn:hover, .pack-main:hover, .top-icon:hover {
  background: var(--soft-hover);
}

button:disabled {
  opacity: .38;
  cursor: default;
}

.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.icon-btn.active {
  background: var(--soft);
  color: var(--text);
}

.icon-btn.danger { color: var(--danger); }

.nav-icon {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  color: currentColor;
}

.nav-icon svg,
.pack-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.row { display: flex; gap: 8px; align-items: center; }
.row > input { margin: 0; }

main {
  min-width: 0;
  padding: 0 30px 56px;
}

.home-page,
.upload-page {
  min-height: calc(100vh - 56px);
  margin: 0 -30px -56px;
  background: var(--bg);
}

.home-header {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.home-brand {
  width: auto;
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 0;
  background: transparent;
  color: var(--text);
  border-radius: 0;
  font-size: 28px;
}

.home-brand:hover {
  background: transparent;
}

.home-logo {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  color: var(--text);
}

.home-actions {
  display: inline-flex;
  align-items: center;
  gap: 18px;
}

.header-action,
.header-theme-btn,
.circle-action {
  display: inline-flex;
  align-items: center;
  background: transparent;
  color: var(--text);
  padding: 8px;
}

.header-action {
  gap: 10px;
}

.header-action {
  font-size: 20px;
}

.circle-action,
.header-theme-btn,
.home-avatar {
  width: 52px;
  height: 52px;
  border-radius: 999px;
}

.header-theme-btn,
.circle-action {
  justify-content: center;
}

.header-theme-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.header-theme-btn:hover {
  background: var(--soft);
}

.home-avatar {
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 26px;
  font-weight: 500;
}

.home-avatar:hover {
  background: var(--soft);
}

.home-avatar[hidden] {
  display: none;
}

.database-shell {
  width: min(1320px, calc(100% - 64px));
  margin: 68px auto;
}

.database-tools {
  display: grid;
  gap: 44px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.database-search {
  display: grid;
  grid-template-columns: 1fr 136px;
  gap: 12px;
}

.database-search input {
  height: 58px;
  margin: 0;
  border-radius: 10px;
  font-size: 20px;
  font-weight: 800;
  background: var(--surface);
}

.database-search button {
  height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: 10px;
  font-size: 19px;
}

.database-filter-row {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.segment-tabs {
  min-width: 0;
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}

.segment-tab {
  min-width: 112px;
  min-height: 52px;
  border-radius: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 18px;
}

.segment-tab:last-child {
  border-right: 0;
}

.segment-tab.active {
  color: var(--text);
  background: var(--panel-2);
}

.segment-arrow {
  min-width: 60px;
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.segment-arrow .nav-icon {
  width: 24px;
  height: 24px;
}

.sort-button {
  min-width: 128px;
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
}

.sort-button.active {
  background: var(--soft);
}

.database-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 520px);
  gap: 40px;
  align-items: start;
  padding-top: 26px;
}

.database-layout:not(.has-detail) {
  grid-template-columns: minmax(0, 1fr);
}

.database-layout:not(.has-detail) .database-list {
  max-width: 860px;
}

.database-list {
  display: grid;
  gap: 20px;
}

.database-card {
  min-height: 120px;
  display: grid;
  grid-template-columns: 28px 66px 1fr;
  gap: 20px;
  align-items: center;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.database-card.active {
  border-color: color-mix(in srgb, var(--text), var(--line) 60%);
}

.database-check {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 2px 5px var(--shadow);
}

.database-avatar {
  display: inline-grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--avatar-a), var(--avatar-b));
  color: #fff;
  font-weight: 950;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}

.database-avatar.small {
  width: 66px;
  height: 66px;
  font-size: 30px;
}

.database-avatar.large {
  width: 104px;
  height: 104px;
  margin: 28px 0 22px;
  font-size: 48px;
}

.database-main {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(260px, auto);
  align-items: center;
  gap: 18px;
  background: transparent;
  color: var(--text);
  padding: 0;
  text-align: left;
}

.database-main:hover {
  background: transparent;
}

.database-main strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 24px;
  line-height: 1.2;
}

.database-meta {
  color: var(--muted);
  font: 800 19px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: right;
  overflow-wrap: anywhere;
}

.database-empty {
  padding: 60px 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.database-detail,
.upload-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 8px 24px var(--shadow);
}

.database-detail {
  position: sticky;
  top: 24px;
  padding: 34px 28px;
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.detail-head h2 {
  font-size: 28px;
}

.detail-close {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--text);
  padding: 0;
  font-size: 30px;
  font-weight: 400;
}

.adapted-select {
  width: 100%;
  min-height: 52px;
  display: grid;
  grid-template-columns: 1fr 58px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
}

.adapted-select span {
  display: grid;
  place-items: center;
}

.adapted-select span + span {
  border-left: 1px solid var(--line);
}

.detail-list {
  display: grid;
  gap: 8px;
  margin: 28px 0;
}

.detail-list dt {
  color: var(--muted);
  font-size: 19px;
  font-weight: 800;
}

.detail-list dd {
  margin: 0 0 18px;
  font: 850 17px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
}

.tag-add {
  width: 48px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 24px;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.detail-divider,
.upload-divider {
  height: 1px;
  background: var(--line);
}

.localized-box {
  margin: 24px 0 0;
}

.localized-box h3 {
  margin-bottom: 16px;
  font-size: 21px;
}

.localized-box p {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 10px 0;
  color: var(--text);
  font-weight: 800;
}

.localized-box span {
  min-width: 48px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--soft);
  color: var(--text);
}

.upload-shell {
  width: min(1360px, calc(100% - 64px));
  margin: 52px auto;
}

.upload-intro {
  margin-bottom: 44px;
}

.upload-intro h2 {
  font-size: clamp(40px, 4vw, 52px);
  margin-bottom: 12px;
}

.upload-intro p {
  font-size: clamp(20px, 2vw, 25px);
  font-weight: 800;
}

.upload-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 40px;
  align-items: start;
}

.upload-card {
  padding: 38px;
}

.upload-card h3 {
  font-size: 28px;
  margin-bottom: 10px;
}

.upload-card p {
  font-size: 21px;
  font-weight: 800;
}

.drop-zone {
  min-height: 320px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  margin-top: 42px;
  border: 3px dashed color-mix(in srgb, var(--muted), transparent 55%);
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
}

.drop-zone.dragging {
  border-color: var(--text);
  background: var(--panel-2);
}

.drop-icon {
  width: 72px;
  height: 72px;
  display: inline-grid;
  place-items: center;
}

.drop-icon .nav-icon {
  width: 60px;
  height: 60px;
}

.drop-zone strong {
  color: var(--text);
  font-size: 24px;
}

.drop-zone span:last-child {
  font-size: 22px;
  font-weight: 800;
}

.upload-detail-card {
  display: grid;
  gap: 22px;
}

.upload-detail-card label {
  margin-bottom: -12px;
  color: var(--text);
  font-size: 20px;
  font-weight: 900;
}

.upload-submit {
  min-height: 64px;
  margin-top: 4px;
  background: var(--accent);
  font-size: 20px;
}

.topbar {
  min-height: 70px;
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 22px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  margin: 0 -30px 34px;
  padding: 0 30px 0 0;
}

.top-icon {
  width: 58px;
  height: 70px;
  display: inline-grid;
  place-items: center;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
}

#breadcrumb {
  color: var(--muted);
  font-weight: 800;
}

#subtitle:empty { display: none; }

.card,
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 32px var(--shadow);
}

.card {
  padding: 28px 30px;
  margin-bottom: 28px;
}

.page-intro {
  margin: 10px 0 30px;
}

.page-intro h2 {
  font-size: 34px;
  margin-bottom: 4px;
}

.page-intro p {
  font-size: 19px;
  font-weight: 700;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  min-height: 174px;
  padding: 34px 30px;
}

.stat-card h3 {
  margin-bottom: 42px;
}

.stat-card strong {
  display: block;
  font-size: 36px;
  line-height: 1;
  margin-bottom: 8px;
}

.stat-card p {
  font-size: 15px;
  font-weight: 700;
}

.activity-card {
  min-height: 170px;
}

.activity-card h2 {
  margin-bottom: 4px;
}

.empty-activity {
  padding-top: 34px;
  color: var(--muted);
  font-weight: 750;
}

.activity-list {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.activity-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.activity-item strong,
.activity-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  margin-bottom: 24px;
}

.version-create {
  width: min(360px, 100%);
}

pre {
  overflow: auto;
  margin: 7px 0 16px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #080809;
  color: #f6f6f6;
  font-size: 13px;
}

:root[data-theme="light"] pre {
  background: #111113;
  color: #f7f7f8;
}

.pack-list {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  max-height: max(180px, calc(100vh - 520px));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
  -webkit-overflow-scrolling: touch;
}

.pack-list::-webkit-scrollbar {
  width: 6px;
}

.pack-list::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted), transparent 58%);
  border-radius: 999px;
}

.pack-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px;
  border-radius: 8px;
}

.pack-item.active {
  background: var(--soft);
}

.pack-main {
  min-width: 0;
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 8px 6px;
  text-align: left;
}

.pack-item.selecting .pack-main {
  grid-template-columns: 20px 24px 1fr;
}

.pack-main strong,
.pack-main small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pack-main strong {
  font-size: 17px;
  line-height: 1.3;
}

.pack-main small { display: none; }

.pack-icon {
  width: 22px;
  height: 22px;
  color: var(--text);
}

.pack-check {
  width: 17px;
  height: 17px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--accent);
  font-size: 12px;
}

.pack-item.checked .pack-check {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.pack-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  padding-right: 2px;
}

.pack-item:hover .pack-actions,
.pack-item.active .pack-actions,
.pack-item.selecting .pack-actions {
  opacity: 1;
}

.bulk-bar {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 4px;
  align-items: center;
  margin: 0 4px 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.bulk-bar span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.text-btn {
  padding: 4px 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}

.danger-text {
  color: var(--danger);
}

.create-pack {
  padding: 0 4px;
}

.create-pack input {
  margin-bottom: 6px;
}

.nav-action {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.nav-link {
  min-height: 38px;
  justify-content: flex-start;
  border-radius: 8px;
  padding: 8px 8px;
}

.nav-action.secondary,
.nav-link.active {
  background: transparent;
}

.nav-link:hover,
.nav-link:active,
.nav-link:focus-visible {
  background: var(--soft);
}

.muted-link {
  color: var(--muted);
}

.side-actions {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.user-badge {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 12px;
  padding: 10px 4px 0;
}

.user-avatar {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--avatar-bg);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 900;
  font-size: 20px;
}

.user-badge strong,
.user-badge small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-btn {
  justify-self: end;
  color: var(--muted);
}

body.sidebar-collapsed .sidebar {
  align-items: center;
  padding: 8px 6px 18px;
}

body.sidebar-collapsed .brand {
  width: 100%;
  justify-content: center;
  padding-bottom: 22px;
}

body.sidebar-collapsed .brand > div,
body.sidebar-collapsed #authPanel,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .section-title h2,
body.sidebar-collapsed .title-actions,
body.sidebar-collapsed .bulk-bar,
body.sidebar-collapsed .create-pack input,
body.sidebar-collapsed .nav-link span:not(.nav-icon),
body.sidebar-collapsed .pack-check,
body.sidebar-collapsed .pack-main strong,
body.sidebar-collapsed .pack-main small,
body.sidebar-collapsed .pack-actions,
body.sidebar-collapsed .user-badge > span:not(.user-avatar),
body.sidebar-collapsed .logout-btn {
  display: none !important;
}

body.sidebar-collapsed .primary-nav,
body.sidebar-collapsed #packPanel,
body.sidebar-collapsed .side-actions {
  width: 100%;
}

body.sidebar-collapsed .primary-nav {
  margin-bottom: 18px;
}

body.sidebar-collapsed #packPanel {
  align-items: center;
}

body.sidebar-collapsed .section-title {
  display: none;
}

body.sidebar-collapsed .pack-list {
  width: 100%;
  max-height: calc(100vh - 310px);
  margin: 0 0 10px;
  padding-right: 0;
}

body.sidebar-collapsed .pack-item {
  display: flex;
  justify-content: center;
}

body.sidebar-collapsed .pack-main,
body.sidebar-collapsed .pack-item.selecting .pack-main,
body.sidebar-collapsed .nav-link {
  width: 52px;
  min-height: 52px;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  gap: 0;
  padding: 0;
}

body.sidebar-collapsed .pack-main {
  color: var(--muted);
}

body.sidebar-collapsed .pack-item.active .pack-main,
body.sidebar-collapsed .nav-link:hover,
body.sidebar-collapsed .nav-link:active,
body.sidebar-collapsed .nav-link:focus-visible {
  background: var(--soft);
  color: var(--text);
}

body.sidebar-collapsed .pack-item.active {
  background: transparent;
}

body.sidebar-collapsed .create-pack {
  width: 100%;
  padding: 0;
}

body.sidebar-collapsed .side-actions {
  justify-items: center;
}

body.sidebar-collapsed .user-badge {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 8px 0 0;
}

body.sidebar-collapsed .user-avatar {
  width: 44px;
  height: 44px;
}

.tools {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 10px;
}

.import-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 18px;
}

.table-wrap { overflow: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

.compact-table table { min-width: 560px; }

th, td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--text);
  font-size: 16px;
}

td {
  font-weight: 750;
}

td.mono {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

.permission-input {
  width: 132px;
  min-height: 34px;
  margin: 0;
  padding: 6px 9px;
  font-size: 14px;
  font-weight: 850;
}

.permission-pill {
  display: inline-grid;
  min-height: 32px;
  place-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
}

.selected-row {
  background: color-mix(in srgb, var(--soft), transparent 44%);
}

.actions-cell {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.app-cell {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 14px;
  align-items: center;
}

.app-avatar {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent), transparent 18%);
  color: var(--accent-text);
  font-weight: 900;
  font-size: 18px;
}

.pill {
  display: inline-block;
  margin-right: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
}

.split-action,
.remove-action {
  min-width: 126px;
  display: inline-grid;
  grid-template-columns: 1fr 36px;
  align-items: center;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--text);
}

.split-action span,
.remove-action span {
  display: inline-grid;
  place-items: center;
  min-height: 38px;
  padding: 0 12px;
}

.split-action span + span,
.remove-action span + span {
  border-left: 1px solid var(--line);
  padding: 0;
}

.remove-action {
  background: #aa4447;
  color: #fff;
}

.remove-action span + span {
  background: var(--soft);
  color: var(--text);
}

.adapted { color: var(--ok); font-weight: 800; }
.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-weight: 800; }
.check input { width: auto; margin: 0; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  translate: -50% 0;
  background: var(--accent);
  color: var(--accent-text);
  padding: 10px 14px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease;
  box-shadow: 0 12px 32px var(--shadow);
}

#toast.show { opacity: 1; }

.auth-loading {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .42);
  backdrop-filter: blur(6px);
}

.spinner {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, .28);
  border-top-color: #fff;
  animation: spin .8s linear infinite;
}

button:disabled {
  cursor: progress;
  opacity: .68;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .62);
  touch-action: none;
  overscroll-behavior: contain;
}

.modal-card {
  width: min(420px, calc(100vw - 32px));
  display: grid;
  gap: 14px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .34);
}

.modal-card input {
  margin: 2px 0 0;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 920px) {
  body {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    min-height: 0;
  }
  body.is-authenticated {
    display: block;
    min-width: 0;
    overflow-x: hidden;
  }
  body.is-public-home {
    min-width: 0;
    overflow-x: hidden;
  }
  body.is-authenticated .sidebar {
    width: 100%;
    height: auto;
    max-height: none;
    padding: 14px 14px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }
  body.is-authenticated .brand {
    padding-bottom: 16px;
  }
  body.is-authenticated .primary-nav,
  body.is-authenticated .side-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  body.is-authenticated .nav-action,
  body.is-authenticated .nav-link {
    min-width: 0;
  }
  body.is-authenticated .nav-link {
    justify-content: center;
    padding: 10px 8px;
  }
  body.is-authenticated .nav-action span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
  }
  body.is-authenticated #packPanel {
    max-height: none;
    margin: 12px 0;
  }
  body.is-authenticated .pack-list {
    max-height: 220px;
  }
  body.is-authenticated .user-badge {
    grid-column: 1 / -1;
  }
  main { padding: 0 16px 32px; }
  .topbar {
    grid-template-columns: 48px minmax(0, 1fr);
    margin: 0 -16px 22px;
    padding-right: 16px;
  }
  .topbar > .row {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: end;
    padding-bottom: 10px;
  }
  .top-icon { width: 48px; height: 64px; }
  .card-head, .tools, .import-box { grid-template-columns: 1fr; display: grid; }
  .version-create { width: 100%; }
  .pack-actions { opacity: 1; }
  .stat-grid { grid-template-columns: 1fr; }
  body.is-public-home .home-page,
  body.is-authenticated .home-page,
  body.is-authenticated .upload-page {
    margin: 0 -16px -32px;
    min-height: auto;
  }
  body.is-public-home .home-header,
  body.is-authenticated .home-header {
    min-height: 62px;
    padding: 0 14px;
  }
  body.is-public-home .home-brand,
  body.is-authenticated .home-brand {
    gap: 10px;
    font-size: 20px;
  }
  body.is-public-home .home-logo,
  body.is-authenticated .home-logo {
    width: 32px;
    height: 32px;
  }
  body.is-public-home .home-actions,
  body.is-authenticated .home-actions {
    gap: 8px;
  }
  body.is-public-home .header-action,
  body.is-authenticated .header-action {
    font-size: 16px;
    gap: 6px;
  }
  body.is-public-home .home-avatar,
  body.is-public-home .header-theme-btn,
  body.is-authenticated .circle-action,
  body.is-authenticated .header-theme-btn,
  body.is-authenticated .home-avatar {
    width: 40px;
    height: 40px;
  }
  body.is-public-home .home-avatar,
  body.is-authenticated .home-avatar {
    font-size: 20px;
  }
  body.is-public-home .database-shell,
  body.is-authenticated .database-shell,
  body.is-authenticated .upload-shell {
    width: calc(100% - 28px);
    margin: 22px auto;
  }
  body.is-public-home .database-tools,
  body.is-authenticated .database-tools {
    gap: 16px;
    padding-bottom: 14px;
  }
  body.is-public-home .database-search,
  body.is-authenticated .database-search {
    grid-template-columns: 1fr;
  }
  body.is-public-home .database-search input,
  body.is-public-home .database-search button,
  body.is-authenticated .database-search input,
  body.is-authenticated .database-search button {
    height: 50px;
    font-size: 16px;
  }
  body.is-public-home .database-filter-row,
  body.is-authenticated .database-filter-row {
    justify-content: stretch;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  body.is-public-home .segment-tabs,
  body.is-authenticated .segment-tabs {
    flex: 1 0 auto;
  }
  body.is-public-home .segment-tab,
  body.is-authenticated .segment-tab {
    min-width: 88px;
    min-height: 46px;
    font-size: 14px;
    padding: 8px 10px;
  }
  body.is-public-home .segment-arrow,
  body.is-authenticated .segment-arrow {
    min-width: 46px;
  }
  body.is-public-home .sort-button,
  body.is-authenticated .sort-button {
    min-width: 92px;
    min-height: 46px;
    font-size: 14px;
  }
  body.is-public-home .database-layout,
  body.is-public-home .database-layout.has-detail,
  body.is-authenticated .database-layout,
  body.is-authenticated .database-layout.has-detail {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    padding-top: 14px;
  }
  body.is-public-home .database-card,
  body.is-authenticated .database-card {
    min-height: 86px;
    grid-template-columns: 22px 48px 1fr;
    gap: 12px;
    padding: 14px 12px;
  }
  body.is-public-home .database-check,
  body.is-authenticated .database-check {
    width: 20px;
    height: 20px;
  }
  body.is-public-home .database-avatar.small,
  body.is-authenticated .database-avatar.small {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    font-size: 22px;
  }
  body.is-public-home .database-main,
  body.is-authenticated .database-main {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  body.is-public-home .database-main strong,
  body.is-authenticated .database-main strong {
    font-size: 18px;
  }
  body.is-public-home .database-meta,
  body.is-authenticated .database-meta {
    font-size: 12px;
    text-align: left;
  }
  body.is-public-home .database-detail,
  body.is-authenticated .database-detail {
    position: static;
    padding: 22px 18px;
  }
  body.is-public-home .detail-head h2,
  body.is-authenticated .detail-head h2 {
    font-size: 22px;
  }
  body.is-public-home .database-avatar.large,
  body.is-authenticated .database-avatar.large {
    width: 86px;
    height: 86px;
    font-size: 40px;
  }
  body.is-authenticated .upload-intro {
    margin-bottom: 22px;
  }
  body.is-authenticated .upload-intro h2 {
    font-size: 32px;
  }
  body.is-authenticated .upload-intro p {
    font-size: 17px;
  }
  body.is-authenticated .upload-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }
  body.is-authenticated .upload-card {
    padding: 22px 18px;
  }
  body.is-authenticated .upload-card h3 {
    font-size: 22px;
  }
  body.is-authenticated .upload-card p {
    font-size: 15px;
  }
  body.is-authenticated .drop-zone {
    min-height: 210px;
    margin-top: 22px;
  }
  body.is-authenticated .drop-zone strong {
    font-size: 18px;
  }
  body.is-authenticated .drop-zone span:last-child {
    font-size: 16px;
  }
}

@media (max-width: 520px) {
  body.is-authenticated .primary-nav,
  body.is-authenticated .side-actions {
    grid-template-columns: 1fr;
  }
  body.is-authenticated .nav-link {
    justify-content: flex-start;
  }
  body.is-authenticated h1 {
    font-size: 24px;
  }
  body.is-authenticated .topbar {
    gap: 12px;
  }
  body.is-public-home .database-filter-row,
  body.is-authenticated .database-filter-row {
    flex-direction: column;
  }
  body.is-public-home .segment-tabs,
  body.is-public-home .sort-button,
  body.is-authenticated .segment-tabs,
  body.is-authenticated .sort-button {
    width: 100%;
  }
  body.is-public-home .segment-tab,
  body.is-authenticated .segment-tab {
    min-width: 0;
    flex: 1 1 0;
  }
  body.is-public-home .home-brand strong,
  body.is-authenticated .home-brand strong {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  body.is-public-home .header-action span:last-child,
  body.is-authenticated .header-action span:last-child {
    display: none;
  }
}
