:root {
  --bg: #09090b;
  --bg-elevated: #121214;
  --surface: #18181b;
  --surface-hover: #27272a;
  --border: #27272a;
  --border-subtle: #1f1f23;
  --text: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-muted: rgba(99, 102, 241, 0.12);
  --accent-glow: rgba(99, 102, 241, 0.25);
  --success: #22c55e;
  --success-muted: rgba(34, 197, 94, 0.12);
  --warning: #f59e0b;
  --warning-muted: rgba(245, 158, 11, 0.12);
  --error: #ef4444;
  --error-muted: rgba(239, 68, 68, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 4px 20px rgba(0,0,0,.25);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.35);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-elevated) 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width .25s ease;
  flex-shrink: 0;
  position: relative;
}

.sidebar.collapsed {
  width: 64px;
}

.sidebar.collapsed .logo,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-datetime,
.sidebar.collapsed .auth-form,
.sidebar.collapsed #logout-btn {
  display: none !important;
}

.sidebar.collapsed #logout-btn-icon {
  display: flex !important;
}

#logout-btn-icon {
  display: none;
  padding: 0.5rem;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

#logout-btn-icon:hover {
  color: var(--error);
  border-color: var(--error);
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 0.85rem;
}

.sidebar.collapsed .nav {
  padding: 0.5rem 0.5rem;
}


.sidebar.collapsed .sidebar-footer {
  padding: 1rem 0.5rem;
  align-items: center;
}

.sidebar.collapsed .sidebar-footer-row {
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
}

.sidebar-toggle {
  position: absolute;
  right: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all .2s;
  box-shadow: var(--shadow);
}

.sidebar-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-muted);
}

.sidebar.collapsed .sidebar-toggle {
  right: -12px;
}

.sidebar.collapsed .sidebar-toggle-icon {
  transform: rotate(180deg);
}

.sidebar-toggle-icon {
  transition: transform .25s ease;
}

.logo {
  padding: 1.75rem 1.5rem 1.25rem;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text);
  background: linear-gradient(135deg, var(--text) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0.5rem 1rem;
}

.nav-sep {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 0;
  width: 100%;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.85rem 1rem;
  border: none;
  background: none;
  text-align: left;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all .2s ease;
  position: relative;
  overflow: hidden;
}

.nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  transition: height .2s ease;
}

.nav-item:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.nav-item:hover::before {
  height: 20px;
}

.nav-item.active {
  color: var(--accent);
  background: none;
}

.nav-item.active::before {
  height: 24px;
}

.nav-icon {
  opacity: 0.9;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-icon svg {
  display: block;
}

.nav-item.active .nav-icon {
  opacity: 1;
}

.nav-label {
  flex: 1;
}

.sidebar-footer {
  margin-top: auto;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
}

.sidebar-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
}

.sidebar-datetime {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.sidebar-time,
.sidebar-date {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.sidebar-time {
  font-variant-numeric: tabular-nums;
}

.auth-forms .auth-form {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.auth-forms .auth-form input {
  padding: .6rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 13px;
}

.user-label {
  font-size: 13px;
  color: var(--text-secondary);
  display: block;
  margin-bottom: .5rem;
  font-weight: 500;
}

.btn-ghost {
  padding: .5rem 1rem;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .2s;
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--border);
}

/* Main content */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-elevated) 100%);
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 2rem 2.5rem;
  min-height: 0;
  overflow: hidden;
}

#dashboard {
  align-items: stretch;
}

#inbox-view {
  width: 100%;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

#inbox-view .toolbar,
#inbox-view .email-pane { width: 100%; }

#domains-view,
#addresses-view,
#instructions-view {
  overflow-y: auto;
}

#domains-view .page-header,
#addresses-view .page-header,
#instructions-view .page-header {
  width: 100%;
}

/* Instructions tab */
.instructions-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex: 1;
}

.instructions-card h3 {
  margin: 0 0 0.75rem 0;
}

