:root {
  --bg: #f6f8fc;
  --card: #ffffff;
  --line: #dde3ea;
  --text: #202124;
  --muted: #5f6368;
  --accent: #0b57d0;
  --shadow: 0 10px 26px rgba(13, 37, 62, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Roboto', sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top right, #e8f0fe, var(--bg) 38%), var(--bg);
}

h1,
h2,
h3,
h4,
h5,
h6,
button {
  font-family: 'Google Sans', sans-serif;
}

.app-shell {
  min-height: 100vh;
  padding: clamp(8px, 1.4vw, 16px);
}

.topbar {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}

.logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #ea4335, #fbbc04);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.title-wrap h1 {
  margin: 0;
  font-size: 22px;
}

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

.topbar-right {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--muted);
  background: #fff;
}

.layout {
  margin-top: 12px;
  height: calc(100vh - 102px);
  min-height: 560px;
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(300px, 400px) minmax(420px, 1fr);
  grid-template-areas: 'sidebar list view';
  gap: 12px;
}

.layout.hide-view {
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  grid-template-areas: 'sidebar list';
}

.sidebar,
.message-list-wrap,
.message-view {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  min-height: 0;
}

.sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  overflow: auto;
}

.sidebar-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-head h2 {
  margin: 0;
  font-size: 16px;
}

.compose {
  width: 100%;
  border: none;
  border-radius: 12px;
  background: #c2e7ff;
  color: #001d35;
  font-weight: 700;
  padding: 10px;
  cursor: pointer;
}

.credential-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.credential-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.cred-main {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 7px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.inbox-label {
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.credential-item.active .cred-main {
  background: #eef4ff;
  border-color: #c8dafd;
}

.unread-pill {
  margin-left: auto;
  min-width: 24px;
  height: 20px;
  border-radius: 999px;
  padding: 0 7px;
  background: #0b57d0;
  color: #fff;
  font-size: 11px;
  display: grid;
  place-items: center;
}

.copy-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 5px 9px;
  font-size: 11px;
  cursor: pointer;
}

.message-list-wrap {
  grid-area: list;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-head {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-head h2 {
  margin: 0;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-head .copy-btn {
  margin-left: auto;
}

.message-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  display: grid;
  gap: 7px;
  overflow: auto;
}

.message-item {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  background: #fff;
  display: grid;
  gap: 4px;
  max-height: 94px;
  overflow: hidden;
}

.message-item:hover,
.message-item.active {
  border-color: var(--line);
  background: #f4f8ff;
}

.line {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line.from {
  font-size: 12px;
  font-weight: 700;
}

.line.subject {
  font-size: 13px;
}

.line.meta {
  margin-top: auto;
  color: var(--muted);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0b57d0;
  display: inline-block;
}

.message-view {
  grid-area: view;
  padding: 16px;
  overflow: auto;
}

.layout.hide-view .message-view {
  display: none;
}

.empty-state {
  color: var(--muted);
  display: grid;
  place-items: center;
  height: 100%;
}

.site-badge {
  color: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mail-subject {
  margin: 0;
  font-size: clamp(19px, 2.3vw, 24px);
}

.mail-details {
  margin-top: 12px;
}

.mail-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
}

.mail-meta {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.mail-content {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  word-break: break-word;
}

.mail-frame {
  width: 100%;
  min-height: 300px;
  max-height: 62vh;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

pre.mail-text {
  font-family: inherit;
  white-space: pre-wrap;
  margin: 0;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(20, 29, 43, 0.42);
  z-index: 20;
  padding: 12px;
}

.modal.open {
  display: grid;
}

.modal-card {
  width: min(460px, 100%);
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
  padding: 14px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.modal-head h3 {
  margin: 0;
  font-size: 16px;
}

.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  cursor: pointer;
}

.site-auto-create {
  width: 100%;
  border: 1px solid #bcd3fb;
  border-radius: 10px;
  background: #e8f0fe;
  color: #07306f;
  font-weight: 700;
  padding: 9px;
  margin-bottom: 10px;
  cursor: pointer;
}

.site-form {
  display: grid;
  gap: 8px;
}

.site-form input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  font-size: 13px;
}

.site-submit {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 9px;
  font-weight: 700;
  cursor: pointer;
}

.site-form-msg {
  min-height: 16px;
  margin: 9px 0 0 0;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 980px) {
  .layout {
    height: auto;
    min-height: 0;
    grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
    grid-template-areas:
      'sidebar view'
      'list view';
  }

  .layout.hide-view {
    grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
    grid-template-areas:
      'sidebar list'
      'sidebar list';
  }

  .message-list-wrap {
    max-height: 40vh;
  }
}

@media (max-width: 760px) {
  .topbar {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .topbar-right {
    margin-left: 0;
  }

  .layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      'sidebar'
      'list'
      'view';
  }

  .layout.hide-view {
    grid-template-columns: 1fr;
    grid-template-areas:
      'sidebar'
      'list';
  }

  .message-list-wrap {
    max-height: 36vh;
  }

  .message-view {
    min-height: 42vh;
  }

  .mail-header {
    flex-wrap: wrap;
  }
}

@media (max-width: 520px) {
  .credential-item {
    grid-template-columns: 1fr;
  }

  .copy-btn {
    width: 100%;
  }
}
