:root {
  color-scheme: light;
  --ink: #1b2430;
  --muted: #667085;
  --line: #d8dde3;
  --paper: #ffffff;
  --canvas: #f4f5f7;
  --blue: #1769aa;
  --blue-soft: #eaf3fb;
  --green: #138a55;
  --green-soft: #e8f6ef;
  --red: #c9362b;
  --red-soft: #fdeceb;
  --amber: #a46508;
  --amber-soft: #fff4d8;
  --shadow: 0 18px 45px rgb(28 39 51 / 10%);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }

:focus-visible {
  outline: 3px solid #2684d8;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  background: var(--ink);
  color: white;
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.gate {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}
.gate__card {
  width: min(460px, 100%);
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: var(--shadow);
  text-align: center;
}
.gate__card h1 { margin: 6px 0 16px; font-size: 2rem; }
.gate__card p:not(.eyebrow) { line-height: 1.7; color: var(--muted); }

.eyebrow {
  margin: 0;
  color: var(--blue);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .14em;
}
.eyebrow--red { color: var(--red); }

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 76px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 94%);
  backdrop-filter: blur(12px);
}
.app-header__title { display: flex; align-items: center; gap: 12px; }
.app-header h1 { margin: 2px 0 0; font-size: 1.1rem; }
.logo-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 900;
}
.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  min-width: 0;
}
.user-profile {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  white-space: nowrap;
}
.user-profile small { font-size: .72rem; }
.user-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--canvas);
  object-fit: cover;
}
.user-name {
  overflow: hidden;
  max-width: 160px;
  color: var(--ink);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header-link {
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 700;
  white-space: nowrap;
}

.decision-bar {
  position: sticky;
  z-index: 18;
  top: 76px;
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 210px));
  justify-content: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgb(244 245 247 / 95%);
  backdrop-filter: blur(12px);
}
.decision {
  min-height: 50px;
  border: 2px solid currentColor;
  border-radius: 9px;
  font-weight: 850;
  letter-spacing: .03em;
  white-space: nowrap;
}
.decision--ok { background: var(--green); color: white; border-color: var(--green); }
.decision--ng { background: var(--red); color: white; border-color: var(--red); }
.decision--hold { background: var(--amber-soft); color: var(--amber); border-color: #ddb866; }
kbd {
  margin-left: 8px;
  padding: 2px 6px;
  border: 1px solid currentColor;
  border-radius: 4px;
  font: 700 .7rem/1 sans-serif;
  opacity: .8;
}

.review-main {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 80px;
}
.status-message {
  min-height: 24px;
  margin-bottom: 8px;
  color: var(--muted);
  text-align: center;
}
.review-instructions {
  max-width: 80ch;
  margin: 0 auto 20px;
  color: var(--muted);
  font-size: .94rem;
  line-height: 1.75;
}
.level-picker {
  max-width: 80ch;
  margin: 0 auto 20px;
  padding: 0;
  border: 0;
}
.level-picker legend {
  margin-bottom: 8px;
  font-weight: 700;
}
.level-picker__options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.level-option {
  position: relative;
}
.level-option input {
  position: absolute;
  opacity: 0;
}
.level-option span {
  display: inline-block;
  min-width: 76px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  text-align: center;
}
.level-option input:checked + span {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 700;
}
.level-option input:focus-visible + span {
  outline: 3px solid #2684d8;
  outline-offset: 3px;
}
.level-picker__hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: .88rem;
}
.question-meta__start {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.level-badge {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: .85rem;
  font-weight: 700;
  white-space: nowrap;
}
.question-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: var(--shadow);
  touch-action: pan-y;
}
.question-card__inner {
  position: relative;
  z-index: 2;
  padding: clamp(24px, 4vw, 54px);
  background: var(--paper);
  transition: transform 160ms ease;
  will-change: transform;
}
.question-card.is-dragging .question-card__inner { transition: none; }
.swipe-cue {
  position: absolute;
  inset-block: 0;
  z-index: 1;
  display: grid;
  width: 36%;
  place-items: center;
  color: white;
  font-size: 2rem;
  font-weight: 900;
}
.swipe-cue--ok { left: 0; background: var(--green); }
.swipe-cue--ng { right: 0; background: var(--red); }

.question-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  width: max-content;
  min-height: 34px;
  padding: 6px 11px;
  border: 1px solid #b7c0ca;
  border-radius: 999px;
  background: white;
  color: #3b4654;
  font-size: .86rem;
  font-weight: 700;
}
button.chip[aria-pressed="true"], .chip--selected {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}
.tag-edit-button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--blue);
  font-weight: 750;
}
.warnings { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0; }
.warning {
  display: inline-flex;
  width: max-content;
  padding: 5px 9px;
  border-radius: 5px;
  background: var(--amber-soft);
  color: #7c4c05;
  font-size: .8rem;
  font-weight: 750;
}

.section-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .08em;
}
.question-section h2 {
  max-width: 900px;
  margin: 0;
  font-size: clamp(1.35rem, 2.1vw, 2rem);
  line-height: 1.65;
}
.question-image {
  display: block;
  width: min(720px, 100%);
  max-height: 420px;
  margin-top: 22px;
  border-radius: 8px;
  object-fit: contain;
}
.answer-section, .explanation-section, .source-section {
  margin-top: 34px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}
