:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f1f4f8;
  --border: #d8dee8;
  --text: #172033;
  --muted: #667085;
  --primary: #2457d6;
  --primary-dark: #1c43aa;
  --success: #147a4b;
  --error: #b42318;
  --focus: #8bb4ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Noto Sans KR", sans-serif;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 28px;
  background: #101828;
  color: #fff;
}

.topbar h1,
.topbar p {
  margin: 0;
}

.topbar h1 {
  font-size: 22px;
}

.topbar p {
  margin-top: 4px;
  color: #cbd5e1;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.tabButton {
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 6px;
  padding: 9px 12px;
  cursor: pointer;
}

.tabButton.active {
  background: #fff;
  color: #101828;
}

.shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px;
}

.loginScreen {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  min-height: calc(100vh - 40px);
  max-width: 640px;
  margin: 0 auto;
}

.loginHero {
  padding: 0 4px;
  text-align: center;
}

.loginHero h1,
.loginHero p {
  margin: 0;
}

.loginHero h1 {
  max-width: 560px;
  font-size: 36px;
  line-height: 1.18;
}

.loginHero p:not(.eyebrow) {
  max-width: 560px;
  margin-top: 10px;
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 8px !important;
  color: var(--primary);
  font-weight: 700;
}

.loginCards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
}

.loginCards.singleLogin {
  grid-template-columns: minmax(320px, 480px);
  justify-content: center;
}

.loginCard {
  display: grid;
  align-content: start;
  min-height: 0;
  padding: 24px;
}

.loginCard h2,
.loginCard p {
  margin-top: 0;
}

.hidden {
  display: none !important;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.compactPanel,
.loginPanel,
.listPanel,
.editorPanel {
  padding: 18px;
}

.compactPanel h2,
.compactPanel h3,
.compactPanel p,
.loginPanel h2,
.loginPanel p,
.panelHeader h2 {
  margin-top: 0;
}

.gatePanel {
  max-width: 640px;
  margin: 0 auto 16px;
  border-color: var(--primary);
}

.mutedText,
.metaText,
.promptText,
.message,
.hint,
.empty,
.emptyEditor {
  color: var(--muted);
}

.panelHeader,
.editorHeader,
.submitBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pmGrid,
.reviewGrid {
  display: grid;
  grid-template-columns: minmax(360px, 1.1fr) minmax(320px, 0.9fr);
  gap: 16px;
}

.loginPanel {
  display: grid;
  grid-template-columns: 1fr minmax(320px, 520px);
  gap: 16px;
  align-items: end;
  margin-bottom: 16px;
}

.loginRow,
.buttonRow,
.filters {
  display: flex;
  gap: 8px;
}

.filters {
  margin: 14px 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

.primaryButton,
.secondaryButton,
.ghostButton,
.iconButton,
.dangerButton {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
}

.primaryButton {
  background: var(--primary);
  color: #fff;
}

.primaryButton:hover {
  background: var(--primary-dark);
}

.secondaryButton {
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--border);
}

.dangerButton {
  background: var(--error);
  color: #fff;
}

.fileDrop {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 180px;
  margin: 14px 0;
  border: 2px dashed var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  text-align: center;
  cursor: pointer;
}

.fileDrop:hover {
  border-color: var(--primary);
}

.fileDrop input {
  display: none;
}

.fileDropIcon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 24px;
}

.ruleList {
  margin: 12px 0 0;
  padding-left: 20px;
}

.ruleList li {
  margin: 8px 0;
}

.workbench {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  min-height: 680px;
}

.workbench.listCollapsed {
  grid-template-columns: 96px 1fr;
}

.workbench.listCollapsed .listPanel {
  padding: 12px;
}

.workbench.listCollapsed .listPanel h2,
.workbench.listCollapsed .countBadge,
.workbench.listCollapsed .listBody {
  display: none;
}

.workbench.listCollapsed .panelHeader {
  justify-content: center;
}

.countBadge,
.statusBadge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 13px;
  background: var(--surface-soft);
  color: var(--muted);
}

.statusBadge[data-status="작업 완료"],
.statusBadge[data-status="검수 완료"] {
  color: var(--success);
}

.statusBadge[data-status="반려됨"] {
  color: var(--error);
}

.itemList {
  display: grid;
  gap: 8px;
}

.itemButton {
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
}

.itemButton.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(36, 87, 214, 0.12);
}

.itemButton strong,
.itemButton span {
  display: block;
}

.itemButton span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.emptyEditor {
  display: grid;
  place-content: center;
  min-height: 540px;
  text-align: center;
}

.editorLayout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, var(--label-sidebar-width, 420px));
  gap: 16px;
  align-items: start;
}

.editorLayout.guideOpen {
  grid-template-columns: minmax(0, 1fr) minmax(320px, var(--label-sidebar-width, 400px)) minmax(300px, 360px);
}

