:root {
  --bg: #f5f6f8;
  --card: #fff;
  --border: #d8dce2;
  --text: #1f2328;
  --muted: #6b7280;
  --accent: #2456a6;
  --ok: #1a7f45;
  --warn: #b45309;
  --err: #b42318;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', system-ui, sans-serif;
  font-size: 15px; line-height: 1.5;
}
a { color: var(--accent); }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.tagline { color: var(--muted); font-size: .82rem; }
.spacer { flex: 1; }
.health { font-size: .8rem; color: var(--muted); }
.health.ok { color: var(--ok); }
.health.bad { color: var(--err); }

.topnav { font-size: .82rem; text-decoration: none; }
.whoami { font-size: .82rem; color: var(--text); white-space: nowrap; }
.tag {
  font-size: .68rem; background: #e5efff; color: var(--accent);
  padding: 1px 6px; border-radius: 8px; margin-left: 2px;
}
.logout { margin: 0; }
.logout button {
  padding: 4px 10px; font-size: .78rem; font-weight: 500;
  background: #f2f3f5; color: var(--muted);
}
.logout button:hover { background: #e6e8ec; }

.wrap { max-width: 1000px; margin: 0 auto; padding: 20px; }

/* 로그인 */
.auth-card { max-width: 420px; margin: 40px auto; }
.auth-form { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; }
.auth-form label > span { font-size: .8rem; color: var(--muted); }
.auth-form input[type=text], .auth-form input[type=password], .auth-form select {
  padding: 8px 10px; font-size: .9rem; border: 1px solid var(--border);
  border-radius: 6px; font-family: inherit;
}
.auth-form.inline {
  flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px;
}
.auth-form.inline button { padding: 6px 14px; font-size: .82rem; }
.signup { margin-top: 18px; padding-top: 12px; border-top: 1px solid #eef0f3; }
.signup summary { cursor: pointer; font-size: .84rem; color: var(--accent); }
.notice {
  color: var(--ok); font-size: .85rem; margin: 8px 0 0;
  background: #e6f5ec; padding: 8px 10px; border-radius: 6px;
}
.danger { color: var(--err) !important; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 18px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 4px; font-size: 1.05rem; }
.card h3 { margin: 0 0 10px; font-size: .95rem; color: var(--muted); }
.hint, .muted { color: var(--muted); font-size: .84rem; }
.muted { font-weight: 400; }

/* 업로드 */
.upload { display: flex; gap: 10px; align-items: stretch; margin-top: 12px; }
.drop {
  flex: 1; display: flex; align-items: center; justify-content: center;
  min-height: 84px; padding: 12px; text-align: center; cursor: pointer;
  border: 2px dashed var(--border); border-radius: 8px;
  color: var(--muted); font-size: .88rem; background: #fafbfc;
}
.drop:hover, .drop.over { border-color: var(--accent); background: #f0f5fd; color: var(--accent); }
.drop.has-file { border-style: solid; color: var(--text); }
button {
  padding: 0 22px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #fff; font-size: .9rem; font-weight: 600;
}
button:disabled { background: #b9c2d0; cursor: not-allowed; }

/* 업로드 옵션 */
.opt-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid #eef0f3;
}
.check { display: flex; align-items: center; gap: 6px; cursor: pointer;
         font-size: .86rem; white-space: nowrap; }
.check input { width: 15px; height: 15px; cursor: pointer; }
.opt-row select {
  padding: 5px 8px; font-size: .82rem; border: 1px solid var(--border);
  border-radius: 5px; background: #fff; font-family: inherit; max-width: 320px;
}
.opt-row select:disabled { background: #f2f3f5; color: var(--muted); cursor: not-allowed; }
#summary-hint { flex: 1; min-width: 200px; font-size: .78rem; }

/* 진행 막대 */
.bar {
  position: relative; height: 22px; margin-top: 8px;
  background: #eceff3; border-radius: 5px; overflow: hidden;
}
.bar-fill {
  height: 100%; width: 0; background: var(--accent);
  transition: width .3s ease;
}
.bar-text {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; font-size: .76rem; color: var(--text);
}
.hidden { display: none; }
.error { color: var(--err); font-size: .85rem; margin: 8px 0 0; }

/* 작업 */
.job { padding: 10px 0; border-bottom: 1px solid #eef0f3; }
.job:last-child { border-bottom: 0; }
.job-head { display: flex; align-items: center; gap: 8px; }
.job-name { flex: 1; font-size: .88rem; overflow: hidden;
            text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: .74rem; padding: 2px 8px; border-radius: 10px; background: #eceff3; }
.badge-running { background: #e5efff; color: var(--accent); }
.badge-queued  { background: #f2f3f5; color: var(--muted); }
.badge-done    { background: #e6f5ec; color: var(--ok); }
.badge-error   { background: #fdecea; color: var(--err); }

/* 결과 표 */
table.results { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: .86rem; }
table.results th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: .78rem;
  border-bottom: 1px solid var(--border); padding: 6px 8px;
}
table.results td { padding: 7px 8px; border-bottom: 1px solid #eef0f3; }
table.results tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.name { word-break: break-all; min-width: 180px; }
.dim { color: var(--muted); font-size: .78rem; }
.links a { margin-right: 8px; white-space: nowrap; }
/* 다운로드 링크는 버튼처럼 보이게 해 '보기'와 구분한다. */
.dl a {
  display: inline-block; margin: 1px 4px 1px 0; padding: 2px 8px;
  border: 1px solid var(--border); border-radius: 4px;
  font-size: .78rem; text-decoration: none; background: #fafbfc;
}
.dl a:hover { background: #eef3fb; border-color: var(--accent); }

/* 결과 상세 */
.back { display: inline-block; margin-bottom: 8px; font-size: .84rem; }
.meta-grid { display: flex; flex-wrap: wrap; gap: 18px; margin: 12px 0; }
.meta-grid dt { color: var(--muted); font-size: .74rem; }
.meta-grid dd { margin: 2px 0 0; font-size: .95rem; font-weight: 600; }
.btn {
  display: inline-block; padding: 7px 16px; border-radius: 6px;
  background: var(--accent); color: #fff !important; text-decoration: none;
  font-size: .86rem; font-weight: 600;
}
.btn-alt { background: #fff; color: var(--accent) !important; border: 1px solid var(--accent); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0 4px; }

/* 다운로드 목록: 파일명 + 무엇인지 설명 */
.dl-list { list-style: none; padding: 0; margin: 12px 0 0; }
.dl-list li {
  padding: 7px 0; border-top: 1px solid #eef0f3;
  display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline;
}
.dl-list a { font-size: .86rem; word-break: break-all; }
.dl-list .muted { font-size: .78rem; }
.dl-list code {
  background: #f0f1f3; padding: 0 4px; border-radius: 3px; font-size: .92em;
}
.preview iframe {
  width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: 6px;
  background: #fff;
}

/* 원본 영상 */
.video-box { margin: 14px 0 4px; }
.video-box summary {
  cursor: pointer; font-size: .88rem; font-weight: 600; padding: 6px 0;
}
.video-box video {
  width: 100%; max-height: 55vh; margin-top: 8px; background: #000;
  border-radius: 6px;
}
.video-box code { background: #f0f1f3; padding: 0 4px; border-radius: 3px; }

/* 요약 */
.summary-form { display: flex; gap: 10px; margin: 12px 0 0; flex-wrap: wrap; }
.summary-form select {
  flex: 1; min-width: 240px; padding: 8px 10px; font-size: .86rem;
  border: 1px solid var(--border); border-radius: 6px; background: #fff;
  font-family: inherit;
}
.summary-meta {
  display: flex; align-items: center; gap: 10px; margin: 14px 0 8px;
  flex-wrap: wrap; font-size: .84rem;
}
.summary-body {
  margin: 0; padding: 14px; background: #fafbfc; border: 1px solid var(--border);
  border-radius: 6px; white-space: pre-wrap; word-break: break-word;
  font-family: inherit; font-size: .88rem; line-height: 1.6;
  max-height: 60vh; overflow-y: auto;
}

.foot { text-align: center; color: var(--muted); font-size: .78rem; padding: 20px; }

@media (max-width: 640px) {
  .upload { flex-direction: column; }
  table.results { font-size: .8rem; }
}