.instructions-card p {
  margin: 0 0 0.75rem 0;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.instructions-card p:last-of-type {
  margin-bottom: 0;
}

.instructions-code-wrap {
  margin: 0.75rem 0;
  padding: 1rem 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.instructions-code-wrap code {
  font-size: 13px;
  font-family: ui-monospace, monospace;
  word-break: break-all;
  color: var(--text);
}

.instructions-hint {
  font-size: 13px !important;
  color: var(--text-muted) !important;
}

.instructions-hint code {
  font-size: 12px;
  padding: 0.15em 0.4em;
  background: var(--surface-hover);
  border-radius: 4px;
}

.instructions-steps {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

.instructions-steps li {
  margin-bottom: 0.5rem;
}

.instructions-steps code {
  font-size: 12px;
  padding: 0.15em 0.4em;
  background: var(--surface-hover);
  border-radius: 4px;
}

.domains-layout {
  display: grid;
  grid-template-columns: minmax(280px, 400px) 1fr;
  gap: 1.5rem;
  align-items: start;
  flex: 1;
  min-height: 0;
}


/* Addresses tab */
.addresses-page-header {
  margin-bottom: 2rem;
}

.addresses-page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.addresses-page-header .page-desc {
  margin-top: 0.5rem;
  font-size: 15px;
  color: var(--text-secondary);
}

.addresses-layout {
  display: grid;
  grid-template-columns: minmax(320px, 440px) 1fr;
  gap: 1.75rem;
  flex: 1;
  min-height: 0;
  align-items: start;
}

.addresses-layout .create-address-card {
  background: linear-gradient(160deg, rgba(99, 102, 241, 0.06) 0%, var(--surface) 50%);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(255,255,255,0.03) inset;
  position: relative;
  overflow: hidden;
}

.addresses-layout .create-address-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.4), transparent);
  opacity: 0.6;
}

.addresses-layout .create-address-card:hover {
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: var(--shadow-lg), 0 0 40px var(--accent-glow);
}

.create-address-header {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.create-address-icon {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent) 0%, #818cf8 100%);
  border-radius: var(--radius);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.create-address-icon svg {
  width: 24px;
  height: 24px;
}

.create-address-header h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0 0 0.35rem 0;
  color: var(--text);
  letter-spacing: -0.01em;
}

.create-address-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

.create-address-form .form-row input,
.create-address-form .form-row select {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: border-color .2s, box-shadow .2s;
}

.create-address-form .form-row input:focus,
.create-address-form .form-row select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.create-address-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.btn-create-address {
  width: 100%;
  padding: 0.85rem 1.5rem;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent) 0%, #818cf8 100%);
  border: none;
  box-shadow: 0 2px 10px var(--accent-glow);
  transition: transform .15s, box-shadow .2s;
}

.btn-create-address:hover {
  box-shadow: 0 4px 20px var(--accent-glow);
  transform: translateY(-1px);
}

.addresses-layout .addresses-list-card {
  flex: 1;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 1.5rem 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.addresses-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}

.addresses-list-title-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.addresses-list-title-row h3 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.addresses-list-filter {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.addresses-filter-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.addresses-list-card .domain-filter-select {
  min-width: 190px;
  height: 40px;
  border-radius: var(--radius-sm);
}

.address-list-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0 -0.25rem;
  padding: 0 0.25rem;
}

.addresses-list-card .address-list {
  flex: none;
}

.addresses-list-card .address-item {
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  border-bottom: none;
  border: 1px solid transparent;
  background: rgba(255,255,255,0.02);
  transition: all .2s ease;
}

.addresses-list-card .address-item:last-child {
  margin-bottom: 0;
}

.addresses-list-card .address-item:hover {
  background: var(--surface-hover);
  border-color: var(--border-subtle);
  transform: translateX(2px);
}

.addresses-list-card .address-item-avatar {
  width: 42px;
  height: 42px;
  font-size: 15px;
  background: linear-gradient(135deg, var(--accent) 0%, #818cf8 100%);
}

.addresses-list-title-row .count-badge {
  background: var(--accent-muted);
  color: var(--accent);
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 13px;
}

@media (max-width: 900px) {
  .addresses-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .domains-layout {
    grid-template-columns: 1fr;
  }
  .domains-layout .domains-list-card {
    grid-column: 1;
    grid-row: auto;
  }
  .addresses-list-header {
    flex-direction: column;
    align-items: stretch;
  }
  .addresses-list-filter {
    width: 100%;
  }
  .addresses-list-card .domain-filter-select {
    flex: 1;
    min-width: 0;
  }
}

/* Login landing */
#login-prompt:not(.hidden) {
  position: fixed;
  inset: 0;
  display: flex !important;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--bg) 0%, #0d0d0f 100%);
  z-index: 10;
  padding: 2rem;
}

.login-state {
  max-width: 380px;
  width: 100%;
  padding: 2.5rem;
  background: transparent;
  border: none;
  box-shadow: none;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1.25rem;
  opacity: .6;
}

.empty-state h2 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 .5rem 0;
}

.empty-state p {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.75rem;
  width: 100%;
}

