:root {
  --wsko-red: #c8102e;
  --wsko-red-dark: #9b0c24;
  --ink: #161616;
  --muted: #6a6a6a;
  --line: #d8d8d8;
  --panel: #ffffff;
  --bg: #ececec;
  --video: #121212;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  --sans: 'Noto Sans', 'Segoe UI', sans-serif;
  --display: 'Noto Serif JP', 'Noto Serif', serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body,
#root {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
}

body[data-screen='login'] {
  overflow: auto;
}

body[data-screen='app'],
body[data-screen='app'] #root {
  overflow: hidden;
  height: 100dvh;
}

button,
input {
  font: inherit;
}

h1,
h2,
p {
  margin: 0;
}

.app-shell {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 12px;
  background: #fff;
  border-bottom: 3px solid var(--wsko-red);
  flex-wrap: nowrap;
  min-height: 56px;
}

.app-header__logo {
  height: 44px;
  width: auto;
  display: block;
}

.app-header__titles h1 {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.app-header__kicker {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.app-header__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  min-width: 0;
}

.session-user {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
}

.logout-btn:hover {
  border-color: var(--wsko-red);
  color: var(--wsko-red);
}

.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 0%, #fff 0%, var(--bg) 62%);
}

.login-card {
  width: min(100%, 380px);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 28px 24px 24px;
  display: grid;
  gap: 12px;
  text-align: center;
}

.login-card__logo {
  width: 88px;
  height: auto;
  margin: 0 auto;
}

.login-card h1 {
  font-family: var(--display);
  font-size: 28px;
}

.login-card > p {
  color: var(--muted);
  font-size: 14px;
}

.login-card label {
  display: grid;
  gap: 6px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.login-card input {
  width: 100%;
  border: 1px solid var(--line);
  padding: 10px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}

.login-card input:focus {
  outline: 2px solid var(--wsko-red);
  border-color: var(--wsko-red);
}

.login-error {
  color: var(--wsko-red);
  font-size: 13px;
  font-weight: 600;
}

.login-card button[type='submit'] {
  border: 0;
  background: var(--wsko-red);
  color: #fff;
  font-weight: 700;
  padding: 12px;
  cursor: pointer;
}

.login-card button[type='submit']:hover {
  background: var(--wsko-red-dark);
}

body[data-screen='login'] .app-shell {
  display: none;
}

body[data-screen='app'] .login-screen {
  display: none;
}

body[data-role='instructor'] .admin-only,
body[data-role='alumno'] .admin-only {
  display: none !important;
}

#results-panel[hidden] {
  display: none !important;
}

body[data-role='instructor'] #results-panel,
body[data-role='alumno'] #results-panel,
body[data-role='admin'] #results-panel {
  display: none !important;
}

body[data-role='alumno'] #evaluators-panel,
body[data-role='alumno'] #student-panel {
  display: none !important;
}

body[data-role='alumno'] #exam-grid {
  grid-template-columns: 3fr 1fr;
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: 'cameras chat';
}

body[data-role='alumno'] .cameras-panel,
body[data-role='alumno'] #chat-panel {
  min-height: 0;
}

.results-panel {
  grid-area: results;
}

.results-body {
  padding: 16px;
  display: grid;
  gap: 16px;
}

.verdict {
  padding: 14px;
  border-left: 4px solid var(--line);
  background: #f7f7f7;
}

.verdict strong {
  display: block;
  font-size: 20px;
  margin-bottom: 4px;
}

.verdict--pass {
  border-left-color: #1f8a4c;
  background: #eef8f1;
}

.verdict--fail {
  border-left-color: var(--wsko-red);
  background: #fff5f6;
}

.verdict--pending {
  border-left-color: #b0b0b0;
}

.results-scores {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.results-scores li {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.results-scores__total {
  font-size: 16px;
}

.instructor-name {
  font-size: 15px;
  font-weight: 600;
}

.exam-tag {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--wsko-red);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.live-pill__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  70% {
    box-shadow: 0 0 0 8px rgba(255, 255, 255, 0);
  }
}

.exam-grid {
  display: grid;
  grid-template-columns: 3fr 1fr;
  grid-template-rows: minmax(0, 1.25fr) minmax(0, 1fr);
  grid-template-areas:
    'cameras chat'
    'evaluators student';
  gap: 8px;
  padding: 8px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--line);
}

.panel__head h2 {
  font-family: var(--display);
  font-size: 16px;
  font-weight: 700;
}

.panel__head p {
  color: var(--muted);
  font-size: 12px;
}

