/* ─────────── ARGOS design tokens ─────────── */
:root {
  /* neutral */
  --text-primary: #1D2023;
  --text-secondary: #4D535A;
  --text-tertiary: #697079;
  --text-muted: #9AA4B1;
  --surface: #FFFFFF;
  --surface-alt: #F2F4F5;
  --border: #E6E8EB;
  --border-strong: #CACFD6;

  /* brand */
  --brand: #FF5E00;
  --brand-strong: #BC3500;
  --brand-soft: #FF8842;
  --brand-bg: #FFF2DF;
  --brand-bg-2: #FBEED8;
  --brand-deep: #7A4A0F;

  /* status */
  --success: #39B159;
  --success-bg: #E6F5EA;
  --danger: #EB5147;
  --danger-bg: #F8DAD8;
  --info: #1B3A6B;
  --info-bg: #EAF2FB;

  /* radii / shadow */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --shadow-card: 0 1px 2px rgba(29, 32, 35, .04);
  --shadow-pop: 0 8px 24px rgba(29, 32, 35, .08);
}

/* ─────────── reset ─────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Arial", "Apple SD Gothic Neo", "맑은 고딕", sans-serif;
  background: var(--surface);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }
input { font: inherit; }

.hidden { display: none !important; }
.muted { color: var(--text-tertiary); }
.small { font-size: 12px; }
.center { text-align: center; }

/* ─────────── login ─────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-alt);
  padding: 32px 16px;
}
.login-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  width: 100%;
}
.login-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.01em;
  margin: 0;
}
.login-title::after {
  content: "";
  display: block;
  width: 32px;
  height: 3px;
  background: var(--brand);
  margin: 10px auto 0;
  border-radius: 2px;
}
.login-cards {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 36px 32px;
  width: 340px;
  text-align: center;
  box-shadow: var(--shadow-pop);
}
.login-card-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text-primary);
}
.login-card-title-admin { color: var(--brand-strong); }
.login-card-title-user  { color: var(--text-primary); }
@media (max-width: 760px) {
  .login-card { width: 100%; max-width: 360px; }
}
.login-buttons { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
.login-fields { display: flex; flex-direction: column; gap: 12px; margin-top: 28px; text-align: left; }
.login-field { display: flex; flex-direction: column; gap: 6px; }
.login-field input {
  padding: 11px 13px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.login-field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 94, 0, .15);
}
.login-submit { width: 100%; margin-top: 18px; padding: 12px; }
.login-error { color: var(--danger); margin-top: 12px; min-height: 18px; font-size: 13px; }

/* ─────────── buttons ─────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-weight: 700;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover { background: var(--surface-alt); border-color: var(--text-tertiary); }
.btn.small { padding: 6px 12px; font-size: 13px; font-weight: 400; }
.btn { gap: 6px; }
.btn .icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.btn:not(.small) .icon { width: 16px; height: 16px; }

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-primary:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  color: #fff;
}
.btn-primary:disabled {
  background: var(--surface-alt) !important;
  border-color: var(--border) !important;
  color: var(--text-muted) !important;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface-alt);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
  background: var(--surface);
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger-bg); }

/* ─────────── layout ─────────── */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
  overflow: hidden;
  background: var(--surface);
}

/* sidebar */
.sidebar {
  background: var(--surface-alt);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
}
.logo-btn {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.01em;
  position: relative;
  padding-left: 12px;
}
.logo-btn::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--brand);
  border-radius: 2px;
}
.logo-btn:hover { color: var(--brand-strong); }

.logout-btn {
  color: var(--text-tertiary);
  font-size: 16px;
  padding: 4px 10px;
  border-radius: var(--r-sm);
}
.logout-btn:hover { color: var(--danger); background: var(--surface); }

