:root {
  --bg: #12131a; --panel: #1c1e28; --panel-2: #252836; --line: #333748;
  --text: #eef0f6; --muted: #9aa0b4; --accent: #8b7bff; --danger: #ff5d6c;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
button { font: inherit; }
[hidden] { display: none !important; }

.top { position: relative; display: flex; align-items: center; justify-content: space-between;
  max-width: 1100px; margin: 0 auto; padding: 14px 16px; }
.brand { font-weight: 800; font-size: 20px; color: var(--text); text-decoration: none; }
.top nav { display: flex; gap: 10px; align-items: center; }
.top nav a { color: var(--muted); text-decoration: none; }
.panel { position: absolute; right: 16px; top: 56px; z-index: 20; width: min(360px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.panel ul { list-style: none; margin: 8px 0 0; padding: 0; max-height: 60vh; overflow: auto; }
.panel li { display: flex; justify-content: space-between; padding: 6px 4px; border-radius: 6px; }
.panel li.current { background: var(--panel-2); }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.muted { color: var(--muted); font-size: 13px; }

main { max-width: 1100px; margin: 0 auto; padding: 0 16px 24px; }
.btn { background: var(--accent); color: #fff; border: none; border-radius: 10px; padding: 10px 16px;
  font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block; }
.btn.alt { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.ghost { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 10px;
  padding: 7px 12px; cursor: pointer; }
.ghost:disabled { opacity: .35; cursor: default; }

.notice, .banner { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-radius: 10px; padding: 9px 14px; margin-bottom: 12px; font-size: 14px; }
.notice { background: rgba(255,93,108,.12); border: 1px solid rgba(255,93,108,.45); }
.banner { background: rgba(139,123,255,.14); border: 1px solid rgba(139,123,255,.45); display: block; }

.editor-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.title { flex: 1; min-width: 200px; background: transparent; border: 1px solid transparent; color: var(--text);
  font-size: 24px; font-weight: 700; padding: 4px 6px; border-radius: 8px; }
.title:hover, .title:focus { border-color: var(--line); outline: none; }
.editor-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hint { color: var(--muted); margin: 6px 0 12px; font-size: 14px; }
body.dropping .board { outline: 2px dashed var(--accent); outline-offset: 6px; border-radius: 12px; }

.tiers { display: flex; flex-direction: column; gap: 4px; }
.tier-row { display: flex; min-height: 80px; background: var(--panel-2); border-radius: 10px; overflow: hidden; }
.tier-head { width: 96px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; padding: 4px; }
.tier-label { width: 100%; background: transparent; border: none; text-align: center; color: #1a1a1a;
  font-size: 22px; font-weight: 900; padding: 2px; border-radius: 6px; }
.tier-label:focus { background: rgba(255,255,255,.4); outline: none; }
.tier-tools { display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.tier-row:hover .tier-tools, .tier-row:focus-within .tier-tools { opacity: 1; }
.tier-color { width: 24px; height: 22px; border: none; padding: 0; background: none; cursor: pointer; }
.tier-remove, .tile-remove { background: rgba(0,0,0,.35); color: #fff; border: none; border-radius: 6px;
  width: 22px; height: 22px; cursor: pointer; line-height: 1; }
.zone { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; align-content: flex-start; transition: background .12s; }
.zone.over { background: rgba(255,255,255,.07); }
#add-tier { margin: 8px 0 0; }
.pool-wrap { margin-top: 14px; }
.pool-label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.pool { min-height: 84px; background: var(--bg); border: 2px dashed var(--line); border-radius: 10px; }

.tile { position: relative; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; background: #2e3246;
  cursor: grab; user-select: none; border: 2px solid transparent; transition: transform .1s, border-color .1s; }
.tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.tile-name { position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; padding: 1px 3px;
  background: rgba(0,0,0,.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-remove { position: absolute; top: 2px; right: 2px; display: none; }
.tile:hover .tile-remove { display: block; }
.tile.dragging { opacity: .35; }

.explore { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }
.foot { max-width: 1100px; margin: 0 auto; padding: 24px 16px 40px; display: flex; gap: 16px; font-size: 13px; }
.foot a { color: var(--muted); }

@media (max-width: 600px) {
  .tier-head { width: 64px; }
  .tier-label { font-size: 18px; }
  .tile { width: 58px; height: 58px; }
}

/* Mobile one-card view */
.cards { max-width: 440px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.c-summary { display: flex; flex-direction: column; gap: 3px; }
.c-row { display: flex; align-items: center; gap: 6px; min-height: 36px; background: var(--panel-2); border-radius: 8px; padding: 3px; }
.c-lab { min-width: 30px; height: 30px; padding: 0 4px; border-radius: 6px; display: grid; place-items: center;
  font-weight: 800; font-size: 13px; flex-shrink: 0; max-width: 70px; overflow: hidden; }
.c-chips { display: flex; flex-wrap: wrap; gap: 3px; }
.c-chip { width: 30px; height: 30px; border-radius: 6px; border: none; padding: 0; overflow: hidden; background: var(--panel); cursor: pointer; }
.c-chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.c-chip.new { animation: pop .35s ease; }
@keyframes pop { 0% { transform: scale(.2); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
.c-stage { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.c-count { text-align: center; color: var(--muted); font-size: 13px; }
.c-card { align-self: center; width: min(280px, 80vw); border-radius: 22px; overflow: hidden; background: var(--panel);
  border: 1px solid var(--line); animation: cardin .2s ease; }
.c-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.c-name { font-weight: 700; font-size: 18px; text-align: center; padding: 8px 8px 0; }
.c-hint { color: var(--muted); font-size: 13px; text-align: center; padding: 4px 8px 10px; }
@keyframes cardin { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }
.c-tiers { display: grid; gap: 8px; }
.c-tier { height: 60px; border: none; border-radius: 14px; font-size: 20px; font-weight: 900; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 4px; }
.c-tier:active { transform: scale(.94); }
.c-sec { display: flex; justify-content: space-between; }
.c-done, .c-empty { text-align: center; padding: 24px 8px; color: var(--muted); }
.c-done h3 { color: var(--text); margin: 6px 0 14px; }
.c-big { font-size: 52px; }
body[data-mode="cards"] .hint { display: none; }

/* Shared page */
.list-title { font-size: 26px; margin: 4px 0; }
.remix-bar { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.remix-bar .btn { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 2px; }
.remix-bar small { font-weight: 400; opacity: .8; font-size: 12px; }
.tier-label-ro { color: #1a1a1a; font-size: 22px; font-weight: 900; text-align: center; word-break: break-word; }
.readonly .tile { cursor: default; }
.readonly .tile:hover { transform: none; border-color: transparent; }
.report-line { margin-top: 18px; font-size: 13px; }
.report-line a { color: var(--muted); }
.gone { text-align: center; padding-top: 40px; }
.readonly-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }

/* Sharing */
.sync-status { font-size: 13px; color: var(--muted); }
.sync-status[data-state="offline"] { color: #ffd23f; }
.sync-status[data-state="readonly"] { color: var(--danger); }
.dialog { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 16px; }
.dialog-box { position: relative; width: min(480px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 20px; }
.dialog-box h2 { margin: 0 0 12px; font-size: 20px; }
.dialog .close { position: absolute; top: 14px; right: 14px; }
.visibility { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 0 0 12px; }
.visibility label { display: block; padding: 4px 0; cursor: pointer; }
.visibility small { color: var(--muted); margin-left: 4px; }
.link-row { display: flex; gap: 8px; }
.link-row input { flex: 1; min-width: 0; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px; }
.danger { color: var(--danger); border-color: rgba(255,93,108,.4); }

/* Discovery */
.explore h2, .family h2 { font-size: 20px; margin: 0 0 12px; }
.explore-bar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs { display: flex; gap: 6px; }
.tab { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 7px 14px; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.search { display: flex; gap: 6px; flex: 1; max-width: 360px; min-width: 200px; }
.search input { flex: 1; min-width: 0; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; color: var(--text); text-decoration: none; padding-bottom: 10px; }
.card img { width: 100%; aspect-ratio: 1200 / 630; object-fit: cover; background: var(--panel-2); }
.card-title { font-weight: 700; padding: 0 10px; }
.card .muted { padding: 0 10px; }
.card:hover { border-color: var(--accent); }
.more { margin-top: 12px; }
.family { margin-top: 24px; }
.legal { max-width: 720px; } .legal h2 { font-size: 17px; margin-top: 22px; } .legal p { color: #c9cddb; }
.tile-report { position: absolute; top: 2px; right: 2px; display: none; background: rgba(0,0,0,.55); color: #fff;
  border: none; border-radius: 6px; width: 22px; height: 22px; cursor: pointer; font-size: 12px; }
.tile:hover .tile-report, .tile:focus-within .tile-report { display: block; }
@media (pointer: coarse) { .tile-report { display: block; opacity: .7; } }
#report-details { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 10px; font: inherit; }
.login { display: flex; gap: 8px; max-width: 420px; margin-bottom: 14px; }
.login input { flex: 1; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.report { display: flex; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 10px; }
.report img { width: 160px; aspect-ratio: 1200 / 630; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.report .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
