:root {
  --bg: #ffffff;
  --surface: #f2f2f2;
  --surface-2: #e5e5e5;
  --text: #0f0f0f;
  --muted: #606060;
  --line: #e0e0e0;
  --accent: #e5322d;
  --chip: #0f0f0f;
  --chip-text: #ffffff;
  --overlay: rgba(0, 0, 0, 0.82);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f0f;
    --surface: #222222;
    --surface-2: #333333;
    --text: #f1f1f1;
    --muted: #aaaaaa;
    --line: #2e2e2e;
    --chip: #f1f1f1;
    --chip-text: #0f0f0f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans JP", system-ui, -apple-system, "Hiragino Sans", sans-serif;
  line-height: 1.6;
}
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

.wrap { max-width: 1600px; margin: 0 auto; padding: 0 16px; }

/* ── header ─────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; gap: 12px; height: 56px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; letter-spacing: 0.02em; text-decoration: none; }
.logo-mark {
  width: 28px; height: 20px; border-radius: 6px; background: var(--accent);
  display: grid; place-items: center;
}
.logo-mark::after {
  content: ""; border-left: 7px solid #fff; border-top: 4.5px solid transparent; border-bottom: 4.5px solid transparent; margin-left: 2px;
}

/* ── profile ────────────────────────── */
.profile { display: flex; gap: 20px; align-items: flex-start; padding: 28px 0 8px; }
.profile-avatar {
  flex: none; width: 72px; height: 72px; border-radius: 50%;
  background: var(--surface-2); display: grid; place-items: center;
  font-size: 28px; font-weight: 700; color: var(--muted);
}
.profile h1 { margin: 0; font-size: 26px; line-height: 1.3; }
.profile-bio { margin: 6px 0 0; color: var(--muted); white-space: pre-wrap; max-width: 760px; }
.profile-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.profile-links a {
  font-size: 13px; text-decoration: none; padding: 4px 12px; border-radius: 999px;
  background: var(--surface);
}
.profile-links a:hover { background: var(--surface-2); }

/* ── filters ────────────────────────── */
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 16px 0; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 0; cursor: pointer; padding: 6px 12px; border-radius: 8px;
  background: var(--surface); font-size: 14px; font-weight: 500; white-space: nowrap;
}
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"] { background: var(--chip); color: var(--chip-text); }
.chip-sep { flex: none; width: 1px; background: var(--line); margin: 4px 4px; }

/* ── grid ───────────────────────────── */
.grid {
  display: grid; gap: 32px 16px; padding-bottom: 64px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
@media (max-width: 520px) { .grid { grid-template-columns: 1fr; gap: 24px; } }
.card { cursor: pointer; background: none; border: 0; padding: 0; text-align: left; }
.thumb {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: var(--surface);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s ease; }
.card:hover .thumb img, .card:focus-visible .thumb img { transform: scale(1.03); }
.badge {
  position: absolute; right: 8px; bottom: 8px;
  background: rgba(0,0,0,.78); color: #fff; font-size: 12px; font-weight: 500;
  padding: 2px 6px; border-radius: 4px; display: flex; align-items: center; gap: 4px;
}
.badge.play::before {
  content: ""; border-left: 7px solid #fff; border-top: 4.5px solid transparent; border-bottom: 4.5px solid transparent;
}
.card-title {
  margin: 12px 0 2px; font-size: 16px; font-weight: 600; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { font-size: 13px; color: var(--muted); }
.empty { color: var(--muted); padding: 64px 0; text-align: center; grid-column: 1 / -1; }

/* ── viewer modal ───────────────────── */
.viewer {
  position: fixed; inset: 0; z-index: 50; background: var(--overlay);
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.viewer.open { display: flex; }
.viewer-body { width: min(1200px, 100%); max-height: 100%; overflow-y: auto; }
.viewer-media { background: #000; border-radius: var(--radius); overflow: hidden; }
.viewer-media iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; }
.viewer-media img { margin: 0 auto; max-height: 78vh; width: auto; }
.viewer-info { color: #fff; padding: 14px 4px 0; }
.viewer-info h2 { margin: 0; font-size: 20px; line-height: 1.4; }
.viewer-info .meta { color: #bbb; font-size: 13px; margin-top: 2px; }
.viewer-info p { margin: 8px 0 0; white-space: pre-wrap; color: #ddd; }
.viewer-close {
  position: fixed; top: 12px; right: 12px; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: rgba(255,255,255,.14); color: #fff; font-size: 24px; cursor: pointer;
}
.viewer-close:hover { background: rgba(255,255,255,.26); }

/* ── admin ──────────────────────────── */
.admin main { padding: 24px 0 80px; display: grid; gap: 24px; max-width: 880px; }
.panel { background: var(--surface); border-radius: var(--radius); padding: 20px; }
.panel h2 { margin: 0 0 14px; font-size: 18px; }
.field { display: grid; gap: 4px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 600; }
.field small { color: var(--muted); font-size: 12px; }
.field input[type=text], .field input[type=url], .field input[type=email], .field input[type=password], .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
.field textarea { min-height: 84px; resize: vertical; }
.seg { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 3px; margin-bottom: 16px; }
.seg button { border: 0; background: none; padding: 8px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--chip); color: var(--chip-text); }
.btn {
  border: 0; cursor: pointer; padding: 10px 18px; border-radius: 999px; font-weight: 600;
  background: var(--chip); color: var(--chip-text);
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.danger { background: transparent; color: var(--accent); padding: 6px 10px; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.preview { width: 240px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; background: var(--bg); margin-top: 6px; }
.msg { font-size: 14px; margin-left: 4px; }
.msg.err { color: var(--accent); }
.list { display: grid; gap: 10px; }
.item { display: flex; gap: 12px; align-items: center; background: var(--bg); border-radius: 10px; padding: 8px; }
.item img { width: 120px; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; flex: none; }
.item-text { flex: 1; min-width: 0; }
.item-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { font-size: 12px; color: var(--muted); }
.item-actions { display: flex; gap: 4px; flex: none; }
.icon-btn { border: 0; background: var(--surface); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; }
.icon-btn:disabled { opacity: .3; cursor: default; }
@media (max-width: 600px) {
  .item { flex-wrap: wrap; }
  .item img { width: 96px; }
  .item-actions { width: 100%; justify-content: flex-end; }
  .preview { width: 100%; }
}
.hidden { display: none !important; }

.dropzone { border: 2px dashed var(--line); border-radius: 10px; padding: 12px; background: var(--bg); transition: border-color .15s, background .15s; }
.dropzone.over { border-color: var(--accent); background: var(--surface-2); }
.drop-hint { color: var(--muted); font-size: 13px; }

.item { cursor: grab; }
.item.dragging { opacity: .4; }
.grip { color: var(--muted); letter-spacing: -3px; font-size: 16px; flex: none; user-select: none; padding: 0 2px; }
.item-actions button { cursor: pointer; }

.pin-badge { position: absolute; left: 8px; top: 8px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 4px; }
.btn.pinned { background: var(--accent); color: #fff; }
