:root {
  --bg: #f4f5f7;
  --card: #fff;
  --text: #1f2328;
  --muted: #667085;
  --line: #d0d5dd;
  --primary: #1d6fd8;
  --primary-text: #fff;
  --ok: #1a7f37;
  --error: #c62828;
  --check: #1d6fd8;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "Meiryo", "Yu Gothic UI", system-ui, sans-serif; font-size: 15px; }
header { display: flex; align-items: center; justify-content: space-between; padding: 10px 20px; background: #1f2937; color: #fff; }
header h1 { font-size: 18px; margin: 0; }
header .me { display: flex; gap: 12px; align-items: center; }
header .link { color: #cbd5e1; }
main { max-width: 1200px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px 20px; margin-bottom: 16px; }
.card h2 { font-size: 16px; margin: 0 0 12px; }
.hidden { display: none !important; }
.row { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; margin: 8px 0; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.note { color: var(--muted); font-size: 13px; }
.error { color: var(--error); }
.ok { color: var(--ok); }
button { font: inherit; padding: 7px 16px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: bold; }
button.link { border: none; background: none; color: var(--primary); padding: 4px; }
input, select { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; }
input[type=checkbox] { width: 18px; height: 18px; vertical-align: -3px; }

.drop { border: 2px dashed var(--line); border-radius: 8px; padding: 32px; text-align: center; color: var(--muted); }
.drop.over { border-color: var(--primary); background: #eef4fd; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin: 12px 0; }
.tile { position: relative; border: 3px solid var(--line); border-radius: 6px; overflow: hidden; background: #eee; cursor: pointer; }
.tile.on { border-color: var(--check); }
.tile img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #222; }
.tile .name { font-size: 12px; padding: 3px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: #fff; }
.tile .mark { position: absolute; top: 6px; left: 6px; background: rgba(255,255,255,.9); border-radius: 4px; padding: 1px 4px; }
.tile .badge { position: absolute; top: 6px; right: 6px; font-size: 12px; padding: 1px 6px; border-radius: 4px; background: #333; color: #fff; }
.tile .badge.fail { background: var(--error); }
.tile .badge.mosaic { background: #7c3aed; }
.tile.off img { opacity: .35; }

.bar { height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; }
.bar div { height: 100%; width: 0; background: var(--primary); transition: width .3s; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 10; }
.modal-box { background: #fff; border-radius: 8px; padding: 12px 16px; width: min(1200px, 96vw); max-height: 96vh; display: flex; flex-direction: column; }
.canvas-wrap { flex: 1; display: flex; justify-content: center; background: #222; border-radius: 4px; overflow: hidden; }
#ed-canvas { max-width: 100%; max-height: 74vh; cursor: crosshair; }

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 28px 32px; width: 360px; display: flex; flex-direction: column; gap: 14px; }
.login-box h1 { font-size: 20px; margin: 0 0 6px; text-align: center; }
.login-box label { display: flex; flex-direction: column; gap: 4px; }
