:root {
  color-scheme: light;
  --color-bg: #f7f9fb;
  --color-surface: #fff;
  --color-surface-subtle: #f5f7fa;
  --color-text: #1a1a1c;
  --color-muted: #5d6470;
  --color-border: #d8dfe8;
  --color-border-strong: #949ca8;
  --color-primary: #0017c1;
  --color-primary-hover: #000082;
  --color-primary-subtle: #e8f1fe;
  --color-danger: #c62828;
  --color-focus: #ffca28;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, .10);
  --radius-sm: 4px;
  --radius-md: 8px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-height: 100%;
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  letter-spacing: 0;
}

a {
  color: var(--color-primary);
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
}

a:hover { color: var(--color-primary-hover); }

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

h1, h2, h3 {
  margin: 0;
  line-height: 1.35;
  letter-spacing: 0;
}

h1 { font-size: 2rem; font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 800; }

button, input, select, textarea {
  font: inherit;
  letter-spacing: 0;
}

.container {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: var(--space-6) var(--space-5);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 72px;
  padding: var(--space-3) var(--space-5) var(--space-3) 72px;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}

.brand {
  color: var(--color-text);
  font-size: 1.05rem;
  font-weight: 800;
}

.row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.topbar > .row { padding-left: 0; }

.btn,
button.btn,
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  gap: var(--space-2);
  padding: 9px 16px;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-primary);
  cursor: pointer;
  font-weight: 700;
  line-height: 1.4;
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.btn:hover {
  background: var(--color-primary-subtle);
  color: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.btn.primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.btn.primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  color: #fff;
}

.btn.danger {
  color: var(--color-danger);
  border-color: var(--color-danger);
}

.card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.card .card {
  background: var(--color-surface-subtle);
  box-shadow: none;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: var(--space-5);
  align-items: start;
}

.field label {
  display: block;
  margin-bottom: var(--space-1);
  color: var(--color-text);
  font-weight: 700;
}

.field input,
.field textarea,
.field select,
select,
textarea,
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]) {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  background: #fff;
  color: var(--color-text);
}

.field input:hover,
.field textarea:hover,
.field select:hover,
select:hover,
textarea:hover,
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):hover {
  border-color: var(--color-text);
}

.field textarea,
textarea {
  min-height: 112px;
  resize: vertical;
}

.muted { color: var(--color-muted); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid #b6c7e6;
  background: var(--color-primary-subtle);
  color: #00118f;
  font-size: .8rem;
  font-weight: 700;
}

.list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.list li {
  border-top: 1px solid var(--color-border);
  padding: var(--space-4) 0;
}

.list li:first-child { border-top: 0; }

.videoBox {
  position: relative;
  width: 100%;
  min-height: 420px;
  border-radius: var(--radius-md);
  background: #101828;
  display: grid;
  place-items: center;
  color: #fff;
  overflow: hidden;
}

.videoBox video {
  width: 100%;
  height: 100%;
  min-height: 420px;
  object-fit: cover;
}

.videoBox canvas.annotation-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  touch-action: none;
}

.videoBox.canvas-active canvas.annotation-overlay {
  pointer-events: auto;
  cursor: crosshair;
}

.video-controls {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto;
  gap: var(--space-3);
  align-items: center;
  margin-top: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
}

.video-controls[hidden] { display: none; }

.video-controls input[type="range"] {
  width: 100%;
  min-height: auto;
  padding: 0;
}

.thumb,
.submission-thumb,
.sub-card__thumb {
  width: 160px;
  height: 90px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  display: block;
  background: #eef2f7;
}

.submission-card {
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
}

.submission-thumb {
  width: 120px;
  height: 68px;
  overflow: hidden;
  flex: 0 0 auto;
  border: 1px solid var(--color-border);
}

.submission-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.submission-body {
  flex: 1 1 auto;
  min-width: 0;
}

.sub-card {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-3);
}

.sub-card:hover { box-shadow: var(--shadow-md); }

.sub-card__thumbWrap {
  width: 160px;
  flex: 0 0 160px;
}

.sub-card__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sub-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.sub-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.sub-card__date {
  font-size: .8rem;
  color: var(--color-muted);
  white-space: nowrap;
}

.sub-card__memo {
  font-size: .9rem;
  color: var(--color-text);
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sub-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid #c9d7f2;
  background: var(--color-primary-subtle);
  color: #00118f;
  font-size: .78rem;
  font-weight: 700;
}

.sub-badge--published,
.sub-badge--reviewed {
  border-color: #b8d7c1;
  background: #e6f5ec;
  color: #0b6b35;
}

.sub-badge--rejected {
  border-color: #f0b8b8;
  background: #fdeaea;
  color: var(--color-danger);
}

.sub-badge--commented {
  border-color: #efd09b;
  background: #fff4df;
  color: #8a5700;
}

.sub-card__open { white-space: nowrap; }

#toast {
  display: none;
  position: fixed;
  bottom: var(--space-5);
  left: 50%;
  z-index: 1000001;
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: #fff;
  box-shadow: var(--shadow-md);
  font-weight: 700;
}

#toast[data-kind="error"] {
  border-color: #f0b8b8;
  background: #fff7f7;
  color: var(--color-danger);
}

.sb-toggle {
  border-radius: var(--radius-sm) !important;
  border-color: var(--color-primary) !important;
  color: var(--color-primary);
  box-shadow: var(--shadow-sm) !important;
}

.sb {
  background: #fff !important;
  border-right-color: var(--color-border) !important;
}

.sb .sb-item {
  border-radius: var(--radius-sm) !important;
}

.sb .sb-item.active {
  background: var(--color-primary-subtle) !important;
  color: var(--color-primary) !important;
}

.debug-only { display: none; }
body.debug .debug-only { display: none; }

@media (max-width: 960px) {
  .container { padding: var(--space-5) var(--space-4); }
  .topbar {
    align-items: flex-start;
    padding-right: var(--space-4);
    flex-direction: column;
  }
  .grid-2 { grid-template-columns: 1fr; }
  .sub-card,
  .submission-card { flex-direction: column; }
  .sub-card__thumbWrap,
  .sub-card__thumb,
  .submission-thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }
}
