:root {
  color-scheme: dark;
  --bg: #0b0b0d;
  --surface: #151518;
  --surface-raised: #1d1d21;
  --surface-soft: #242429;
  --line: #313137;
  --text: #f5f5f7;
  --muted: #a5a5ae;
  --red: #ff3b30;
  --red-soft: rgba(255, 59, 48, 0.13);
  --blue: #3b82f6;
  --green: #31c48d;
  --yellow: #f5b942;
  --radius: 16px;
  font-family:
    Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", Inter, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

.login-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 59, 48, 0.15), transparent 32%),
    var(--bg);
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(21, 21, 24, 0.96);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.42);
  text-align: center;
}

.login-brand {
  width: 52px;
  height: 52px;
  margin: 0 auto 22px;
}

.login-card h1 {
  margin: 0;
  font-size: 27px;
  letter-spacing: -0.04em;
}

.login-card p {
  margin: 13px 0 26px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.google-login-button {
  display: flex;
  width: 100%;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid #45454d;
  border-radius: 11px;
  background: #f8f8fa;
  color: #202124;
  font-weight: 800;
}

.google-login-button span {
  color: #4285f4;
  font-size: 17px;
  font-weight: 900;
}

.login-status {
  margin-top: 16px;
  padding: 11px 13px;
  border-radius: 9px;
  background: rgba(59, 130, 246, 0.1);
  color: #9bc1ff;
  font-size: 11px;
  line-height: 1.55;
}

.login-status.is-error {
  background: rgba(255, 59, 48, 0.1);
  color: #ff9a94;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 12px clamp(18px, 3vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgba(11, 11, 13, 0.94);
  backdrop-filter: blur(14px);
}

.brand-block,
.topbar-actions,
.panel-heading,
.dialog-header,
.dialog-actions,
.current-product {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  background: var(--red);
  color: white;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: -0.04em;
  box-shadow: 0 10px 28px rgba(255, 59, 48, 0.22);
}

.brand-block strong {
  display: block;
  font-size: 17px;
}

.brand-block p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.topbar-actions {
  justify-content: flex-end;
  gap: 10px;
}

.live-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.live-state i,
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.live-state.is-live {
  border-color: rgba(255, 59, 48, 0.38);
  color: #ff8c86;
  background: var(--red-soft);
}

.live-state.is-live i {
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(255, 59, 48, 0.12);
}

.ghost-button,
.secondary-button,
.primary-button {
  min-height: 42px;
  border-radius: 10px;
  padding: 0 16px;
  border: 1px solid var(--line);
  font-weight: 750;
}

.ghost-button,
.secondary-button {
  background: var(--surface-raised);
  color: var(--text);
}

.ghost-button:hover,
.secondary-button:hover {
  border-color: #55555e;
  background: var(--surface-soft);
}

.ghost-button span {
  display: inline-grid;
  min-width: 21px;
  height: 21px;
  margin-left: 5px;
  place-items: center;
  border-radius: 999px;
  background: #34343a;
  font-size: 11px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 410px);
  gap: clamp(16px, 2vw, 28px);
  min-height: 0;
  padding: clamp(18px, 2.4vw, 32px) clamp(18px, 3vw, 40px);
}

.video-column {
  min-width: 0;
}

.player-frame {
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid #242429;
  border-radius: var(--radius);
  background: #050506;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.28);
}

.player-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.player-placeholder {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 32px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 59, 48, 0.12), transparent 30%),
    #09090b;
}

.player-placeholder span {
  margin-bottom: 16px;
  padding: 5px 8px;
  border-radius: 5px;
  background: var(--red);
  font-size: 11px;
  font-weight: 900;
}

.player-placeholder strong {
  font-size: clamp(20px, 2.3vw, 30px);
}

.player-placeholder p {
  margin: 10px 0 0;
  color: var(--muted);
}

.broadcast-info {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 3px 0;
}

.eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.12em;
}

.broadcast-info h1,
.panel-heading h2,
.dialog-header h2 {
  margin: 0;
  letter-spacing: -0.035em;
}

.broadcast-info h1 {
  font-size: clamp(20px, 2vw, 28px);
}

.sync-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
}

