:root {
  --canvas: #f4f7f7;
  --surface: #ffffff;
  --surface-soft: #eef3f3;
  --ink: #17242b;
  --ink-soft: #5c6a70;
  --line: #d9e1e1;
  --teal: #0f766e;
  --teal-dark: #0b5d57;
  --teal-soft: #d8eeeb;
  --amber: #a45b12;
  --amber-soft: #fff0d9;
  --slate: #53656d;
  --slate-soft: #e7edef;
  --danger: #a33b3b;
  --danger-soft: #fff0ee;
  --shadow: 0 16px 48px rgba(30, 49, 57, 0.09);
  --radius: 18px;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", "Roboto Mono", monospace;
  --sans: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--canvas); }

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, transparent 0 31px, rgba(15, 118, 110, 0.035) 31px 32px, transparent 32px 100%),
    var(--canvas);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.32);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  color: white;
  background: var(--teal-dark);
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 760;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  grid-template-columns: repeat(3, 4px);
  align-items: end;
  gap: 3px;
  width: 18px;
  height: 20px;
}
.brand-mark i { display: block; width: 4px; border-radius: 3px; background: var(--teal); }
.brand-mark i:nth-child(1) { height: 8px; }
.brand-mark i:nth-child(2) { height: 17px; }
.brand-mark i:nth-child(3) { height: 12px; }

.eyebrow,
.panel-kicker {
  margin: 0 0 10px;
  color: var(--teal);
  font: 700 11px/1 var(--mono);
  letter-spacing: 0.14em;
}

.auth-shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 78% 20%, rgba(15, 118, 110, 0.13), transparent 28%),
    linear-gradient(135deg, #edf3f2 0%, #f7f9f9 58%, #e8eeee 100%);
}

.auth-card {
  width: min(100%, 480px);
  padding: 46px;
  border: 1px solid rgba(15, 118, 110, 0.14);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.auth-card .brand-lockup { margin-bottom: 58px; }
.auth-card h1 {
  margin: 0;
  max-width: 420px;
  font-size: clamp(34px, 8vw, 49px);
  line-height: 1.08;
  letter-spacing: -0.055em;
}
.auth-copy { margin: 22px 0 32px; color: var(--ink-soft); font-size: 15px; line-height: 1.75; }

.login-form label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 700; }
.password-field { position: relative; }
.password-field input {
  width: 100%;
  height: 50px;
  padding: 0 70px 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #fbfcfc;
}
.password-field input:focus { border-color: var(--teal); }
.text-button {
  position: absolute;
  top: 50%;
  right: 8px;
  padding: 7px 9px;
  border: 0;
  color: var(--teal-dark);
  background: transparent;
  transform: translateY(-50%);
  cursor: pointer;
}
.primary-button {
  width: 100%;
  min-height: 50px;
  margin-top: 12px;
  border: 0;
  border-radius: 12px;
  color: white;
  background: var(--teal);
  font-weight: 750;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}