.login-form input {
  padding: .875rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 14px;
  transition: border-color .2s;
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.login-form button {
  padding: .875rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
}

.login-form button:hover {
  background: var(--accent-hover);
}

.login-form button:active {
  transform: scale(0.99);
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: .75rem;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

/* Gmail-style inbox toolbar */
.inbox-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.inbox-toolbar-left {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex: 1;
  min-width: 0;
}

/* Segmented tabs */
.inbox-tabs {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  gap: 2px;
}

.inbox-tab {
  padding: 0 1rem;
  height: 34px;
  line-height: 34px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all .2s ease;
}

.inbox-tab:hover {
  color: var(--text-secondary);
  background: var(--surface-hover);
}

.inbox-tab.active {
  color: var(--text);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

.inbox-tabs-wrap,
.inbox-domain-wrap,
.inbox-search-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inbox-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.inbox-domain-wrap .gmail-select {
  min-width: 200px;
}

.inbox-search-wrap {
  flex: 1;
  min-width: 200px;
}

.inbox-search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.inbox-search-input-wrap .search {
  flex: 1;
  padding-right: 36px;
}

.inbox-search-clear {
  position: absolute;
  right: 10px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: var(--surface-hover);
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
  transition: all .2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.inbox-search-clear:hover {
  color: var(--text);
  background: var(--border);
}

.inbox-search-clear.hidden {
  display: none;
}

/* Domain select & search – unified input style */
.gmail-select {
  min-width: 200px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2371717a' d='M3 4.5L6 7.5l3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px;
}

.toolbar select,
.gmail-select,
.inbox-toolbar .search {
  height: 40px;
  padding: 0 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color .2s, background .2s, box-shadow .2s;
}

.gmail-select {
  padding: 0 36px 0 1rem;
  line-height: 38px;
}

.toolbar select:focus,
.gmail-select:focus,
.inbox-toolbar .search:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-elevated);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.inbox-toolbar .search {
  min-width: 200px;
}

.inbox-toolbar .search::placeholder {
  color: var(--text-muted);
}

/* Refresh button */
.inbox-toolbar .btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all .2s;
  flex-shrink: 0;
}

.inbox-toolbar .btn-icon:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-muted);
}

/* Email pane */
.email-pane {
  flex: 1;
  display: flex;
  gap: 1.25rem;
  min-height: 0;
  overflow: hidden;
}

.email-list-wrap {
  flex: 0 0 360px;
  min-width: 280px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Empty state: compact height only */
.email-list-wrap.empty {
  align-self: flex-start;
  max-height: none;
}

.email-list-wrap.empty .email-list {
  flex: 0 0 auto;
  min-height: 0;
  overflow: visible;
}

.email-pane:has(.email-preview.hidden) .email-list-wrap {
  flex: 1;
}

/* With emails: height fits content up to max, then scrolls */
.email-list-wrap:not(.empty) {
  align-self: flex-start;
  max-height: 100%;
  height: fit-content;
}

.email-list-wrap:not(.empty) .email-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.email-list-title {
  margin: 0;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.email-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.email-list::-webkit-scrollbar {
  width: 6px;
}

.email-list::-webkit-scrollbar-track {
  background: transparent;
}

.email-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.email-list::-webkit-scrollbar-thumb:hover {
  background: #3f3f46;
}

.email-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background .15s;
}

.email-item:hover {
  background: var(--surface-hover);
}

.email-item.active {
  background: var(--accent-muted);
}

.email-item:last-child { border-bottom: none; }

.email-item-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #818cf8 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
}

.email-item-content {
  flex: 1;
  min-width: 0;
}

.email-item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.email-item-date {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.email-item-from {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-item-subject {
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.email-item-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-email-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}


.btn-email-remove,
.btn-email-permanent {
  width: 17px;
  height: 17px;
  min-width: 17px;
  min-height: 17px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .2s;
  opacity: 0.6;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: visible;
}

.email-item:hover .btn-email-remove {
  opacity: 1;
}

.btn-email-remove:hover {
  color: var(--error);
}


.email-item:hover .btn-email-permanent {
  opacity: 1;
}

.btn-email-permanent:hover {
  color: var(--error);
}

.email-item-actions {
  flex-shrink: 0;
  align-self: center;
  display: flex;
  align-items: center;
  gap: 2px;
}

.btn-email-restore {
  width: 17px;
  height: 17px;
  min-width: 17px;
  min-height: 17px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .2s;
  opacity: 0.6;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.btn-email-restore svg {
  display: block;
}

.email-item:hover .btn-email-restore {
  opacity: 1;
}

.btn-email-restore:hover {
  color: var(--success);
}

.email-preview {
  flex: 2;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.email-preview.hidden { display: none; }

.email-read-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  background: var(--bg-elevated);
}

.email-read-header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.email-preview-date {
  font-size: 13px;
  color: var(--text-muted);
}

.btn-restore {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--success);
  background: var(--success-muted);
  color: var(--success);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .2s;
}

.btn-restore:hover {
  background: var(--success);
  color: white;
}

/* Undo toast (shown when deleting from inbox) */
.undo-toast {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 100;
}

.undo-toast-text {
  font-size: 14px;
  color: var(--text-secondary);
}

.btn-undo {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--success);
  background: var(--success-muted);
  color: var(--success);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .2s;
}

.btn-undo:hover {
  background: var(--success);
  color: white;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: .5rem .75rem;
  margin: -.25rem -.5rem;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .2s;
}

.btn-back:hover {
  color: var(--accent);
  background: var(--surface-hover);
}

.btn-back-icon {
  flex-shrink: 0;
  display: block;
}

/* Loading state */
.email-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
}