.sync-time strong {
  margin-left: 4px;
  color: #d2d2d7;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel-heading {
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2 {
  font-size: 17px;
}

.chat-count {
  display: grid;
  min-width: 32px;
  height: 26px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.chat-feed {
  overflow-y: auto;
  padding: 8px 0;
  scrollbar-color: #3c3c42 transparent;
}

.chat-message {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 16px;
}

.chat-message:hover {
  background: rgba(255, 255, 255, 0.025);
}

.chat-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: hsl(var(--avatar-hue) 48% 35%);
  color: white;
  font-size: 12px;
  font-weight: 850;
}

.chat-line {
  min-width: 0;
  color: #e9e9ec;
  font-size: 13px;
  line-height: 1.52;
  overflow-wrap: anywhere;
}

.chat-author {
  margin-right: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.chat-time {
  margin-left: 7px;
  color: #6f6f77;
  font-size: 10px;
}

.intent-badge {
  display: inline-block;
  margin: 5px 6px 0 0;
  padding: 3px 7px;
  border-radius: 5px;
  background: rgba(59, 130, 246, 0.12);
  color: #87b4ff;
  font-size: 9px;
  font-weight: 850;
}

.intent-badge.needs-review {
  background: rgba(245, 185, 66, 0.12);
  color: #f6c862;
}

.chat-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.chat-footer .status-dot {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(49, 196, 141, 0.1);
}

.empty-state {
  display: flex;
  min-height: 100%;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 40px;
  text-align: center;
}

.empty-state strong {
  font-size: 15px;
}

.empty-state p {
  max-width: 310px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.current-product {
  justify-content: space-between;
  gap: 28px;
  min-height: 86px;
  padding: 14px clamp(18px, 3vw, 40px);
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.current-product strong {
  display: block;
  font-size: 18px;
}

.product-meta {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

body.player-hidden .workspace {
  grid-template-columns: minmax(0, 1fr);
}

body.player-hidden .video-column {
  display: none;
}

body.player-hidden .chat-panel {
  min-height: calc(100vh - 76px - 86px - 64px);
}

.modal-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
}

.candidate-dialog {
  width: min(820px, 92vw);
  max-height: 92vh;
  overflow-y: auto;
  border: 1px solid #3d3d44;
  border-radius: 20px;
  background: #19191d;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.55);
}

.dialog-header {
  justify-content: space-between;
  gap: 20px;
  padding: 24px 26px 18px;
}

.dialog-kicker {
  display: block;
  margin-bottom: 7px;
  color: #ff807a;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.dialog-header h2 {
  font-size: clamp(21px, 3vw, 28px);
}

.confidence {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 7px;
  background: #29292f;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.transcript-box {
  margin: 0 26px 20px;
  padding: 15px 16px;
  border-left: 3px solid #4d4d55;
  border-radius: 0 10px 10px 0;
  background: #222227;
}

.transcript-box span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.transcript-box p {
  margin: 7px 0 0;
  color: #dedee2;
  font-size: 14px;
  line-height: 1.55;
}

.candidate-dialog form {
  padding: 0 26px 26px;
}

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

.field {
  display: block;
}

.field-wide {
  grid-column: 1 / -1;
}

.field > span {
  display: block;
  margin-bottom: 7px;
  color: #c8c8ce;
  font-size: 12px;
  font-weight: 750;
}

.field em {
  color: #ff7770;
  font-size: 10px;
  font-style: normal;
}

.field input {
  width: 100%;
  height: 46px;
  border: 1px solid #3a3a42;
  border-radius: 9px;
  outline: none;
  padding: 0 13px;
  background: #111114;
  color: var(--text);
}

.field input:read-only {
  border-color: #2d2d33;
  background: #202025;
  color: #dddde1;
}

.field input:not(:read-only):focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}

.field.is-invalid input {
  border-color: rgba(255, 59, 48, 0.75);
  background: rgba(255, 59, 48, 0.05);
}

.field small {
  display: block;
  min-height: 16px;
  margin-top: 6px;
  color: #ff827c;
  font-size: 10px;
}

.money-input {
  position: relative;
}

.money-input input {
  padding-right: 38px;
}

.money-input b {
  position: absolute;
  top: 50%;
  right: 13px;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 11px;
}

.dialog-alert {
  margin-top: 17px;
  padding: 11px 13px;
  border: 1px solid rgba(245, 185, 66, 0.3);
  border-radius: 9px;
  background: rgba(245, 185, 66, 0.08);
  color: #f5c75f;
  font-size: 11px;
  line-height: 1.5;
}

.dialog-actions {
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.primary-button {
  min-width: 190px;
  border-color: var(--red);
  background: var(--red);
  color: white;
  box-shadow: 0 10px 26px rgba(255, 59, 48, 0.18);
}

.primary-button:hover:not(:disabled) {
  background: #ff5047;
}

.toast {
  position: fixed;
  z-index: 80;
  right: 24px;
  bottom: 24px;
  max-width: min(430px, calc(100vw - 48px));
  padding: 13px 16px;
  border: 1px solid #3b3b43;
  border-radius: 10px;
  background: #25252a;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  color: #f2f2f4;
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .chat-panel {
    min-height: 620px;
  }

  body.player-hidden .chat-panel {
    min-height: calc(100vh - 76px - 86px - 56px);
  }
}

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

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .live-state {
    margin-right: auto;
  }

  .workspace {
    padding: 14px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .candidate-dialog {
    width: 100%;
    max-height: 96vh;
  }

  .dialog-header,
  .candidate-dialog form {
    padding-right: 18px;
    padding-left: 18px;
  }

  .transcript-box {
    margin-right: 18px;
    margin-left: 18px;
  }

  .dialog-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .primary-button {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .current-product {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .product-meta {
    text-align: left;
  }
}
