:root {
  --bg-grad-1: #f9e6ff;
  --bg-grad-2: #ffe6f0;
  --bg-grad-3: #e6e6ff;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --border: rgba(120, 100, 200, 0.18);
  --border-strong: rgba(120, 100, 200, 0.32);
  --text: #1f1538;
  --text-muted: #6b6386;
  --text-faint: #a8a3bd;
  --primary: #6d4cf3;
  --primary-hover: #5a3ce0;
  --primary-shadow: rgba(109, 76, 243, 0.35);
  --danger: #e54a6c;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(50, 30, 100, 0.04);
  --shadow-md: 0 8px 24px rgba(80, 50, 160, 0.08);
  --transition: 160ms ease;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(at 20% 10%, var(--bg-grad-1) 0px, transparent 50%),
    radial-gradient(at 80% 0%, var(--bg-grad-2) 0px, transparent 50%),
    radial-gradient(at 50% 100%, var(--bg-grad-3) 0px, transparent 50%),
    #fafaff;
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input, select {
  font-family: inherit;
  color: inherit;
}

.topbar {
  padding: 18px 28px;
  display: flex;
  align-items: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
}

.brand-icon {
  font-size: 20px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 24px 32px;
}

.composer {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 16px 0 20px;
}

.field {
  display: flex;
  align-items: center;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 6px 0 14px;
  height: 46px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.field:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(109, 76, 243, 0.12);
}

.username-field {
  width: 280px;
}

.domain-field {
  width: 220px;
  padding: 0;
}

.username-field input {
  flex: 1;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
}

.username-field input::placeholder {
  color: var(--text-faint);
}

.domain-field select {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  padding: 0 14px;
  background: transparent;
  font-size: 15px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6386' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}

.icon-btn:hover {
  background: rgba(109, 76, 243, 0.08);
  color: var(--primary);
}

.primary-btn {
  height: 46px;
  padding: 0 28px;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 6px 18px var(--primary-shadow);
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.primary-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px var(--primary-shadow);
}

.primary-btn:active {
  transform: translateY(0);
}

.current-address {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 4px 0 20px;
  font-size: 14px;
  color: var(--text-muted);
}

.current-address .label {
  color: var(--text-muted);
}

.current-address .value {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 15px;
  color: var(--primary);
  background: var(--surface-strong);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-weight: 600;
}

.workspace {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  min-height: 560px;
  box-shadow: var(--shadow-md);
}

.inbox-panel, .reader-panel {
  background: var(--surface-strong);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.inbox-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}

.inbox-item {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 4px;
  transition: background var(--transition), border-color var(--transition);
}

.inbox-item:hover {
  background: rgba(109, 76, 243, 0.06);
}

.inbox-item.active {
  background: rgba(109, 76, 243, 0.1);
  border-color: rgba(109, 76, 243, 0.3);
}

.inbox-item .from {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 2px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.inbox-item .from .time {
  font-weight: 400;
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
}

.inbox-item .subject {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox-item .preview {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-faint);
}

.empty-icon {
  font-size: 36px;
  opacity: 0.45;
  margin-bottom: 12px;
}

.empty-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--text-muted);
}

.empty-sub {
  font-size: 13px;
  margin: 0;
}

.reader-panel {
  position: relative;
  min-height: 400px;
}

.reader-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-faint);
  padding: 40px;
}

.reader-icon {
  font-size: 80px;
  opacity: 0.25;
  margin-bottom: 16px;
}

.reader-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.reader-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.reader-header h3 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.reader-meta {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.reader-meta .from-line {
  font-weight: 500;
  color: var(--text);
}

.reader-body {
  flex: 1;
  overflow: auto;
  min-height: 320px;
}

.reader-body iframe {
  width: 100%;
  height: 100%;
  min-height: 320px;
  border: none;
  background: #fff;
}

.reader-body pre {
  margin: 0;
  padding: 20px;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
}

.footer {
  text-align: center;
  padding: 24px;
  font-size: 13px;
  color: var(--text-muted);
}

.footer strong {
  color: var(--text);
}

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  z-index: 100;
  animation: toast-in 200ms ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 820px) {
  .container { padding: 8px 14px 24px; }
  .composer { gap: 8px; }
  .username-field, .domain-field { width: 100%; }
  .domain-field { width: 100%; }
  .primary-btn { width: 100%; }
  .workspace {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .inbox-panel { min-height: 280px; }
  .reader-panel { min-height: 360px; }
}