.answer-section h3, .explanation-section h3, .source-section h3 {
  margin: 0 0 14px;
  font-size: .9rem;
}
.answer-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; counter-reset: answer; }
.answer-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  counter-increment: answer;
}
.answer-row::before { content: counter(answer, upper-alpha); color: var(--muted); font-weight: 800; }
.answer-row--correct { border-color: #79b995; background: var(--green-soft); }
.answer-mark { color: var(--green); font-size: .8rem; font-weight: 850; }
.explanation-section p, .source-section p { margin: 0; line-height: 1.85; }
.source-section p { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.source-section__content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.source-open-button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 9px 14px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 800;
}
.swipe-help { margin: 28px 0 0; color: var(--muted); font-size: .78rem; text-align: center; }

.empty-state {
  padding: 72px 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  text-align: center;
}
.empty-state h2 { margin-top: 0; }
.empty-state p { color: var(--muted); }

.button {
  min-height: 48px;
  padding: 10px 18px;
  border: 1px solid #aeb7c2;
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-weight: 800;
}
.button--login, .button--primary { border-color: var(--blue); background: var(--blue); color: white; }
.button--danger { border-color: var(--red); background: var(--red); color: white; }
.button--small { min-height: 44px; }

.drawer {
  width: min(480px, 100%);
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
}
.drawer::backdrop { background: rgb(18 25 33 / 44%); }
.drawer__panel {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  margin: 0;
  padding: 28px;
  background: white;
  box-shadow: -20px 0 45px rgb(10 20 30 / 15%);
}
.drawer__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.drawer__header h2 { margin: 4px 0 0; }
.drawer__hint { color: var(--muted); line-height: 1.6; }
.icon-button {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--canvas);
  font-size: 1.5rem;
}
.chips--editor { margin: 10px 0 26px; }
.new-tag, .memo { display: grid; gap: 8px; margin-top: 14px; font-weight: 750; }
.new-tag__row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
input, textarea {
  width: 100%;
  border: 1px solid #9da8b5;
  border-radius: 7px;
  background: white;
  color: var(--ink);
}
input { min-height: 46px; padding: 9px 12px; }
textarea { padding: 12px; line-height: 1.6; resize: vertical; }
.memo textarea { font-weight: normal; }
.drawer__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: auto;
  padding-top: 28px;
  color: var(--muted);
  font-size: .8rem;
}
.drawer__footer--buttons { justify-content: flex-end; }
.source-sheet {
  width: min(1120px, calc(100% - 32px));
  max-width: none;
  height: min(82vh, 760px);
  max-height: none;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 16px 16px 0 0;
  background: transparent;
}
.source-sheet::backdrop { background: rgb(18 25 33 / 52%); }
.source-sheet__panel {
  display: flex;
  height: 100%;
  flex-direction: column;
  padding: 22px 24px;
  border-radius: 16px 16px 0 0;
  background: white;
  box-shadow: 0 -20px 45px rgb(10 20 30 / 15%);
}
.source-sheet__domain {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: .82rem;
}
.source-sheet__hint {
  margin: 14px 0;
  color: var(--muted);
  font-size: .84rem;
}
.source-frame {
  width: 100%;
  min-height: 0;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--canvas);
}
.source-sheet__footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 14px;
}
.source-external-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.reason-list {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin: 12px 0 18px;
  padding: 0;
  border: 0;
}
.reason-option input { position: absolute; opacity: 0; pointer-events: none; }
.reason-option span {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid #c5cbd2;
  border-radius: 999px;
  font-weight: normal;
}
.reason-option input:checked + span { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.reason-option input:focus-visible + span { outline: 3px solid #2684d8; outline-offset: 2px; }
.form-error { min-height: 24px; color: var(--red); font-weight: 750; }

.toast {
  position: fixed;
  z-index: 80;
  right: 24px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: calc(100% - 48px);
  padding: 14px 16px;
  border-radius: 9px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
}
.toast button { min-height: 40px; border: 0; background: transparent; color: #8ed1ff; font-weight: 850; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 760px) {
  .app-header { grid-template-columns: 1fr auto; min-height: 68px; padding: 10px 14px; }
  .app-header__title .eyebrow { display: none; }
  .app-header h1 { font-size: 1rem; }
  .logo-mark { width: 38px; height: 38px; }
  .header-actions #logout-button { display: none; }
  .header-actions { gap: 6px; }
  .header-link { min-height: 40px; padding: 6px 4px; font-size: .8rem; }
  .user-profile { max-width: 120px; gap: 4px; }
  .user-profile small { font-size: .65rem; }
  .user-icon { width: 28px; height: 28px; }
  .user-name { max-width: 72px; font-size: .82rem; }
  .decision-bar { top: 68px; grid-template-columns: repeat(3, 1fr); gap: 7px; padding: 8px; }
  .decision { min-width: 0; min-height: 48px; padding: 6px; }
  .decision kbd { display: none; }
  .review-main { width: 100%; padding: 12px 10px 70px; }
  .question-card { border-radius: 10px; }
  .question-card__inner { padding: 22px 18px 30px; }
  .question-meta { display: grid; }
  .tag-edit-button { justify-self: start; }
  .question-section h2 { font-size: 1.25rem; line-height: 1.7; }
  .source-section__content { align-items: flex-start; flex-direction: column; }
  .drawer { width: 100%; height: min(82vh, 720px); margin: auto 0 0; }
  .drawer__panel { min-height: 100%; padding: 22px 18px; box-shadow: 0 -20px 45px rgb(10 20 30 / 15%); }
  .drawer__footer { position: sticky; bottom: 0; margin-inline: -18px; padding: 14px 18px; background: white; }
  .source-sheet { width: 100%; height: min(88vh, 760px); }
  .source-sheet__panel { padding: 18px 14px; }
  .source-sheet__footer { flex-wrap: wrap; }
  .toast { right: 12px; bottom: 12px; max-width: calc(100% - 24px); }
}

@media (max-width: 480px) {
  .app-header { grid-template-columns: auto 1fr; gap: 10px; }
  .app-header__title > div { display: none; }
  .app-header__title { gap: 0; }
  .header-actions { justify-self: end; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}
