@font-face {
  font-family: 'Gibson';
  src: url('font/Gibson-Light-webfont.woff2') format('woff2'), url('font/Gibson-Light-webfont.woff') format('woff');
  font-weight: 300;
  font-display: swap;
}
@font-face {
  font-family: 'Gibson';
  src: url('font/Gibson-Regular-webfont.woff2') format('woff2'), url('font/Gibson-Regular-webfont.woff') format('woff');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Gibson';
  src: url('font/Gibson-SemiBold-webfont.woff2') format('woff2'), url('font/Gibson-SemiBold-webfont.woff') format('woff');
  font-weight: 600;
  font-display: swap;
}

:root {
  --bg: #1b2131;
  --surface: #242b3a;
  --surface-2: #2b3346;
  --surface-3: #323b50;
  --line: rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .13);
  --text: #eef1f7;
  --muted: #949eb2;
  --faint: #67718a;
  --blue: #3598fe;
  --blue-2: #5aacff;
  --blue-soft: rgba(53, 152, 254, .13);
  --blue-line: rgba(53, 152, 254, .38);
  --orange: #d05a29;
  --green: #36c47f;
  --amber: #f0b429;
  --radius: 18px;
  --font: 'Gibson', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  font: 400 15px/1.5 var(--font);
  color: var(--text);
  background:
    radial-gradient(1100px 520px at 0% -12%, rgba(208, 90, 41, .13), transparent 62%),
    radial-gradient(900px 520px at 100% -8%, rgba(53, 152, 254, .10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

button { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: .86em; color: #c9d3e6; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--blue-2); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 26px 28px 8px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand img { display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-size: 22px; font-weight: 400; letter-spacing: .2px; }
.brand-name strong { font-weight: 600; }
.brand-sub { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.6px; margin-top: 4px; }

.tools { display: flex; align-items: center; gap: 14px; }
.search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}
.search svg { position: absolute; left: 13px; width: 17px; height: 17px; fill: var(--faint); pointer-events: none; }
.search input {
  width: 250px;
  height: 42px;
  padding: 0 14px 0 38px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  font: inherit;
  transition: border-color .15s, background .15s;
}
.search input::placeholder { color: var(--faint); }
.search input:focus { outline: none; border-color: var(--blue-line); background: rgba(53, 152, 254, .06); }

.live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(54, 196, 127, .1);
  color: #9fe3c0;
  font-size: 13px;
  white-space: nowrap;
}
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(54, 196, 127, .6); animation: pulse 2s infinite; }
.live.is-error { background: rgba(240, 180, 41, .12); color: #f6d58a; }
.live.is-error i { background: var(--amber); animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(54, 196, 127, .55); }
  70% { box-shadow: 0 0 0 8px rgba(54, 196, 127, 0); }
  100% { box-shadow: 0 0 0 0 rgba(54, 196, 127, 0); }
}

/* ---------- layout ---------- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: 24px;
  align-items: start;
  align-content: start;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 28px 28px;
}

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, .025), transparent 40%), var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px -24px rgba(0, 0, 0, .55);
}

/* ---------- message viewer ---------- */
.hero { padding: 26px 28px 24px; }
.hero.flash { animation: flash 1.6s ease-out; }
@keyframes flash {
  0% { box-shadow: 0 0 0 2px var(--blue-line), 0 0 48px -8px rgba(53, 152, 254, .55); }
  100% { box-shadow: 0 18px 40px -24px rgba(0, 0, 0, .55); }
}

.hero-top { display: flex; align-items: center; gap: 14px; }
.who { min-width: 0; flex: 1; }
.sender { font-size: 18px; font-weight: 600; line-height: 1.2; }
.recipient { color: var(--muted); font-size: 14px; margin-top: 2px; }
.recipient b { color: var(--text); font-weight: 400; font-variant-numeric: tabular-nums; letter-spacing: .3px; }
.when { text-align: right; color: var(--muted); font-size: 13px; line-height: 1.35; white-space: nowrap; }
.when strong { display: block; color: var(--text); font-weight: 400; font-size: 14px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
  font-size: 12px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); }
.badge button {
  border: 0;
  background: none;
  padding: 0;
  color: var(--blue-2);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  margin-left: 6px;
}
.badge button:hover { text-decoration: underline; }

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, #e0703d, var(--orange));
  color: #fff;
  font-weight: 600;
  font-size: 19px;
  text-transform: uppercase;
}
.avatar.sm { width: 36px; height: 36px; border-radius: 11px; font-size: 15px; }

.code-block {
  margin: 26px 0 22px;
  padding: 22px 22px 20px;
  border-radius: 16px;
  background: rgba(53, 152, 254, .07);
  border: 1px solid rgba(53, 152, 254, .18);
  text-align: center;
}
.code-label {
  font-size: 12px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--blue-2);
  margin-bottom: 14px;
}
.code-block.is-low { background: rgba(255, 255, 255, .03); border-color: var(--line-2); }
.code-block.is-low .code-label { color: var(--muted); }

