:root {
  --bg: #0b0d10;
  --bg-elev: #14181d;
  --bg-elev-2: #1c2128;
  --border: #262c34;
  --text: #e6e9ee;
  --text-dim: #9aa3ad;
  --accent: #4f8cff;
  --accent-hover: #6aa0ff;
  --toolbar-h: 56px;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

button.btn {
  font: inherit;
  color: var(--text);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
button.btn:hover { background: #232a32; border-color: #2f3742; }
button.btn:active { transform: translateY(1px); }

/* ---------- Viewer ---------- */
.viewer-body {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.toolbar {
  height: var(--toolbar-h);
  flex: 0 0 var(--toolbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}
.toolbar .back {
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
}
.toolbar .back:hover { background: var(--bg-elev-2); }
.toolbar .title {
  flex: 1 1 auto;
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.toolbar .title #playable-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toolbar .title .version {
  color: var(--text-dim);
  font-size: 12px;
  white-space: nowrap;
}
.toolbar .actions { display: flex; gap: 8px; flex: 0 0 auto; }

.stage {
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  padding: 16px;
  background:
    radial-gradient(ellipse at center, #15191f 0%, var(--bg) 70%);
  overflow: hidden;
}

.frame {
  position: relative;
  aspect-ratio: 9 / 16;
  height: min(100%, calc(100vw * 16 / 9));
  width: auto;
  max-width: 100%;
  max-height: 100%;
  background: #000;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  transition: padding .15s ease, border-radius .15s ease;
}
.frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

/* Device-frame mode: rounded "phone" bezel around the iframe */
.frame.device {
  background: #111418;
  border: 10px solid #1a1f25;
  border-radius: 36px;
  padding: 6px;
  box-shadow:
    0 0 0 2px #2a3038 inset,
    0 12px 40px rgba(0,0,0,0.55);
}
.frame.device iframe { border-radius: 24px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(8px);
  background: #2a3038;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Index ---------- */
.index-body { min-height: 100vh; }

.page-header {
  padding: 32px 24px 16px;
  max-width: 1200px;
  margin: 0 auto;
}
.page-header h1 {
  margin: 0 0 4px;
  font-size: 24px;
  letter-spacing: -0.01em;
}
.page-header .subtitle {
  margin: 0 0 16px;
  color: var(--text-dim);
}
.search {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.search input[type=search],
.search select {
  font: inherit;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 220px;
}
.search input[type=search]:focus,
.search select:focus {
  outline: none;
  border-color: var(--accent);
}
.search .count { color: var(--text-dim); font-size: 13px; margin-left: auto; }

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px 48px;
}

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.card:hover {
  transform: translateY(-2px);
  border-color: #313943;
  background: var(--bg-elev-2);
}
.card a {
  display: block;
  color: inherit;
}
.card .thumb {
  aspect-ratio: 9 / 16;
  background:
    repeating-linear-gradient(45deg, #1a1f25 0 10px, #181c22 10px 20px);
  background-size: cover;
  background-position: center;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.card .thumb.no-thumb::after {
  content: "9:16";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 0.1em;
}
.card .meta {
  padding: 12px 14px;
}
.card .meta .name {
  font-weight: 600;
  margin: 0 0 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card .meta .sub {
  color: var(--text-dim);
  font-size: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.card .meta .group {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
}

.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 48px 0;
}

.page-footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 24px;
  border-top: 1px solid var(--border);
}
.page-footer code {
  background: var(--bg-elev);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
