:root {
  color-scheme: dark;
  --bg: #0b0915;
  --panel: #191821;
  --panel-2: #12111a;
  --field: #111019;
  --line: #2b2938;
  --line-soft: #22202d;
  --text: #fbf7ef;
  --muted: #89869a;
  --accent: #7b61ff;
  --accent-2: #6c55e8;
  --accent-soft: rgba(123, 97, 255, 0.18);
  --warm: #ead9bc;
  --danger: #ff5e7d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: block;
  padding: 28px;
  background:
    radial-gradient(circle at 50% 22%, rgba(123, 97, 255, 0.11), transparent 36%),
    radial-gradient(circle at 12% 18%, rgba(68, 55, 130, 0.2), transparent 28%),
    linear-gradient(180deg, #12101e 0%, var(--bg) 72%);
  color: var(--text);
  font: 14px/1.45 Arial, Helvetica, sans-serif;
}

button,
input {
  border: 0;
  border-radius: 10px;
  color: var(--text);
  font: inherit;
}

button {
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.app {
  width: min(100%, 1080px);
  height: min(820px, calc(100vh - 56px));
  min-height: 650px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 38%),
    rgba(25, 24, 33, 0.96);
  box-shadow:
    0 26px 80px rgba(0, 0, 0, 0.52),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 340px) minmax(150px, 220px) 72px 118px;
  align-items: end;
  gap: 10px;
  padding: 26px 28px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  min-height: 74px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 10px;
  padding: 0 16px;
  white-space: nowrap;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.32);
}

.brandMark {
  width: 50px;
  height: 50px;
  display: inline-grid;
  place-items: center;
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.22), transparent 42%),
    var(--accent);
  box-shadow: 0 14px 34px rgba(123, 97, 255, 0.36);
}

.brandMark svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

input {
  height: 46px;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--field);
  padding: 0 14px;
  outline: 0;
  font-weight: 700;
}

input::placeholder {
  color: #6e6a82;
}

input:focus {
  border-color: rgba(123, 97, 255, 0.86);
  box-shadow: 0 0 0 4px rgba(123, 97, 255, 0.14);
}

.limit {
  text-align: center;
}

.topbar button {
  height: 46px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 900;
  box-shadow: 0 16px 32px rgba(123, 97, 255, 0.22);
}

.topbar button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 40px rgba(123, 97, 255, 0.3);
}

.topbar.isLoading button::after {
  content: "";
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-left: 8px;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-top-color: #fff;
  border-radius: 999px;
  vertical-align: -1px;
  animation: spin 700ms linear infinite;
}

.status {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px 4px;
  color: var(--muted);
}

.status.error {
  color: var(--danger);
}

.status.ok {
  color: #d8d1ff;
}

.status.loading {
  color: #f4f0ff;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 332px minmax(0, 1fr);
  gap: 0;
  border-top: 1px solid var(--line-soft);
}

.mailList {
  min-height: 0;
  overflow: auto;
  border-right: 1px solid var(--line-soft);
  background: rgba(10, 9, 16, 0.42);
}

#messages {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.messagesEmpty {
  padding: 18px;
  color: var(--muted);
  border: 1px dashed #373447;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
}

.mailRow {
  width: 100%;
  min-height: 62px;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: rgba(18, 17, 26, 0.9);
  text-align: left;
}

.mailRow:hover {
  border-color: rgba(123, 97, 255, 0.34);
  background: rgba(29, 27, 42, 0.96);
}

.mailRow.active {
  border-color: rgba(123, 97, 255, 0.72);
  background:
    linear-gradient(90deg, rgba(123, 97, 255, 0.22), rgba(25, 24, 35, 0.96));
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
}

.rowCode {
  min-height: 38px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border-radius: 10px;
  background: rgba(123, 97, 255, 0.18);
  color: #f3edff;
  font-size: 18px;
  font-weight: 900;
}

.rowMeta {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.from,
.date {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.from {
  color: #f7f2ff;
  font-weight: 700;
}

.date {
  color: var(--muted);
  font-size: 12px;
}

.reader {
  min-width: 0;
  overflow: auto;
  padding: 36px 34px;
  background:
    radial-gradient(circle at 50% 0%, rgba(123, 97, 255, 0.07), transparent 32%),
    rgba(8, 8, 13, 0.48);
}

.reader.empty {
  display: grid;
  place-items: center;
}

.readerHint {
  color: var(--muted);
}

.readerHeader {
  max-width: 680px;
  margin: 0 auto 26px;
  display: grid;
  justify-items: center;
  gap: 8px;
}

.readerTitle {
  max-width: 100%;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(18, 17, 26, 0.92);
  overflow-wrap: anywhere;
  color: #f5efff;
  font-weight: 900;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.22);
}

.readerSubject {
  color: var(--muted);
}

.mainCode {
  width: min(100%, 462px);
  min-height: 104px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  margin: 0 auto 16px;
  padding: 0 28px;
  border: 1px solid rgba(123, 97, 255, 0.28);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    #111019;
  color: var(--warm);
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 3px;
  text-align: center;
  box-shadow:
    0 20px 46px rgba(0, 0, 0, 0.36),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.mainCode:hover {
  border-color: rgba(123, 97, 255, 0.72);
  transform: translateY(-1px);
}

.mainCode small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
}

.mainCode + .readerBody::before {
  content: "";
  display: block;
  width: min(100%, 462px);
  height: 4px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--accent) 0 42%, rgba(255, 255, 255, 0.04) 42% 100%);
}

.readerBody {
  max-width: 680px;
  margin: 0 auto;
  padding: 18px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  color: #f2edf8;
  white-space: pre-wrap;
  word-break: break-word;
  font: 16px/1.65 Arial, Helvetica, sans-serif;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 920px) {
  body {
    padding: 14px;
  }

  .app {
    width: 100%;
    height: auto;
    min-height: calc(100vh - 28px);
  }

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

  .brand {
    grid-column: 1 / -1;
    white-space: normal;
    text-align: center;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 260px minmax(420px, 1fr);
  }

  .mailList {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }
}

@media (max-width: 560px) {
  body {
    padding: 0;
  }

  .app {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    border-radius: 0;
  }

  .topbar {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .reader {
    padding: 24px 16px;
  }

  .mainCode {
    font-size: 34px;
  }
}
