﻿:root {
  --bg: #090b10;
  --surface: #11141b;
  --surface-2: #0d1016;
  --surface-3: #171b24;
  --stroke: #232938;
  --stroke-2: #2e3547;
  --ink: #dde4f1;
  --muted: #8f9ab0;
  --accent: #4d8dff;
  --accent-2: #2d6fe5;
  --ok: #35a46e;
  --danger: #d15a5a;
  --warning: #f2c94c;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  background: radial-gradient(circle at 80% -10%, #1a2130 0%, transparent 40%), var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", sans-serif;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
}

.topbar {
  height: 64px;
  flex: 0 0 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  background: #0d1118;
  border-bottom: 1px solid var(--stroke);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}

.brand__mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font: 700 0.95rem "IBM Plex Mono", monospace;
  color: #ffffff;
  background: linear-gradient(145deg, #2f5fae, #3d83ff);
  border: 1px solid #4d86e0;
}

.brand__text {
  display: grid;
  line-height: 1.05;
}

.brand__text strong {
  font-size: 0.92rem;
  font-weight: 700;
}

.brand__text span {
  font-size: 0.67rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar__tools {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(860px, 100%);
}

.search-input {
  width: 100%;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--stroke-2);
  background: #121824;
  color: var(--ink);
  padding: 0 0.8rem;
  font: 500 0.84rem "IBM Plex Sans", sans-serif;
}

.search-input:focus {
  outline: none;
  border-color: #4a75b9;
  box-shadow: 0 0 0 3px rgba(77, 141, 255, 0.15);
}

.page {
  flex: 1;
  min-height: 0;
  width: 100%;
  padding: 0.5rem;
  overflow: hidden;
}

.card {
  height: 100%;
  min-height: 0;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: color-mix(in oklab, var(--surface), #000 4%);
}

.mail {
  display: flex;
  flex-direction: column;
  padding: 0.7rem;
  height: 100%;
  min-height: 0;
}

.mail__head {
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--stroke);
}

.eyebrow {
  margin: 0;
  color: #8cb4ff;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 600;
  font-family: "IBM Plex Mono", monospace;
}

h1,
h2,
h3,
h4,
h5 {
  margin: 0;
}

.mail__head h1 {
  margin-top: 0.22rem;
  font-size: clamp(1rem, 1.7vw, 1.28rem);
}

.mail__desc,
.muted,
.mailbox-meta,
.message-meta {
  color: var(--muted);
}

.mail__desc {
  margin: 0.28rem 0 0;
  font-size: 0.83rem;
  line-height: 1.35;
}

.status {
  min-height: 1rem;
  margin-top: 0.45rem;
  font-size: 0.8rem;
}

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

.status.success {
  color: var(--ok);
}

.mail__grid {
  margin-top: 0.5rem;
  flex: 1;
  min-height: 0;
  display: grid;
  /* Give more space to the right (viewer) panel */
  grid-template-columns: minmax(320px, 390px) minmax(300px, 420px) minmax(0, 1fr);
  gap: 0.55rem;
  overflow: hidden;
}

.mail__grid > * {
  min-width: 0;
}

.sidebar,
.card-panel {
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.sidebar {
  padding: 0.5rem;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 0.45rem;
}

.sidebar__meta {
  display: flex;
}

.pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--stroke-2);
  background: var(--surface-3);
  color: #b8c5de;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font: 500 0.72rem "IBM Plex Mono", monospace;
}

.section-title {
  font-size: 0.85rem;
  font-weight: 600;
}

.btn {
  border: 1px solid #3a5f9a;
  border-radius: 9px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #f2f7ff;
  padding: 0.45rem 0.75rem;
  font: 600 0.78rem "IBM Plex Sans", sans-serif;
  cursor: pointer;
}

.btn:hover {
  filter: brightness(1.05);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: none;
}

.btn--ghost {
  border-color: var(--stroke-2);
  background: #141927;
  color: #c3cee0;
}

.compose-btn {
  width: 100%;
  font-size: 0.81rem;
}

.mailbox-list,
.inbox-list {
  min-height: 0;
  overflow: auto;
  overflow-x: hidden;
  display: grid;
  gap: 0.38rem;
  align-content: start;
}

