:root {
  --bg: #0b0d16;
  --panel: #121625;
  --panel-2: #191d2f;
  --line: #2a2e45;
  --muted: #99a2c7;
  --text: #f2f4ff;
  --accent: #6957ff;
  --accent-2: #8a72ff;
  --danger: #ff5e8c;
  --ok: #2fd39a;
  --radius: 16px;
  --neon-a: #8a5dff;
  --neon-b: #56c3ff;
  --neon-c: #ff63de;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(circle at top right, #1d2142, var(--bg) 42%);
  color: var(--text);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 15% -10%, rgba(138, 93, 255, 0.3), transparent 40%),
    radial-gradient(ellipse at 90% 20%, rgba(86, 195, 255, 0.2), transparent 38%),
    radial-gradient(ellipse at 50% 110%, rgba(255, 99, 222, 0.16), transparent 44%);
  z-index: 0;
}

.app-shell,
.toast,
.mail-alert {
  position: relative;
  z-index: 1;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: rgba(10, 13, 25, 0.95);
  border-right: 1px solid var(--line);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: inset -1px 0 0 rgba(130, 120, 255, 0.26), 10px 0 32px rgba(10, 12, 25, 0.35);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--accent), #3a2cc9);
  font-size: 18px;
  box-shadow: 0 0 20px rgba(118, 94, 255, 0.55);
}

.brand h1 {
  margin: 0;
  font-size: 17px;
}

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

.compose-btn {
  border: 0;
  background: linear-gradient(145deg, var(--accent), #4a3fd8);
  color: #fff;
  border-radius: 12px;
  height: 48px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(78, 68, 212, 0.45);
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.menu-item {
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.menu-item:hover {
  border-color: var(--line);
  background: rgba(130, 120, 255, 0.1);
}

.menu-item.active {
  background: rgba(133, 113, 255, 0.18);
  border-color: rgba(133, 113, 255, 0.35);
  box-shadow: inset 0 0 0 1px rgba(138, 114, 255, 0.25), 0 0 18px rgba(120, 99, 255, 0.18);
}

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 22px;
  border-radius: 999px;
  background: rgba(167, 154, 255, 0.25);
  font-size: 12px;
  padding: 0 8px;
}

.status-card {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: rgba(20, 25, 40, 0.8);
  box-shadow: 0 0 0 1px rgba(123, 101, 255, 0.2), 0 0 24px rgba(86, 195, 255, 0.08);
}

.status-title {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

#sync-status {
  margin: 0;
  font-size: 13px;
}

#sync-time {
  color: var(--muted);
  font-size: 11px;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: 74px 1fr;
}

.topbar {
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: rgba(12, 16, 30, 0.7);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 -1px 0 rgba(123, 101, 255, 0.26);
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(125, 107, 255, 0.18);
}

.sound-toggle.off {
  opacity: 0.6;
  filter: grayscale(0.35);
}

#sidebar-toggle {
  display: none;
}

.search-wrap {
  flex: 1;
}

.search-wrap input {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(24, 29, 44, 0.88);
  color: var(--text);
  padding: 0 14px;
}

.search-wrap input:focus {
  outline: 2px solid rgba(138, 114, 255, 0.45);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(118, 94, 255, 0.16), 0 0 22px rgba(86, 195, 255, 0.12);
}

.top-actions {
  display: flex;
  gap: 8px;
}

.pill-btn {
  border: 1px solid var(--line);
  background: rgba(23, 28, 42, 0.85);
  color: var(--text);
  border-radius: 999px;
  height: 40px;
  padding: 0 16px;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(130, 120, 255, 0.2);
}

.content-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
}

.mail-list,
.mail-viewer {
  min-height: 0;
}

.mail-list {
  border-right: 1px solid var(--line);
  display: grid;
  grid-template-rows: auto 1fr;
  background: linear-gradient(180deg, rgba(15, 19, 35, 0.9), rgba(9, 12, 23, 0.94));
}

