@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #f5f5f5;
  --surface: #f5f5f5;
  --border: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #1a73e8;
  --accent-hover: #1557b0;
  --accent-light: #dbeafe;
  --hover: #eeeeee;
  --selected: #e0e0e0;
  --danger: #dc2626;
  --success: #059669;
}

html, body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
input, textarea, button { font-family: inherit; }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

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

.animate-fade-in { animation: fadeIn 0.35s ease-out both; }
.animate-fade-in-scale { animation: fadeInScale 0.3s ease-out both; }
.animate-slide-left { animation: slideInLeft 0.3s ease-out both; }
.animate-slide-right { animation: slideInRight 0.3s ease-out both; }

/* Header */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 64px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(245,245,245,0.92);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all 0.2s ease;
}

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

.logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.header-center {
  flex: 1;
  max-width: 720px;
  margin: 0 40px;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 16px;
  height: 48px;
  transition: all 0.2s ease;
}

.search-box:focus-within {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(31, 41, 55, 0.08);
}

.search-box input {
  border: none;
  background: transparent;
  padding: 0 12px;
  height: 100%;
  font-size: 14px;
  color: var(--text);
}

.search-box input:focus { outline: none; }

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

/* Layout */
.layout {
  display: flex;
  margin-top: 64px;
  min-height: calc(100vh - 64px);
}

/* Sidebar */
.sidebar {
  width: 256px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 16px;
  position: fixed;
  top: 64px;
  bottom: 0;
  overflow-y: auto;
}

.compose-btn {
  width: 100%;
  padding: 14px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 20px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transition: all 0.2s ease;
}

.compose-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

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

.nav-section {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-radius: 0 16px 16px 0;
  margin-right: -16px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--selected); color: var(--text); font-weight: 700; }

.nav-icon {
  width: 20px;
  height: 20px;
  color: var(--muted);
  flex-shrink: 0;
  transition: color 0.2s ease;
}

.nav-item.active .nav-icon { color: var(--text); }

.nav-label { flex: 1; }

.nav-badge {
  background: var(--text);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

/* Main */
.main {
  flex: 1;
  margin-left: 256px;
  padding: 0;
  background: var(--bg);
}

/* Content */
.content { max-width: 100%; }

/* Tabs */
.tabs {
  display: flex;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  gap: 4px;
}

.tab {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.2s ease;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }

/* Cards */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin: 20px;
  transition: all 0.2s ease;
}

.card:hover { border-color: #d1d5db; }

/* Inputs */
input, textarea {
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
}

input:focus, textarea:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(31, 41, 55, 0.08);
}

textarea { min-height: 120px; resize: vertical; line-height: 1.6; }

/* Buttons */
button {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

button:hover { background: var(--accent-hover); transform: translateY(-1px); }
button:active { transform: translateY(0); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

button .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}

/* Email list */
.email-list { display: flex; flex-direction: column; }

.email-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
  animation: fadeIn 0.3s ease-out both;
}

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

.email-checkbox {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.email-checkbox:hover { border-color: var(--text); }

.email-star {
  width: 18px;
  height: 18px;
  color: var(--border);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.email-star.active { color: #f59e0b; }

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

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

.email-sender {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}

.email-subject {
  font-size: 14px;
  color: var(--text);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

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

/* Reading pane */
.reading-pane {
  flex: 1;
  background: var(--bg);
  border-left: 1px solid var(--border);
  padding: 32px;
  overflow-y: auto;
}

.reading-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
  margin-bottom: 20px;
  animation: fadeIn 0.3s ease-out both;
}

.reading-subject {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 16px;
  line-height: 1.4;
}

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

.reading-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
}

.reading-info { flex: 1; }

.reading-from {
  font-size: 14px;
  font-weight: 600;
}

.reading-to {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.reading-date {
  font-size: 12px;
  color: var(--muted);
}

.reading-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  animation: fadeIn 0.4s ease-out both;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 40px;
  text-align: center;
  color: var(--muted);
  animation: fadeIn 0.5s ease-out both;
}

.empty-state svg {
  width: 80px;
  height: 80px;
  margin-bottom: 20px;
  opacity: 0.3;
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  max-width: 400px;
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, var(--bg) 25%, #e5e7eb 50%, var(--bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
}

.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 70%; }
.skeleton-text.long { width: 100%; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.login-wrap::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 30%, rgba(37,99,235,0.06), transparent 50%),
              radial-gradient(circle at 70% 70%, rgba(124,58,237,0.06), transparent 50%);
  animation: pulse 8s ease-in-out infinite;
}

.login-card {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 48px;
  border-radius: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.04);
  animation: fadeInScale 0.5s ease-out both;
  position: relative;
  z-index: 1;
}

.login-card h1 {
  text-align: center;
  margin-bottom: 12px;
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.login-card .sub {
  text-align: center;
  color: var(--muted);
  margin-bottom: 32px;
  font-size: 14px;
}

.login-card input { margin-bottom: 16px; }

.login-card button {
  width: 100%;
  margin-top: 8px;
  padding: 14px;
}

/* Public inbox */
.public-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 20px;
  text-align: center;
}

.public-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.public-header p {
  font-size: 13px;
  color: var(--muted);
}

/* Error box */
.error-box {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  padding: 14px;
  border-radius: 14px;
  font-size: 13px;
}

/* Note */
.note {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

/* Endpoint */
.endpoint {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  margin-top: 18px;
  transition: all 0.2s ease;
}

.endpoint:hover { border-color: #d1d5db; }

.badge {
  display: inline-flex;
  align-items: center;
  background: rgba(31, 41, 55, 0.06);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  margin-right: 10px;
}

code {
  background: var(--bg);
  padding: 10px 12px;
  border-radius: 10px;
  display: block;
  margin-top: 10px;
  font-size: 13px;
  border: 1px solid var(--border);
}

/* Utility */
.hidden { display: none !important; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 13px; }
.font-semibold { font-weight: 600; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* Mobile */
@media (max-width: 768px) {
  .header-center { display: none; }
  .sidebar { transform: translateX(-100%); transition: transform 0.3s ease; z-index: 200; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .layout { flex-direction: column; }
  .public-header { padding: 16px; }
  .reading-pane { padding: 20px; }
}