.code {
  --size: 64px;
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 4px;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 14px;
}
.code.len-7, .code.len-8 { --size: 54px; gap: 8px; }
.code.len-long { --size: 44px; gap: 6px; }
.digit {
  display: grid;
  place-items: center;
  width: var(--size);
  height: calc(var(--size) * 1.18);
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--blue-line);
  font-size: calc(var(--size) * .58);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #fff;
  transition: transform .15s, border-color .15s, background .15s;
}
.code:hover .digit { border-color: var(--blue-2); background: var(--surface-3); }
.code:active .digit { transform: scale(.97); }
.is-low .digit { border-color: var(--line-2); }

.code-actions { display: flex; justify-content: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.code-hint { color: var(--faint); font-size: 12.5px; margin-top: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border-radius: 11px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: rgba(255, 255, 255, .08); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; fill: currentColor; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--blue-2); border-color: var(--blue-2); }
.btn.is-done { background: var(--green); border-color: var(--green); }

.no-code {
  margin: 24px 0 18px;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .03);
  border: 1px dashed var(--line-2);
  color: var(--muted);
  font-size: 14px;
}

.bubble-label { font-size: 12px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--faint); margin-bottom: 8px; }
.bubble {
  position: relative;
  padding: 16px 18px;
  border-radius: 6px 18px 18px 18px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 16px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bubble mark { background: var(--blue-soft); color: #fff; font-weight: 600; padding: 0 3px; border-radius: 5px; box-shadow: inset 0 0 0 1px var(--blue-line); }

.hero-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.stats { display: flex; flex-wrap: wrap; gap: 6px; }
.stat { font-size: 12.5px; color: var(--muted); padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); }
.stat.warn { color: #f6d58a; border-color: rgba(240, 180, 41, .3); }
.link-btn { border: 0; background: none; color: var(--blue-2); cursor: pointer; font-size: 13.5px; padding: 4px 2px; }
.link-btn:hover { text-decoration: underline; }

/* empty state */
.empty { padding: 56px 32px; text-align: center; }
.empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: var(--blue-soft);
}
.empty-icon svg { width: 30px; height: 30px; fill: var(--blue-2); }
.empty h1 { margin: 0 0 8px; font-size: 22px; font-weight: 600; }
.empty p { margin: 0 auto; max-width: 440px; color: var(--muted); }
.empty code { display: inline-block; margin-top: 14px; padding: 8px 12px; font-size: 13px; }

/* ---------- inbox ---------- */
.inbox {
  position: sticky;
  top: 18px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 36px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.inbox-head { display: flex; align-items: baseline; justify-content: space-between; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.inbox-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.count { color: var(--faint); font-size: 13px; }

.list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
.row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: none;
  text-align: left;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.row:hover { background: rgba(255, 255, 255, .035); }
.row.is-active { background: var(--blue-soft); border-color: rgba(53, 152, 254, .28); }
.row.is-new { animation: slide-in .5s ease-out; }
@keyframes slide-in {
  from { opacity: 0; transform: translateY(-8px); background: rgba(53, 152, 254, .22); }
  to { opacity: 1; transform: none; }
}
.row-main { min-width: 0; }
.row-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.row-top b { flex: none; max-width: 60%; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-to { flex: 0 1 auto; min-width: 0; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-time { flex: none; margin-left: auto; padding-left: 6px; color: var(--faint); font-size: 12px; white-space: nowrap; }
.row-text { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip {
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  padding: 4px 9px;
  border-radius: 8px;
  background: rgba(53, 152, 254, .15);
  color: #cfe5ff;
  border: 1px solid rgba(53, 152, 254, .25);
}
.chip.is-low { background: rgba(255, 255, 255, .05); color: var(--muted); border-color: var(--line-2); }
.list-empty { padding: 28px 16px; color: var(--faint); text-align: center; font-size: 14px; }

/* ---------- footer + toast ---------- */
.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 4px 28px 26px;
  color: var(--faint);
  font-size: 12.5px;
}
.foot em { font-style: normal; color: var(--muted); }
.foot code { overflow-wrap: anywhere; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  padding: 10px 16px;
  border-radius: 12px;
  background: #0f1420;
  border: 1px solid var(--line-2);
  color: var(--text);
  font-size: 14px;
  box-shadow: 0 14px 32px -12px rgba(0, 0, 0, .7);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- small screens ---------- */
@media (max-width: 920px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .inbox { position: static; max-height: none; }
}
@media (max-width: 600px) {
  .topbar { padding: 18px 16px 4px; }
  .tools { width: 100%; }
  .search { flex: 1; }
  .search input { width: 100%; min-width: 0; }
  .layout { padding: 14px 16px 20px; gap: 16px; }
  .hero { padding: 20px 18px 18px; }
  .hero-top { flex-wrap: wrap; }
  .when { text-align: left; flex-basis: 100%; padding-left: 60px; }
  .code-block { padding: 18px 12px 16px; margin: 20px 0 18px; }
  .code { --size: 52px; gap: 8px; }
  .code.len-7, .code.len-8 { --size: 38px; gap: 5px; }
  .code.len-long { --size: 30px; gap: 4px; }
  .foot { padding: 4px 16px 22px; }
  .row-top { flex-wrap: wrap; row-gap: 0; }
  .row-to { order: 3; flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