.section-head {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.section-head h2 {
  margin: 0;
  font-size: 28px;
}

.section-head span {
  color: var(--muted);
  font-size: 12px;
}

.mail-list-items {
  overflow: auto;
}

.mail-item {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.mail-item:hover {
  background: rgba(127, 111, 255, 0.08);
}

.mail-item.active {
  background: rgba(127, 111, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(134, 114, 255, 0.35), 0 0 18px rgba(120, 95, 255, 0.18);
}

.mail-top {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 6px;
}

.mail-from {
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.mail-subject {
  font-size: 13px;
  line-height: 1.3;
  color: #d6daf2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-item.unseen .mail-from,
.mail-item.unseen .mail-subject {
  color: #ffffff;
  font-weight: 700;
}

.mail-viewer {
  background: rgba(10, 13, 25, 0.35);
  padding: 16px;
  background:
    radial-gradient(circle at 80% 0%, rgba(70, 100, 255, 0.13), transparent 40%),
    rgba(10, 13, 25, 0.35);
}

.viewer-empty {
  height: 100%;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  background: rgba(14, 18, 31, 0.45);
}

.mail-view {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
}

.mail-meta {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(18, 23, 35, 0.88);
  padding: 12px;
  position: relative;
  box-shadow: 0 0 0 1px rgba(122, 102, 255, 0.2), 0 0 24px rgba(86, 195, 255, 0.06);
}

.mail-meta h3 {
  margin: 0 0 10px;
  font-size: 20px;
  line-height: 1.3;
}

.mail-meta p {
  margin: 2px 0;
  color: #d8ddfb;
  font-size: 13px;
}

.mobile-back {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
}

#mail-frame {
  width: 100%;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.hidden {
  display: none;
}

.readonly-action {
  position: relative;
}

.readonly-action::after {
  content: 'RO';
  position: absolute;
  top: -7px;
  right: -6px;
  font-size: 10px;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  padding: 2px 6px;
  pointer-events: none;
}

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(12, 15, 26, 0.95);
  color: var(--text);
  padding: 10px 16px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(138, 114, 255, 0.22);
}

.mail-alert {
  position: fixed;
  right: 14px;
  top: 14px;
  border: 1px solid rgba(138, 114, 255, 0.45);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(25, 31, 53, 0.95), rgba(18, 22, 39, 0.96));
  color: #f4f7ff;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35), 0 0 26px rgba(118, 94, 255, 0.25);
  transform: translateY(-14px);
  opacity: 0;
  pointer-events: none;
  transition: 0.24s ease;
  max-width: min(86vw, 310px);
  z-index: 60;
}

.mail-alert.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@keyframes pulseGlow {
  0% {
    box-shadow: 0 0 0 0 rgba(138, 114, 255, 0.45);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(138, 114, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(138, 114, 255, 0);
  }
}

@media (max-width: 1180px) {
  .content-grid {
    grid-template-columns: minmax(280px, 380px) 1fr;
  }

  .top-actions {
    display: none;
  }
}

@media (max-width: 980px) {
  body {
    background:
      radial-gradient(circle at 85% -10%, rgba(106, 78, 255, 0.44), transparent 35%),
      radial-gradient(circle at 10% 15%, rgba(86, 195, 255, 0.22), transparent 35%),
      radial-gradient(circle at 50% 110%, rgba(255, 99, 222, 0.18), transparent 44%),
      #090b17;
  }

  .app-shell {
    grid-template-columns: 1fr;
    border: 0;
    border-radius: 0;
    margin: 0;
    min-height: 100dvh;
    overflow: hidden;
    box-shadow: none;
  }

  .sidebar {
    position: fixed;
    z-index: 30;
    inset: 0 auto 0 0;
    width: min(86vw, 320px);
    transform: translateX(-101%);
    transition: transform 0.2s ease;
    border-right: 1px solid rgba(138, 114, 255, 0.35);
    background:
      radial-gradient(circle at 20% 0%, rgba(104, 78, 255, 0.26), transparent 38%),
      rgba(9, 12, 24, 0.96);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  #sidebar-toggle {
    display: inline-grid;
    place-items: center;
  }

  .content-grid {
    grid-template-columns: 1fr;
    gap: 0;
    min-height: 0;
  }

  .mail-list {
    border-right: 0;
    border: 0;
    border-radius: 0;
    margin: 0;
    overflow: hidden;
    background:
      radial-gradient(circle at 80% 0%, rgba(86, 195, 255, 0.12), transparent 30%),
      linear-gradient(180deg, rgba(15, 20, 38, 0.96), rgba(8, 11, 22, 0.98));
    box-shadow: none;
  }

  .mail-viewer {
    padding: 0;
    margin: 0;
    border-radius: 0;
    border: 0;
    background:
      radial-gradient(circle at 20% 0%, rgba(255, 99, 222, 0.13), transparent 34%),
      linear-gradient(180deg, rgba(14, 19, 35, 0.94), rgba(8, 10, 20, 0.98));
    box-shadow: none;
  }

  .mail-viewer.mobile-hidden {
    display: none;
  }

  .mail-list.mobile-hidden {
    display: none;
  }

  .mobile-back {
    display: inline-grid;
    place-items: center;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 25;
    padding: 10px 12px;
    gap: 8px;
    background:
      linear-gradient(120deg, rgba(16, 20, 38, 0.94), rgba(24, 18, 45, 0.9));
    box-shadow: inset 0 -1px 0 rgba(126, 106, 255, 0.3), 0 4px 16px rgba(31, 20, 62, 0.35);
  }

  .top-actions {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .top-actions::-webkit-scrollbar {
    display: none;
  }

  .pill-btn {
    height: 34px;
    padding: 0 12px;
    font-size: 12px;
    white-space: nowrap;
  }

  .mail-meta {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  #mail-frame {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .status-card {
    border-color: rgba(138, 114, 255, 0.35);
    background: linear-gradient(145deg, rgba(27, 34, 57, 0.95), rgba(18, 22, 36, 0.92));
  }

  .compose-btn {
    animation: pulseGlow 2.8s infinite;
  }
}

@media (max-width: 560px) {
  .workspace {
    grid-template-rows: 68px 1fr;
    min-height: 100dvh;
  }

  .topbar {
    padding: 10px;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 25;
    background:
      linear-gradient(120deg, rgba(16, 20, 38, 0.92), rgba(24, 18, 45, 0.88));
    backdrop-filter: blur(10px);
    box-shadow: inset 0 -1px 0 rgba(126, 106, 255, 0.3), 0 4px 16px rgba(31, 20, 62, 0.35);
  }

  .icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 11px;
  }

  .search-wrap input {
    height: 40px;
    border-radius: 11px;
    font-size: 15px;
  }

  .section-head {
    padding-top: 12px;
    padding-bottom: 12px;
    padding-left: 12px;
    padding-right: 12px;
    background: linear-gradient(90deg, rgba(100, 75, 255, 0.16), rgba(86, 195, 255, 0.06));
  }

  .mail-item {
    padding-left: 12px;
    padding-right: 12px;
  }

  .section-head h2 {
    font-size: 24px;
  }

  .mail-item {
    padding-top: 11px;
    padding-bottom: 11px;
    border-bottom-color: rgba(126, 106, 255, 0.28);
  }

  .mail-from {
    font-size: 14px;
  }

  .mail-subject {
    font-size: 14px;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    color: #dbdef3;
  }

  .mail-meta {
    padding: 12px;
    background: linear-gradient(145deg, rgba(24, 30, 53, 0.92), rgba(13, 17, 30, 0.95));
  }

  .mail-meta h3 {
    font-size: 18px;
    padding-right: 42px;
  }

  #mail-frame {
    min-height: calc(100dvh - 250px);
  }

  .viewer-empty h3 {
    font-size: 24px;
  }

  .viewer-empty p {
    font-size: 14px;
    line-height: 1.45;
    max-width: 90%;
  }

  .toast {
    width: calc(100% - 24px);
    border-radius: 14px;
    text-align: center;
    font-size: 12px;
  }

  .mail-alert {
    left: 50%;
    right: auto;
    top: 10px;
    transform: translateX(-50%) translateY(-14px);
    width: calc(100% - 20px);
    max-width: 420px;
    border-radius: 14px;
    text-align: center;
    font-size: 12px;
  }

  .mail-alert.show {
    transform: translateX(-50%) translateY(0);
  }
}

