:root {
  --border: #e0e0e0;
  --hover: #f2f2f2;
  --selected: #d3e3fd;
  --selected-text: #001d35;
  --text: #202124;
  --text-secondary: #5f6368;
  --blue: #1a73e8;
  --green: #3a7a48;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Google Sans", Roboto, Arial, sans-serif;
  color: var(--text);
  background: #fff;
  -webkit-font-smoothing: antialiased;
}

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
  font-size: 20px;
  line-height: 1;
  user-select: none;
}

button { font-family: inherit; border: none; background: none; cursor: pointer; color: inherit; }
input, textarea { font-family: inherit; }
a { color: inherit; }

#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== Top bar ===== */
.topbar {
  height: 64px;
  min-height: 64px;
  display: flex;
  align-items: center;
  padding: 0 8px 0 4px;
  gap: 4px;
}

.topbar-left { display: flex; align-items: center; gap: 8px; padding-left: 8px; min-width: 200px; }

.logo { display: flex; align-items: center; gap: 6px; }
.logo-text { font-size: 22px; color: #5f6368; letter-spacing: -0.5px; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex: none;
}
.icon-btn:hover { background: var(--hover); }

.topbar-search {
  flex: 1;
  max-width: 720px;
  height: 48px;
  background: #eaf1fb;
  border-radius: 8px;
  display: flex;
  align-items: center;
  padding: 0 8px 0 20px;
  margin: 0 20px;
}
.topbar-search:focus-within { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.search-icon { color: var(--text-secondary); margin-right: 12px; }
.topbar-search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  color: var(--text);
}

.topbar-right { display: flex; align-items: center; gap: 2px; flex: none; margin-left: auto; }
.gemini-spark { color: #4285f4; }

.avatar-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg,#4285f4,#34a853);
  color: #fff;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
}

/* ===== Body layout ===== */
.body-wrap { flex: 1; display: flex; min-height: 0; }

/* ===== Sidebar ===== */
.sidebar {
  width: 256px;
  min-width: 256px;
  padding: 8px 8px 0 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.compose-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #c2e7ff;
  color: #001d35;
  font-weight: 500;
  font-size: 14px;
  border-radius: 16px;
  padding: 16px 24px 16px 16px;
  margin: 8px 8px 20px 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  width: fit-content;
}
.compose-btn:hover { box-shadow: 0 1px 3px 1px rgba(60,64,67,.3); }

.nav-list, .labels-section { display: flex; flex-direction: column; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 32px;
  padding: 0 8px 0 24px;
  border-radius: 0 16px 16px 0;
  font-size: 14px;
  color: var(--text);
  cursor: default;
  position: relative;
}
.nav-item.active {
  background: var(--selected);
  color: var(--selected-text);
  font-weight: 700;
}
.nav-item.active .material-symbols-outlined { color: var(--selected-text); font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 20; }

.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { font-size: 12px; color: var(--text-secondary); }
.nav-item.active .nav-count { color: var(--selected-text); font-weight: 700; }

.nav-more { color: var(--text-secondary); }
.chevron { font-size: 18px; transition: transform .15s; }
.chevron.collapsed { transform: rotate(-90deg); }

/* ===== Main ===== */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #fff; position: relative; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 48px;
  min-height: 48px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}
.toolbar .spacer { flex: 1; }
.toolbar .page-range { font-size: 12px; color: var(--text-secondary); margin-right: 8px; white-space: nowrap; }
.toolbar .divider { width: 1px; height: 24px; background: var(--border); margin: 0 8px; }

/* ===== Detail view ===== */
.detail-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.detail-scroll { flex: 1; overflow-y: auto; padding: 0 20px 20px 20px; }

.subject {
  font-size: 22px;
  font-weight: 400;
  padding: 20px 0 8px 0;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}