.mailbox-item {
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background: #121824;
  padding: 0.46rem;
  cursor: pointer;
}

.mailbox-item:hover {
  border-color: #3f4f69;
}

.mailbox-item.active {
  border-color: #537dc5;
  background: #152033;
  box-shadow: inset 0 0 0 1px rgba(83, 125, 197, 0.25);
}

.mailbox-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.35rem;
  min-width: 0;
}

.mailbox-email {
  font: 500 0.72rem "IBM Plex Mono", monospace;
  flex: 1;
  min-width: 0;
  /* show more of the address without breaking layout */
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.mailbox-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.count-badge {
  min-width: 1.25rem;
  text-align: center;
  border-radius: 999px;
  padding: 0.06rem 0.38rem;
  font: 600 0.68rem "IBM Plex Mono", monospace;
  color: #11151d;
  background: #9fc2ff;
}

.copy-btn {
  border: 1px solid var(--stroke-2);
  border-radius: 6px;
  background: #181f2d;
  color: #c5d0e4;
  padding: 0.16rem 0.4rem;
  font-size: 0.67rem;
  cursor: pointer;
}

.copy-btn:hover {
  border-color: #4a5a77;
}

.delete-btn {
  border: 1px solid rgba(255, 94, 94, 0.35);
  border-radius: 6px;
  background: rgba(255, 94, 94, 0.08);
  color: #ffb8b8;
  padding: 0.16rem 0.4rem;
  font-size: 0.67rem;
  cursor: pointer;
}

.delete-btn:hover {
  border-color: rgba(255, 94, 94, 0.7);
  background: rgba(255, 94, 94, 0.12);
}

.mailbox-meta {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
}

.inbox-panel,
.viewer-panel {
  padding: 0.5rem;
  display: grid;
  gap: 0.45rem;
  min-height: 0;
}

.inbox-panel {
  grid-template-rows: auto auto auto 1fr;
}

.inbox-head,
.viewer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.filter-btn {
  border: 1px solid var(--stroke-2);
  border-radius: 999px;
  background: #161d2a;
  color: #b9c4d7;
  padding: 0.18rem 0.56rem;
  font: 500 0.72rem "IBM Plex Sans", sans-serif;
  cursor: pointer;
}

.filter-btn:hover {
  border-color: #4a607f;
}

.filter-btn.active {
  color: #e7f0ff;
  border-color: #5686d8;
  background: #234274;
}

.empty-state {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.empty-state p {
  margin: 0.2rem 0;
}

.open-link {
  color: #8fb7ff;
  text-decoration: none;
  border-bottom: 1px dashed #4f6c97;
}

.open-link:hover {
  color: #b7d0ff;
}
.inbox-item {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 0.5rem;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background: #121824;
  padding: 0.44rem;
  cursor: pointer;
}

.inbox-item:hover {
  border-color: #495976;
}

.inbox-item.active {
  border-color: #5d88cf;
  background: #162134;
}

.inbox-item.is-unread {
  border-left: 3px solid #6fa0ff;
  padding-left: calc(0.44rem - 2px);
}

.inbox-item.is-read {
  opacity: 0.9;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #22324a;
  border: 1px solid #39537a;
  display: grid;
  place-items: center;
  font: 600 0.67rem "IBM Plex Mono", monospace;
  color: #c7dbff;
}

.inbox-main {
  min-width: 0;
}

.inbox-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.from {
  font-size: 0.76rem;
  font-weight: 600;
}

.inbox-row-right {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.69rem;
}

.tiny-badge {
  border: 1px solid #5c7295;
  color: #a8c1eb;
  border-radius: 4px;
  padding: 0 0.24rem;
  font: 600 0.58rem "IBM Plex Mono", monospace;
}

.icon-btn {
  border: 1px solid transparent;
  background: transparent;
  color: #9ca8be;
  font-size: 0.82rem;
  line-height: 1;
  border-radius: 6px;
  padding: 0.08rem 0.2rem;
  cursor: pointer;
}

.icon-btn:hover {
  border-color: var(--stroke-2);
  color: #d3def1;
}

.star-btn.active {
  color: var(--warning);
}

.subject {
  margin: 0.2rem 0 0;
  font-size: 0.76rem;
  font-weight: 600;
  color: #dbe4f3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.snippet {
  margin: 0.14rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-panel {
  grid-template-rows: auto minmax(0, 1fr);
}

.viewer-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.message-view {
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background: #0f141d;
  padding: 0.58rem;
  min-height: 0;
  height: 100%;
  overflow: auto;
  overflow-x: hidden;
  word-break: break-word;
  font-size: 0.77rem;
}

.message-view img,
.message-view video,
.message-view iframe {
  max-width: 100%;
}

.open-head h4 {
  font-size: 0.94rem;
  margin-bottom: 0.25rem;
}

.message-meta {
  margin: 0.1rem 0 0;
  font-size: 0.72rem;
}

.view-modes {
  margin-top: 0.46rem;
  display: flex;
  gap: 0.3rem;
}

.mode-btn {
  border: 1px solid var(--stroke-2);
  border-radius: 7px;
  background: #161d2b;
  color: #b6c3da;
  padding: 0.2rem 0.52rem;
  font: 500 0.72rem "IBM Plex Sans", sans-serif;
  cursor: pointer;
}

.mode-btn.active {
  border-color: #5b87cf;
  color: #e7f0ff;
  background: #244173;
}

.open-body {
  margin-top: 0.42rem;
}

.open-text {
  margin: 0;
  font: 500 0.74rem/1.45 "IBM Plex Mono", monospace;
  color: #d7dfef;
  background: #0b1018;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  padding: 0.5rem;
  white-space: pre-wrap;
}

.hidden {
  display: none !important;
}

.html-wrap {
  border: 1px solid var(--stroke);
  border-radius: 8px;
  overflow: visible;
}

.html-frame {
  width: 100%;
  height: 120px;
  border: 0;
  background: #0f141c;
}

.attachments,
.image-preview {
  margin-top: 0.48rem;
}

.attachments h5,
.image-preview h5 {
  font-size: 0.76rem;
  color: #c8d4ea;
  margin-bottom: 0.3rem;
}

.attachment-list {
  display: grid;
  gap: 0.28rem;
}

.attachment-item {
  border: 1px solid var(--stroke);
  border-radius: 7px;
  background: #111826;
  padding: 0.38rem;
}

.attachment-item strong {
  display: block;
  font-size: 0.73rem;
}

.attachment-item p {
  margin: 0.12rem 0 0;
  color: var(--muted);
  font-size: 0.69rem;
}

.attachment-item a {
  display: inline-block;
  margin-top: 0.2rem;
  color: #8fb7ff;
  font-size: 0.71rem;
  text-decoration: none;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.34rem;
}

.image-grid a {
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background: #121a2a;
  overflow: hidden;
  display: block;
}

.image-grid img {
  width: 100%;
  height: 96px;
  object-fit: cover;
  display: block;
}

.reveal {
  animation: fadeIn 0.26s ease both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1250px) {
  .mail__grid {
    grid-template-columns: minmax(300px, 360px) 1fr;
    grid-template-rows: minmax(260px, 50%) 1fr;
  }

  .sidebar {
    grid-row: 1 / span 2;
  }

  .viewer-panel {
    grid-column: 2;
  }
}

@media (max-width: 920px) {
  .topbar {
    height: auto;
    flex: 0 0 auto;
    padding: 0.55rem;
    flex-direction: column;
    align-items: stretch;
  }

  .brand {
    min-width: auto;
  }

  .topbar__tools {
    width: 100%;
    flex-direction: column;
  }

  .topbar__tools .btn {
    width: 100%;
  }

  .page {
    height: auto;
    padding: 0.45rem;
    overflow: visible;
  }

  .mail__grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }

  .sidebar {
    grid-row: auto;
  }

  .inbox-panel {
    min-height: 250px;
  }

  .viewer-head {
    flex-direction: column;
    align-items: stretch;
  }

  .viewer-actions .btn {
    width: 100%;
  }
}

/* Scrollbars (match design, prevent "default" fat bars) */
* {
  scrollbar-width: thin;
  scrollbar-color: #2a3243 rgba(10, 12, 16, 0.2);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: rgba(10, 12, 16, 0.2);
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #2a3243, #1c2230);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #33405a, #20283a);
}