.sidebar-folders {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.folder-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  cursor: pointer;
  margin-bottom: 3px;
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.folder-item:hover {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-primary);
}
.folder-item.active {
  background: var(--brand-bg);
  color: var(--brand-strong);
  border-color: transparent;
  font-weight: 700;
}
.folder-item .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  line-height: 1.25;
}
.folder-item .counts {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.folder-item .count {
  font-size: 10.5px;
  line-height: 1.3;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-tertiary);
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}
.folder-item .count.count-done {
  background: #2F9B4D;
  border-color: #2F9B4D;
  color: #fff;
}
/* '전체' 칩은 항상 주황 솔리드 — active 여부와 무관 */
.folder-item .count.count-total {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
/* active 상태에서도 완료 칩은 그대로 녹색을 유지 */
.folder-item.active .count.count-done {
  background: #2F9B4D;
  border-color: #2F9B4D;
  color: #fff;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.settings-btn {
  text-align: left;
  padding: 8px 12px;
  border-radius: var(--r-md);
  color: var(--text-secondary);
}
.settings-btn:hover { background: var(--surface); color: var(--text-primary); }
.me-info { color: var(--text-muted); font-size: 11px; }

/* main */
.main {
  height: 100vh;
  overflow: hidden;
  position: relative;
  background: var(--surface);
}
.pane { height: 100%; width: 100%; }
.placeholder {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  padding: 0 72px;
  text-align: center;
}
.placeholder h2 {
  font-size: 42px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  letter-spacing: -.015em;
}
.placeholder h2::after {
  content: "";
  display: block;
  width: 36px;
  height: 3px;
  background: var(--brand);
  margin: 16px auto 20px;
  border-radius: 2px;
}
.placeholder p { font-size: 16px; color: var(--text-secondary); }

/* ─────────── label pane ─────────── */
.label-pane {
  display: grid;
  grid-template-columns: 1fr 360px;
  height: 100%;
}
.image-pane {
  position: relative;
  background: var(--surface-alt);
  overflow: hidden;
}
.image-stage {
  position: absolute;
  inset: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  /* 변환 중심 = 무대 중앙 */
  touch-action: none;
}
.image-pane img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: center center;
  transition: transform .08s ease-out;
  will-change: transform;
}
/* 도구 모드별 커서 */
.image-stage.tool-zoom        { cursor: zoom-in; }
.image-stage.tool-zoom.alt    { cursor: zoom-out; }
.image-stage.tool-pan         { cursor: grab; }
.image-stage.tool-pan.dragging { cursor: grabbing; }
/* 변환 중에는 transition 끄기(드래그/휠 부드러움) */
.image-stage.transforming img { transition: none; }

/* 우측 하단 도구 팔레트 */
.image-tools {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  backdrop-filter: blur(4px);
  z-index: 5;
}
.image-zoom-badge {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 0 8px 0 4px;
  min-width: 52px;
  text-align: center;
  border-right: 1px solid var(--border);
}
.image-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.image-tool-btn:hover { background: var(--surface-alt); color: var(--text-primary); }
.image-tool-btn.active {
  background: var(--brand-bg);
  border-color: var(--brand);
  color: var(--brand-strong);
}
.image-tool-btn .icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.label-side {
  border-left: 1px solid var(--border);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--surface);
  overflow-y: auto;
}
.label-toolbar { display: flex; gap: 6px; }
.label-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  background: var(--surface-alt);
  border-radius: var(--r-md);
}
.filename {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-all;
  font-weight: 700;
}
.diseases-group { display: flex; flex-direction: column; gap: 10px; }
.diseases-group > label.muted {
  font-size: 12px;
  color: var(--text-tertiary);
  letter-spacing: .02em;
  text-transform: uppercase;
  font-weight: 700;
}
.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--text-primary);
  transition: all .12s ease;
}
.checkbox-grid label:hover { border-color: var(--brand-soft); background: var(--brand-bg-2); }
.checkbox-grid label:has(input:checked) {
  background: var(--brand-bg);
  border-color: var(--brand);
  color: var(--brand-strong);
  font-weight: 700;
}
.checkbox-grid input { cursor: pointer; accent-color: var(--brand); }

/* 체크박스 + 제출 + 힌트를 하나의 카드로 묶어 마우스 이동 거리를 최소화 */
.action-group {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}
.action-group .checkbox-grid label { background: var(--surface); }
.submit-btn { padding: 13px; font-size: 15px; }

/* ─────────── list pane ─────────── */
.list-pane {
  display: flex;
  flex-direction: column;
  padding: 18px 24px;
  height: 100%;
  gap: 10px;
}
.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.list-header h3 {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.005em;
}
.table-wrap {
  flex: 1;
  overflow: auto;
  background: var(--surface);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}