.chip {
  font-size: 12px;
  font-weight: 400;
  background: #f1f3f4;
  color: var(--text-secondary);
  border-radius: 4px;
  padding: 4px 6px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.chip-x { font-size: 14px; }

.sender-row { display: flex; align-items: flex-start; gap: 14px; padding: 12px 0; }
.sender-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: #7baaf7; color: #fff; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex: none; font-size: 16px;
}
.sender-meta { display: flex; flex-direction: column; margin-right: auto; }
.sender-name { font-size: 14px; font-weight: 700; }
.sender-to { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; cursor: pointer; }
.chevron-inline { font-size: 16px; }
.sender-time { font-size: 12px; color: var(--text-secondary); white-space: nowrap; margin-right: 8px; align-self: center; }
.star-btn.starred .material-symbols-outlined { color: #f2b400; font-variation-settings: 'FILL' 1; }

.email-body-wrap { background: #e2e8f0; border-radius: 10px; padding: 24px 0; margin-top: 8px; }

.email-card {
  width: 680px;
  max-width: calc(100% - 32px);
  margin: 0 auto;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
}

.email-header-block { padding: 24px 20px; text-align: center; border-bottom: 1px solid #e2e8f0; }
.brand-logo { display: block; max-height: 48px; max-width: 220px; margin: 0 auto 12px auto; }
.brand-name { color: #3a7a48; font-size: 20px; font-weight: 700; letter-spacing: 1px; }

.email-intro { padding: 24px 20px 0 20px; }
.intro-title { color: #1e293b; font-size: 14px; font-weight: 700; margin: 0 0 6px 0; }
.intro-text { color: #475569; font-size: 13px; line-height: 1.7; margin: 0 0 20px 0; }

.deal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
  padding: 0 20px 8px 20px;
}

.deal-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  margin-bottom: 16px;
  overflow: hidden;
}
.deal-img { width: 100%; height: 150px; object-fit: cover; display: block; background: #ddd; }
.deal-body { padding: 14px 16px 0 16px; }
.deal-top-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.deal-location { color: #425e6c; font-size: 12px; font-weight: 600; }
.deal-provider { height: 16px; opacity: .7; font-size: 11px; font-weight: 700; color: #7a8a94; }
.deal-title {
  color: #283941; font-size: 14px; font-weight: 700; line-height: 1.3;
  min-height: 37px; max-height: 37px; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  margin-bottom: 10px;
}
.deal-meta-row {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 10px; border-top: 1px solid #e2e8f0;
}
.deal-rating { color: #283941; font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.deal-rating .count { color: #7a8a94; font-weight: 400; }
.deal-price { color: #1e293b; font-size: 15px; font-weight: 700; }
.deal-cta { padding: 16px; }
.deal-cta a {
  display: block; background: var(--green); border-radius: 999px;
  color: #fff; font-size: 13px; font-weight: 700; text-decoration: none;
  text-align: center; padding: 12px 0;
}
.deal-cta a:hover { background: #2f6339; }

.explore-more { padding: 8px 20px 32px 20px; text-align: center; }
.explore-btn {
  display: inline-block; background: #fff; border: 2px solid var(--green);
  border-radius: 999px; color: var(--green); font-size: 13px; font-weight: 700;
  text-decoration: none; padding: 12px 28px;
}
.explore-btn:hover { background: #f0f7f1; }

.email-hr { border-top: 1px solid #e2e8f0; margin: 0 20px; }
.email-footer { background: #f8fafc; padding: 24px 20px; text-align: center; }
.email-footer p { color: #64748b; font-size: 12px; margin: 0 0 6px 0; }
.email-footer a { color: #0ea5e9; text-decoration: none; }
.email-footer .copyright { color: #94a3b8; font-size: 11px; margin: 0; }

/* ===== Reply bar / box ===== */
.reply-bar { display: flex; gap: 12px; padding: 20px 0 8px 0; }
.reply-pill {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 20px;
  padding: 10px 20px; font-size: 14px; font-weight: 500; color: var(--text-secondary);
}
.reply-pill:hover { background: var(--hover); border-color: #d0d0d0; }

.reply-box {
  border: 1px solid var(--border); border-radius: 8px; margin-top: 12px;
  padding: 12px; display: flex; flex-direction: column; gap: 8px;
}
.reply-box-to { font-size: 13px; color: var(--text-secondary); }
.reply-box textarea {
  min-height: 120px; border: none; outline: none; resize: vertical; font-size: 14px;
}
.reply-box-actions { display: flex; align-items: center; gap: 8px; }
.send-btn {
  background: var(--blue); color: #fff; font-size: 14px; font-weight: 500;
  border-radius: 18px; padding: 10px 24px;
}
.send-btn:hover { background: #1765cc; }

/* ===== Side rail ===== */
.side-rail {
  width: 48px; flex: none; display: flex; flex-direction: column;
  align-items: center; gap: 20px; padding-top: 16px; border-left: 1px solid var(--border);
}
.rail-btn { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--text-secondary); }
.rail-btn:hover { background: var(--hover); }
.rail-count { font-size: 13px; font-weight: 700; color: #b06000; background: #fef7e0; border-radius: 50%; }

/* ===== Compose modal ===== */
.compose-modal {
  position: fixed; bottom: 0; right: 80px; width: 460px; height: 500px;
  background: #fff; border-radius: 8px 8px 0 0;
  box-shadow: 0 -2px 10px rgba(0,0,0,.3);
  display: flex; flex-direction: column; overflow: hidden; z-index: 100;
}
.compose-header {
  background: #f2f6fc; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between;
  font-size: 14px; font-weight: 500; cursor: default;
}
.compose-header-actions { display: flex; gap: 4px; }
.compose-header .icon-btn, .compose-header-actions .icon-btn { width: 28px; height: 28px; }
.compose-fields { flex: 1; display: flex; flex-direction: column; padding: 0 16px; overflow-y: auto; }
.compose-fields input { border: none; border-bottom: 1px solid var(--border); padding: 12px 0; outline: none; font-size: 14px; }
.compose-fields textarea { flex: 1; border: none; outline: none; resize: none; padding: 16px 0; font-size: 14px; min-height: 200px; }
.compose-footer { display: flex; align-items: center; gap: 8px; padding: 12px 16px; }

/* ===== Scrollbars ===== */
.detail-scroll::-webkit-scrollbar, .sidebar::-webkit-scrollbar { width: 12px; }
.detail-scroll::-webkit-scrollbar-thumb, .sidebar::-webkit-scrollbar-thumb {
  background-color: #dadce0; border-radius: 8px; border: 3px solid #fff;
}
.detail-scroll::-webkit-scrollbar-thumb:hover { background-color: #bdc1c6; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .sidebar { width: 72px; min-width: 72px; }
  .nav-label, .nav-count, .compose-label { display: none; }
  .compose-btn { padding: 16px; }
  .deal-grid { grid-template-columns: 1fr; }
  .topbar-search { margin: 0 8px; }
}