.email-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: email-spin .8s linear infinite;
}

.email-loading p {
  margin: 1rem 0 0 0;
  font-size: 14px;
}

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

.email-detail {
  padding: 0;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: auto;
  contain: layout;
  width: 100%;
}

.email-read-card {
  padding: 24px 28px;
  min-width: 0;
  overflow-wrap: break-word;
}

.email-read-header-inner {
  display: flex;
  gap: 16px;
  padding-bottom: 1.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.email-read-avatar {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #818cf8 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 600;
}

.email-read-meta {
  flex: 1;
  min-width: 0;
}

.email-read-from-row {
  margin-bottom: 6px;
}

.email-read-from {
  font-weight: 600;
  font-size: 17px;
  color: var(--text);
}

.email-read-to {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 0.75rem 0;
}

.email-read-subject {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.35;
}

.email-body-wrap {
  margin-top: 0;
  min-width: 0;
  overflow-x: auto;
  max-width: 100%;
}

.email-detail .email-body {
  white-space: pre-wrap;
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-secondary);
  word-wrap: break-word;
}

.email-detail .email-body.html-content {
  white-space: normal;
  font-size: 15px;
  line-height: 1.7;
}

.email-detail .email-body.html-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

/* Dark-mode friendly HTML email overrides */
.email-detail .email-body.html-content {
  background: var(--bg-elevated) !important;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-sm);
  border: none !important;
  color: var(--text) !important;
}

/* Override inline styles from HTML emails (white bg, black borders) */
.email-detail .email-body.html-content table,
.email-detail .email-body.html-content td,
.email-detail .email-body.html-content th,
.email-detail .email-body.html-content div,
.email-detail .email-body.html-content p,
.email-detail .email-body.html-content span,
.email-detail .email-body.html-content section {
  background: transparent !important;
  background-color: transparent !important;
  border-color: var(--border) !important;
  color: inherit !important;
}

.email-detail .email-body.html-content a {
  color: var(--accent) !important;
  text-decoration: none;
}

.email-detail .email-body.html-content a:hover {
  text-decoration: underline;
}

.email-detail .email-body.html-content table {
  max-width: 100% !important;
  width: 100% !important;
  table-layout: fixed !important;
  border-collapse: collapse;
}

.email-detail .email-body.html-content {
  max-width: 100%;
  overflow-x: auto;
  word-wrap: break-word;
  overflow-wrap: break-word;
  min-height: unset !important;
  height: auto !important;
}

/* Page headers */
.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 0 0 0.25rem 0;
}

.page-desc {
  font-size: 15px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.6;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
  transition: border-color .2s, box-shadow .2s;
}

.domains-layout .card,
.addresses-layout .card {
  margin-bottom: 0;
}

.card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow);
}

.card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.75rem 0;
  color: var(--text);
}