.list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  line-height: 1.35;
}
.list-table thead {
  position: sticky;
  top: 0;
  background: var(--surface-alt);
  z-index: 1;
}
.list-table th {
  text-align: left;
  padding: 7px 10px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  color: var(--text-secondary);
  font-size: 11px;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.list-table th:hover { color: var(--text-primary); }
.list-table th .arrow { color: var(--brand); margin-left: 4px; }
.list-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
.list-table tbody tr { cursor: pointer; transition: background .1s ease; }
.list-table tbody tr:hover { background: var(--brand-bg-2); }
.list-table tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  background: var(--surface-alt);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  margin-right: 3px;
}
.badge.ok {
  background: var(--success-bg);
  color: var(--success);
  border-color: transparent;
}
.badge.warn {
  background: var(--brand-bg);
  color: var(--brand-strong);
  border-color: transparent;
}

.list-footer {
  margin-top: 2px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

/* ─────────── settings ─────────── */
.settings-pane {
  display: flex;
  flex-direction: column;
  padding: 28px 32px;
  height: 100%;
  overflow: hidden;
  gap: 14px;
  position: relative;
  transition: background .15s ease, box-shadow .15s ease;
}
/* DnD 상태: 윈도우에서 zip 드래그가 시작되면 버튼이 강조됨 */
#zip-upload-btn.drop-ready {
  outline: 2px dashed var(--brand-soft);
  outline-offset: 3px;
}
#zip-upload-btn.drop-hover,
.settings-pane.drop-hover {
  background: var(--brand-bg);
  box-shadow: inset 0 0 0 2px var(--brand);
}
#zip-upload-btn.drop-hover {
  background: var(--brand-strong);
  box-shadow: 0 0 0 3px rgba(255, 94, 0, .25);
}
.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.settings-header h3 {
  font-size: 23px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.005em;
}

.upload-status {
  background: var(--info-bg);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--info);
}
.upload-status.error {
  background: var(--danger-bg);
  border-color: transparent;
  color: var(--danger);
}
.upload-status .progress-bar {
  height: 6px;
  background: rgba(255, 255, 255, .6);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}
.upload-status .progress-bar > div {
  height: 100%;
  background: var(--brand);
  transition: width .3s ease;
}

.settings-list {
  flex: 1;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
}
.settings-folder-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.settings-folder-row:last-child { border-bottom: none; }
.settings-folder-row:hover { background: var(--surface-alt); }
.settings-folder-row .meta { color: var(--text-tertiary); font-size: 12px; margin-left: 12px; }
.settings-folder-info { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.settings-folder-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 12px;
}

/* ─────────── omr modal ─────────── */
.omr-btn {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  background: var(--brand-bg);
  border-color: var(--brand-soft);
  color: var(--brand-strong);
}
.omr-btn:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.omr-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.omr-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(29, 32, 35, .55);
}
.omr-dialog {
  position: relative;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  width: min(96vw, 1080px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.omr-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}
.omr-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}
.omr-meta {
  color: var(--text-tertiary);
  font-size: 13px;
  margin-right: auto;
}
.omr-body {
  flex: 1;
  overflow: auto;
  padding: 16px 22px 24px;
}
/* OMR 카드: 시험 답안지 느낌의 다열 그리드 */
.omr-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
}
.omr-col {
  flex: 0 0 auto;
  border: 1px solid #BFD6E2;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface);
  min-width: 230px;
}
.omr-col-head {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  background: #E2EFF5;
  color: #2F6E89;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 6px 8px;
  border-bottom: 1px solid #BFD6E2;
}
.omr-col-head > span:first-child {
  text-align: right;
  padding-right: 6px;
}
.omr-col-head-bubs {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 10px;
}
.omr-col-h { color: #2F6E89; }
.omr-row {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  width: 100%;
  padding: 3px 8px;
  border: none;
  border-top: 1px solid #ECEEF1;
  background: var(--surface);
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.omr-row:hover { background: var(--brand-bg-2); }
.omr-row.current { background: var(--brand-bg); }
.omr-row.current .omr-row-idx { color: var(--brand-strong); font-weight: 800; }
.omr-row-idx {
  text-align: right;
  padding-right: 6px;
  font-size: 12px;
  color: #5DB0CC;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.omr-row-bubs {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  justify-items: center;
}
.omr-b {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid #E5B3AD;
  background: transparent;
  display: inline-block;
  transition: background .1s ease;
}
.omr-b.on {
  background: var(--brand);
  border-color: var(--brand);
}

/* ─────────── scrollbars ─────────── */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 2px solid var(--surface);
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