.cameras-panel {
  grid-area: cameras;
  position: relative;
  min-height: 0;
  background: #111;
  overflow: hidden;
}

.cameras-panel__grid {
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  min-height: 0;
  align-items: center;
}

.camera-tile {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  place-items: center;
}

.camera-tile__frame {
  aspect-ratio: 16 / 9;
  width: 100%;
  max-height: 100%;
  background: radial-gradient(circle at 50% 40%, #2a2a2a 0%, var(--video) 62%);
  display: grid;
  place-items: center;
  position: relative;
}

.camera-tile__placeholder {
  color: #bdbdbd;
  text-align: center;
}

.camera-tile__placeholder p {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
}

.camera-tile__label {
  position: absolute;
  left: 8px;
  bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  padding: 4px 8px;
}

.camera-tile__rec {
  position: absolute;
  left: 8px;
  top: 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #fff;
  background: var(--wsko-red);
  padding: 3px 7px;
}

.record-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 12px;
  cursor: pointer;
}

.record-btn:hover {
  background: rgba(0, 0, 0, 0.88);
}

.record-btn__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e11d2e;
}

.record-btn--active {
  background: var(--wsko-red);
}

.record-btn--active .record-btn__dot {
  background: #fff;
  animation: pulse 1.4s infinite;
}

.evaluators-panel {
  grid-area: evaluators;
}

.evaluators-panel .panel__head {
  align-items: center;
}

.score-table {
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr 1fr;
  gap: 1px;
  background: var(--line);
  margin: 10px;
  border: 1px solid var(--line);
  overflow: auto;
  flex: 1;
  min-height: 0;
  align-content: start;
}

.score-table__row {
  display: contents;
}

.score-table__row > * {
  background: #fff;
  padding: 8px;
  min-width: 0;
}

.score-table__row--head > * {
  background: #f6f6f6;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.instructor-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.instructor-cell__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.role-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.role-badge--chief {
  color: var(--wsko-red);
}

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
}

.icon-btn:hover {
  color: var(--wsko-red);
}

.name-input,
.score-input,
.chat-panel__composer input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fafafa;
  padding: 7px 8px;
  outline: none;
}

.name-input:focus,
.score-input:focus,
.chat-panel__composer input:focus {
  border-color: var(--wsko-red);
  background: #fff;
}

.score-cell {
  display: flex;
  align-items: flex-end;
}

.score-input {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  height: 42px;
}

.add-evaluator {
  border: 1px solid var(--wsko-red);
  background: #fff5f6;
  color: var(--wsko-red);
  font-weight: 700;
  padding: 7px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.add-evaluator:hover {
  background: #ffe8eb;
}

.evaluators-limit {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.chat-panel {
  grid-area: chat;
}

.chat-panel__messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-msg {
  padding: 8px 9px;
  background: #f7f7f7;
  border-left: 3px solid var(--line);
}

.chat-msg--system {
  border-left-color: #b0b0b0;
}

.chat-msg--instructor {
  border-left-color: var(--wsko-red);
}

.chat-msg--dojo {
  border-left-color: var(--ink);
}

.chat-msg header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 11px;
}

.chat-msg strong {
  font-size: 12px;
}

.chat-msg time {
  color: var(--muted);
}

.chat-msg p {
  font-size: 13px;
  line-height: 1.35;
}

.chat-panel__composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--line);
}

.chat-panel__composer button {
  border: 0;
  background: var(--wsko-red);
  color: #fff;
  font-weight: 700;
  padding: 0 14px;
  cursor: pointer;
}

.chat-panel__composer button:hover {
  background: var(--wsko-red-dark);
}

.student-panel {
  grid-area: student;
  overflow: auto;
}

.student-card {
  padding: 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.student-card__photo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid var(--wsko-red);
  background: #f0f0f0;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-family: var(--display);
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}

.student-card__photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.student-card dl {
  margin: 0;
  width: 100%;
  display: grid;
  gap: 8px;
  min-width: 0;
}

.student-card dt {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.student-card dd {
  margin: 3px 0 0;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.belt {
  width: 42px;
  height: 8px;
  background: #111;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

@media (max-width: 1280px) {
  .exam-tag {
    display: none;
  }

  .app-header__kicker {
    display: none;
  }
}

@media (max-width: 1100px) {
  .exam-grid {
    grid-template-columns: minmax(0, 2.2fr) minmax(220px, 1fr);
  }

  .student-card {
    grid-template-columns: auto 1fr;
  }

  .student-card__photo {
    width: 52px;
    height: 52px;
    font-size: 16px;
  }
}