.primary-button:hover { background: var(--teal-dark); }
.primary-button:active { transform: translateY(1px); }
.primary-button:disabled { opacity: 0.6; cursor: wait; }
.form-error { margin: 12px 0 0; color: var(--danger); font-size: 13px; }
.auth-footnote { margin: 22px 0 0; color: #7a878c; font-size: 12px; }

.app-shell { min-height: 100svh; }
.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 10px clamp(18px, 4vw, 54px);
  border-bottom: 1px solid rgba(217, 225, 225, 0.9);
  background: rgba(244, 247, 247, 0.9);
  backdrop-filter: blur(18px);
}
.brand-lockup--compact > span:last-child { display: grid; }
.brand-lockup--compact small { color: var(--ink-soft); font: 650 8px/1.4 var(--mono); letter-spacing: 0.12em; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.owner-email { color: var(--ink-soft); font-size: 12px; }
.quiet-link, .quiet-button {
  border: 0;
  color: var(--ink-soft);
  background: transparent;
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}
.quiet-link:hover, .quiet-button:hover { color: var(--teal); }

.workspace { width: min(1540px, 100%); margin: 0 auto; padding: 52px clamp(18px, 4vw, 54px) 70px; }
.workspace-head { display: flex; align-items: end; justify-content: space-between; gap: 28px; margin-bottom: 30px; }
.workspace-head h1 { margin: 0; font-size: clamp(34px, 5vw, 54px); letter-spacing: -0.055em; line-height: 1; }
.workspace-head > div:first-child > p:last-child { margin: 13px 0 0; color: var(--ink-soft); font-size: 14px; }

.summary { display: grid; grid-template-columns: repeat(3, minmax(108px, 1fr)); overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.summary div { min-width: 118px; padding: 14px 16px; border-right: 1px solid var(--line); }
.summary div:last-child { border-right: 0; }
.summary strong { display: block; font: 700 23px/1 var(--mono); }
.summary span { display: block; margin-top: 8px; color: var(--ink-soft); font-size: 11px; }

.global-error { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; padding: 13px 16px; border: 1px solid #ecc5bf; border-radius: 12px; color: #7f302b; background: var(--danger-soft); font-size: 13px; }
.global-error button { border: 0; color: inherit; background: transparent; font-weight: 750; cursor: pointer; }

.review-grid { display: grid; grid-template-columns: minmax(360px, 0.92fr) minmax(520px, 1.35fr); gap: 20px; align-items: start; }
.message-panel, .detail-panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 7px 24px rgba(30, 49, 57, 0.045); }
.message-panel { overflow: hidden; }
.detail-panel { position: sticky; top: 88px; min-height: 570px; padding: 26px; }
.panel-head { display: flex; justify-content: space-between; align-items: end; padding: 22px 22px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2, .detail-panel h2, .detail-panel h3 { margin: 0; letter-spacing: -0.035em; }
.panel-head h2 { font-size: 21px; }
.refresh-label { color: var(--ink-soft); font: 11px/1.4 var(--mono); }

.loading-block, .empty-state { padding: 50px 24px; text-align: center; color: var(--ink-soft); }
.empty-state strong { display: block; color: var(--ink); }
.empty-state p { margin: 9px auto 14px; max-width: 360px; font-size: 13px; line-height: 1.6; }
.empty-state a { color: var(--teal); font-size: 13px; font-weight: 700; }

.message-list { max-height: calc(100svh - 260px); min-height: 280px; overflow-y: auto; }
.message-row { position: relative; width: 100%; padding: 20px 22px 19px 30px; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); background: transparent; text-align: left; cursor: pointer; }
.message-row::before { content: ""; position: absolute; top: 22px; bottom: 22px; left: 15px; width: 3px; border-radius: 4px; background: var(--slate); }
.message-row[data-classification="human_likely"]::before { background: var(--teal); }
.message-row[data-classification="automatic"]::before { background: var(--amber); }
.message-row:hover { background: #f8fafa; }
.message-row[aria-current="true"] { background: var(--surface-soft); box-shadow: inset 3px 0 var(--teal); }
.message-row-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.message-row-subject { overflow: hidden; font-size: 14px; font-weight: 740; text-overflow: ellipsis; white-space: nowrap; }
.message-row-time { flex: 0 0 auto; color: #79868b; font: 10px/1.2 var(--mono); }
.message-row-recipient { display: block; overflow: hidden; margin-top: 6px; color: var(--ink-soft); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.message-row-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 13px; }
.message-row-events { color: var(--ink-soft); font: 10px/1 var(--mono); }

.status-badge { display: inline-flex; align-items: center; flex: 0 0 auto; min-height: 25px; padding: 0 9px; border-radius: 999px; color: var(--slate); background: var(--slate-soft); font-size: 11px; font-weight: 750; }
.status-badge[data-classification="human_likely"] { color: var(--teal-dark); background: var(--teal-soft); }
.status-badge[data-classification="automatic"] { color: var(--amber); background: var(--amber-soft); }

.detail-placeholder { min-height: 510px; display: grid; place-content: center; justify-items: center; text-align: center; color: var(--ink-soft); }
.detail-placeholder h2 { margin-top: 22px; color: var(--ink); }
.detail-placeholder p { margin: 8px 0 0; font-size: 13px; }
.signal-glyph { position: relative; display: flex; align-items: end; gap: 7px; height: 50px; }
.signal-glyph::after { content: ""; position: absolute; top: 50%; left: 50%; width: 76px; height: 76px; border: 1px solid var(--teal-soft); border-radius: 50%; transform: translate(-50%, -50%); }
.signal-glyph i { width: 6px; border-radius: 5px; background: var(--teal); }
.signal-glyph i:nth-child(1) { height: 18px; opacity: 0.46; }
.signal-glyph i:nth-child(2) { height: 45px; }
.signal-glyph i:nth-child(3) { height: 29px; opacity: 0.72; }

.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 23px; border-bottom: 1px solid var(--line); }
.detail-head h2 { max-width: 700px; font-size: clamp(22px, 3vw, 30px); line-height: 1.25; }
.detail-sender { margin: 0 0 8px; color: var(--teal); font: 650 11px/1.4 var(--mono); }
.detail-recipients { margin: 8px 0 0; color: var(--ink-soft); font-size: 12px; }
.message-meta { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0; padding: 20px 0; border-bottom: 1px solid var(--line); }
.message-meta div { padding: 0 14px; border-right: 1px solid var(--line); }
.message-meta div:first-child { padding-left: 0; }
.message-meta div:last-child { border-right: 0; }
.message-meta dt { color: var(--ink-soft); font-size: 10px; }
.message-meta dd { margin: 7px 0 0; font-size: 12px; font-weight: 700; }

.evidence-block, .timeline-block { padding-top: 26px; }
.section-title-row { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.section-title-row h3 { font-size: 18px; }
.classification-label { color: var(--ink-soft); font: 11px/1.4 var(--mono); }
.evidence-explanation { margin: 17px 0 0; padding: 15px 16px; border-left: 3px solid var(--teal); border-radius: 0 8px 8px 0; color: #33464e; background: var(--surface-soft); font-size: 13px; line-height: 1.65; }
.reason-list { display: flex; flex-wrap: wrap; gap: 7px; margin: 13px 0 0; padding: 0; list-style: none; }
.reason-list li { padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink-soft); background: #fafbfb; font: 10px/1.2 var(--mono); }

.timeline-empty { margin-top: 16px; padding: 18px; border: 1px dashed #c7d1d2; border-radius: 10px; color: var(--ink-soft); background: #fafcfc; font-size: 13px; line-height: 1.65; }
.event-timeline { margin: 19px 0 0; padding: 0; list-style: none; }
.event-item { position: relative; display: grid; grid-template-columns: 104px 16px minmax(0, 1fr); gap: 13px; min-height: 78px; }
.event-time { color: var(--ink-soft); font: 10px/1.5 var(--mono); text-align: right; }
.event-rail { position: relative; }
.event-rail::before { content: ""; position: absolute; top: 5px; left: 7px; bottom: -5px; width: 1px; background: var(--line); }
.event-item:last-child .event-rail::before { bottom: auto; height: 10px; }
.event-dot { position: absolute; z-index: 1; top: 3px; left: 3px; width: 9px; height: 9px; border: 2px solid white; border-radius: 50%; background: var(--slate); box-shadow: 0 0 0 1px var(--slate); }
.event-item[data-classification="human_likely"] .event-dot { background: var(--teal); box-shadow: 0 0 0 1px var(--teal); }
.event-item[data-classification="automatic"] .event-dot { background: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.event-body { padding-bottom: 20px; }
.event-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.event-title strong { font-size: 13px; }
.event-client { color: var(--ink-soft); font: 10px/1.2 var(--mono); }
.event-reasons { margin: 7px 0 0; color: var(--ink-soft); font-size: 11px; line-height: 1.5; }

@media (max-width: 960px) {
  .workspace-head { align-items: stretch; flex-direction: column; }
  .summary { align-self: stretch; }
  .review-grid { grid-template-columns: 1fr; }
  .detail-panel { position: static; min-height: 420px; }
  .message-list { max-height: 540px; }
}

@media (max-width: 640px) {
  .auth-shell { padding: 12px; }
  .auth-card { padding: 30px 22px; border-radius: 20px; }
  .auth-card .brand-lockup { margin-bottom: 42px; }
  .topbar { align-items: flex-start; padding: 12px 16px; }
  .owner-email { display: none; }
  .topbar-actions { gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
  .quiet-link, .quiet-button { font-size: 11px; }
  .workspace { padding: 36px 12px 48px; }
  .summary { grid-template-columns: 1fr; }
  .summary div { display: flex; align-items: center; justify-content: space-between; min-width: 0; padding: 10px 13px; border-right: 0; border-bottom: 1px solid var(--line); }
  .summary div:last-child { border-bottom: 0; }
  .summary strong { font-size: 18px; }
  .summary span { margin: 0; }
  .detail-panel { padding: 20px 16px; }
  .detail-head { flex-direction: column; }
  .message-meta { grid-template-columns: 1fr 1fr; gap: 16px 0; }
  .message-meta div:nth-child(2) { border-right: 0; }
  .message-meta div:nth-child(3) { padding-left: 0; }
  .event-item { grid-template-columns: 74px 14px minmax(0, 1fr); gap: 9px; }
  .event-time { font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
