:root {
  --bg: #f6f5f3;
  --card: #ffffff;
  --text: #1d1b18;
  --muted: #6b665e;
  --line: #e4e0da;
  --accent: #6A57F2;
  --accent-ink: #ffffff;
  --danger: #c2412d;
  --warn-bg: #fff4e5;
  --warn-ink: #8a4b00;
  --session-bg: #121212;
  --bar-bg: #1c1c1e;
  --bar-ink: #f2f2f2;
  --bar-line: #2c2c2e;
  --radius-card: 12px;
  --radius-btn: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141414;
    --card: #1e1e1e;
    --text: #f0eeea;
    --muted: #a39e95;
    --line: #333;
  }
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.card-view {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 28px 24px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.brand {
  font-weight: 700;
  color: var(--accent);
}

h1 {
  font-size: 22px;
  margin: 8px 0 16px;
}

.sub {
  color: var(--muted);
  font-size: 14px;
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 12px 0 6px;
}

input {
  width: 100%;
  box-sizing: border-box;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  background: transparent;
  color: inherit;
  font-size: 16px;
}

input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

input.code {
  font-size: 26px;
  letter-spacing: 0.12em;
  text-align: center;
  height: 56px;
  font-variant-numeric: tabular-nums;
  margin-top: 8px;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius-btn);
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: transparent;
  color: inherit;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 600;
}

.wide {
  width: 100%;
  margin-top: 16px;
  min-height: 46px;
}

.ghost {
  border-color: transparent;
  color: var(--muted);
}

.msg {
  min-height: 1.4em;
  font-size: 14px;
  color: var(--danger);
  margin: 10px 0 0;
}

.msg.warn {
  background: var(--warn-bg);
  color: var(--warn-ink);
  padding: 10px 12px;
  border-radius: var(--radius-btn);
}

.top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.me {
  display: flex;
  align-items: center;
  gap: 8px;
}

.note {
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
}

#view-session {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--session-bg);
  color: var(--bar-ink);
}

#bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding: 4px 10px;
  background: var(--bar-bg);
  border-bottom: 1px solid var(--bar-line);
  flex-wrap: wrap;
  box-sizing: border-box;
}

.bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #2f2a55;
  color: #cfc8ff;
}

.mono {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 15px;
  letter-spacing: 0.04em;
}

.state {
  color: #a9a9ad;
  font-size: 13px;
  margin-left: 8px;
}

.bar-btn {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
  border-color: var(--bar-line);
  color: var(--bar-ink);
  background: #26262a;
}

.bar-btn:hover {
  background: #303036;
}

.danger {
  background: #3a1d19;
  border-color: #5a2a23;
  color: #ffb4a8;
}

.menu-wrap {
  position: relative;
  display: inline-block;
}

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  min-width: 230px;
  background: #26262a;
  border: 1px solid var(--bar-line);
  border-radius: 10px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.menu button {
  text-align: left;
  border: 0;
  color: var(--bar-ink);
  min-height: 36px;
  width: 100%;
}

.menu button:hover {
  background: #34343a;
}

#stage {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

#screen {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  outline: none;
  image-rendering: auto;
  background: #000;
}

#stage.one-to-one {
  overflow: auto;
  display: block;
}

#stage.one-to-one #screen {
  max-width: none;
  max-height: none;
  margin: 0;
}

#cursor {
  position: absolute;
  pointer-events: none;
  z-index: 5;
  image-rendering: pixelated;
}

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c8c8cc;
  font-size: 15px;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.35);
  text-align: center;
  padding: 16px;
}

#overlay:empty {
  display: none;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: #2b2b2f;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 50;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

@media (max-width: 600px) {
  .bar-btn {
    font-size: 12px;
    padding: 0 8px;
  }

  .state {
    display: none;
  }

  .card {
    padding: 22px 16px;
  }
}

/* 단계 2 — 파일 주고받기 띠 · 화면 고르기 메뉴의 지금 화면 */
#transfer {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: #1f1d2b;
  border-bottom: 1px solid var(--bar-line);
  font-size: 13px;
  color: var(--bar-ink);
  min-width: 0;
}
#transfer-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#transfer-bar {
  flex: 0 1 220px;
  min-width: 60px;
  height: 8px;
  accent-color: var(--accent);
}
.menu button.current {
  color: #cfc8ff;
  font-weight: 600;
}

/* 2단계 인증 — 처음 등록 QR · 열쇠 */
#totp-setup {
  text-align: center;
  margin: 8px 0 4px;
}
#totp-qr {
  width: 220px;
  height: 220px;
  max-width: 100%;
  image-rendering: pixelated;
  background: #fff;
  border-radius: 8px;
}
#totp-secret {
  display: block;
  font-size: 14px;
  letter-spacing: .08em;
  word-break: break-all;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  user-select: all;
}