.card-header h3,
.create-address-header h3,
.addresses-list-title-row h3 {
  margin: 0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.domains-list-card .card-header {
  margin-bottom: 1.25rem;
  gap: 0.5rem;
}


.count-badge {
  font-size: 12px;
  padding: .3rem .6rem;
  background: var(--bg-elevated);
  border-radius: 20px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Forms */
.add-domain-form {
  display: flex;
  gap: .75rem;
  align-items: center;
  flex-wrap: wrap;
}

.add-domain-form input,
.create-address-form input,
.create-address-form select {
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color .2s;
}

.add-domain-form input:focus,
.create-address-form input:focus,
.create-address-form select:focus {
  outline: none;
  border-color: var(--accent);
}

.add-domain-form input {
  flex: 1;
  min-width: 200px;
}

.create-address-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.create-address-form .form-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.create-address-form input[type="text"] {
  flex: 1;
  min-width: 140px;
}

.create-address-form select {
  flex: 1;
  min-width: 180px;
}

.create-address-form .domain-filter-select {
  padding: 0 36px 0 1rem;
  height: 40px;
  line-height: 38px;
}

.at-symbol {
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 500;
}

.domain-filter-select {
  height: 40px;
  padding: 0 36px 0 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2371717a' d='M3 4.5L6 7.5l3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px;
  appearance: none;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  min-width: 180px;
  line-height: 38px;
}

/* Buttons */
.btn-primary {
  padding: .7rem 1.5rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-copy {
  padding: .6rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all .2s;
}

.btn-copy:hover {
  color: var(--text);
  background: var(--surface-hover);
}

/* Verification card */
.verification-card {
  border-color: rgba(99, 102, 241, .4);
  background: linear-gradient(135deg, rgba(99, 102, 241, .06) 0%, rgba(99, 102, 241, .02) 100%);
}

.verification-header {
  margin-bottom: 1rem;
}

.verification-header .verification-icon {
  font-size: 1.5rem;
  display: block;
  margin-bottom: .5rem;
}

.verification-header h3 {
  font-size: 1rem;
  margin: 0 0 .35rem 0;
}

.verification-header p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

.verification-record-wrap {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.verification-record-wrap code {
  flex: 1;
  padding: 1rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 12px;
  word-break: break-all;
  border: 1px solid var(--border);
}

/* Lists */
.domain-list,
.address-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.domain-item,
.address-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background .15s;
}

.domain-item:hover,
.address-item:hover {
  background: var(--surface-hover);
}

.domain-item:last-child,
.address-item:last-child { border-bottom: none; }

.domain-item-avatar,
.address-item-avatar {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #818cf8 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
}

.domain-item--pending .domain-item-avatar {
  width: 36px;
  height: 36px;
  font-size: 14px;
  background: var(--warning-muted);
  color: var(--warning);
  border: 2px dashed var(--warning);
}

.domain-item-content,
.address-item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

.address-item-content {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.address-local {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.address-domain {
  font-family: ui-monospace, 'SF Mono', monospace;
  font-size: 13px;
  color: var(--text-muted);
}

.domain-name {
  font-family: ui-monospace, monospace;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.domain-badge {
  font-size: 11px;
  padding: .35rem .65rem;
  border-radius: 6px;
  font-weight: 600;
}

.domain-badge.verified {
  background: var(--success-muted);
  color: var(--success);
}

.domain-badge.pending {
  background: var(--warning-muted);
  color: var(--warning);
}

.domain-verification-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.domain-verification-hint {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.domain-verification-record {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  padding: 4px 8px;
  background: var(--bg);
  border-radius: 4px;
  word-break: break-all;
  color: var(--text-secondary);
}

.btn-copy-inline {
  padding: 0.35rem 0.6rem;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  border: none;
  background: var(--surface-hover);
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all .2s;
  flex-shrink: 0;
}

.btn-copy-inline:hover {
  color: var(--accent);
  background: var(--accent-muted);
}

.btn-verify-inline {
  padding: 0.35rem 0.6rem;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  border: none;
  background: var(--accent-muted);
  color: var(--accent);
  border-radius: 6px;
  cursor: pointer;
  transition: all .2s;
  flex-shrink: 0;
}

.btn-verify-inline:hover {
  background: var(--accent);
  color: white;
}

.domain-actions,
.address-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-remove {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.15rem;
  line-height: 1;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-remove:hover {
  color: var(--error);
  background: var(--error-muted);
}


.btn-copy-small {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .2s ease;
}

.btn-copy-small:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-muted);
}

/* Empty states */
.empty-state-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 2rem;
  text-align: center;
  color: var(--text-muted);
  list-style: none;
  border: none;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.02);
  border: 1px dashed var(--border-subtle);
}

.empty-state-item .empty-icon-small {
  font-size: 2.5rem;
  opacity: .4;
  margin-bottom: 1rem;
}

.empty-state-item p {
  margin: 0 0 0.35rem 0;
  font-size: 15px;
  color: var(--text-secondary);
}

.empty-state-item p:last-of-type {
  margin-bottom: 0;
}

.empty-state-item .hint {
  font-size: 13px;
  color: var(--text-muted);
  opacity: .9;
}

.empty-state-item .error-text {
  color: var(--error);
  font-weight: 500;
}

.email-list .empty-msg,
.email-list .placeholder {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.empty-msg.loading { color: var(--text-muted); }
.empty-msg.error { color: var(--error); }

.email-detail .empty-msg {
  padding: 2rem 1rem;
  text-align: center;
}

.hidden { display: none !important; }