.questionPane,
.labelingSidebar {
  min-width: 0;
}

.message {
  min-height: 22px;
  margin: 8px 0 0;
}

.message.error {
  color: var(--error);
}

.message.success {
  color: var(--success);
}

.stickyQuestion {
  position: sticky;
  top: 0;
  z-index: 4;
  padding-bottom: 12px;
  background: var(--surface);
}

.labelingSidebar {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 0 14px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.sidebarResizeHandle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -6px;
  width: 12px;
  cursor: col-resize;
}

.sidebarResizeHandle::after {
  content: "";
  position: absolute;
  top: 45%;
  left: 5px;
  width: 2px;
  height: 44px;
  border-radius: 999px;
  background: #c4ccd8;
}

.sidebarResizeHandle:hover::after,
.resizingSidebar .sidebarResizeHandle::after {
  background: var(--primary);
}

.resizingSidebar {
  cursor: col-resize;
  user-select: none;
}

.labelingSidebarHeader {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 14px 0 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.labelingSidebarHeader h3,
.labelingSidebarHeader p {
  margin: 0;
}

.labelingSidebarHeader h3 {
  font-size: 16px;
}

.labelingSidebarHeader p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.questionBox,
.formSection {
  margin-top: 16px;
  padding: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.passageText {
  white-space: pre-wrap;
}

.questionText {
  font-weight: 700;
}

.choiceList {
  margin: 12px 0 0;
  padding-left: 24px;
}

.choiceList li {
  margin: 6px 0;
}

.tierToolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 0;
  padding: 12px 0 10px;
  background: var(--surface);
}

.tierTabs {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.tierTabButton {
  border: 0;
  border-radius: 6px;
  padding: 7px 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}

.tierTabButton.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(23, 32, 51, 0.06);
}

.tier2Search {
  margin: 8px 0 12px;
}

.guideSidebar {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.guideSidebarHeader {
  position: sticky;
  top: -14px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.guideSidebarHeader h3 {
  margin: 0;
}

.guideContent {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.guideSection {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
}

.guideSection h4 {
  margin: 0 0 8px;
}

.guideTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.guideTable th,
.guideTable td {
  border-top: 1px solid var(--border);
  padding: 7px;
  text-align: left;
  vertical-align: top;
}

.fieldGrid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
}

.field > span {
  font-weight: 700;
}

.optionField {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.optionFieldHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.optionFieldHeader strong {
  font-size: 13px;
}

.optionFieldHeader span {
  color: var(--muted);
  font-size: 11px;
}

.optionGroup {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.optionPill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 4px 8px;
  background: #fff;
  cursor: pointer;
  color: var(--text);
  font-size: 12px;
  line-height: 1.25;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.optionPill:hover {
  border-color: #9aa8bd;
  background: #f8fafc;
}

.optionPill:has(input:checked) {
  border-color: var(--primary);
  background: #eef4ff;
}

.optionPill strong {
  font-size: 12px;
}

.optionPill span {
  color: var(--muted);
}

.optionPill input {
  width: auto;
  margin: 0;
  accent-color: var(--primary);
}

.scaleField {
  grid-column: 1 / -1;
}

.scaleGroup {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
  gap: 8px;
  padding: 18px 0 2px;
}

.scaleGroup::before {
  content: "";
  position: absolute;
  top: 34px;
  left: 42px;
  right: 42px;
  height: 2px;
  background: var(--border);
}

.scaleOption {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  min-height: 82px;
  padding: 4px;
  text-align: center;
  cursor: pointer;
}

.scaleOption input {
  position: relative;
  z-index: 1;
  width: 18px;
  height: 18px;
  margin: 3px 0 2px;
  accent-color: var(--primary);
}

.scaleOption strong {
  font-size: 14px;
}

.scaleOption span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.scaleEdgeLabels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.submitBar {
  position: sticky;
  bottom: 0;
  margin-top: 18px;
  padding: 12px 0 0;
  background: var(--surface);
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .tabs {
    justify-content: flex-start;
  }

  .loginPanel,
  .loginCards,
  .workbench,
  .workbench.listCollapsed,
  .fieldGrid,
  .editorLayout,
  .editorLayout.guideOpen,
  .pmGrid,
  .reviewGrid {
    grid-template-columns: 1fr;
  }

  .stickyQuestion,
  .labelingSidebar,
  .guideSidebar {
    position: static;
    max-height: none;
  }

  .sidebarResizeHandle {
    display: none;
  }

  .workbench.listCollapsed .listPanel h2,
  .workbench.listCollapsed .countBadge,
  .workbench.listCollapsed .listBody {
    display: block;
  }

  .loginRow,
  .buttonRow,
  .filters {
    flex-direction: column;
  }

  .shell {
    padding: 12px;
  }
}
