* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Text", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: #e7ebff;
  background: #0b1024;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}

.bg-orbs {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background: radial-gradient(circle at 20% 0%, #1a1f4d 0%, #0b1024 60%);
}
.orb {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.55;
  animation: float 18s ease-in-out infinite;
}
.orb-1 { width: 420px; height: 420px; background: #5b8cff; top: -120px; left: -120px; }
.orb-2 { width: 360px; height: 360px; background: #b14dff; top: 30%; right: -100px; animation-delay: -6s; }
.orb-3 { width: 320px; height: 320px; background: #4dd9ff; bottom: -140px; left: 30%; animation-delay: -12s; }

@keyframes float {
  0%, 100% { transform: translate(0,0) scale(1); }
  33%      { transform: translate(40px,-30px) scale(1.08); }
  66%      { transform: translate(-30px,30px) scale(0.95); }
}

.glass {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}

.view { width: 100%; min-height: 100dvh; }
.view-center { display: flex; align-items: center; justify-content: center; padding: 24px; }
.hidden { display: none !important; }

.card-login { width: 100%; max-width: 380px; padding: 32px 26px; }
.brand { text-align: center; margin-bottom: 22px; }
.brand-logo {
  font-size: 32px; width: 56px; height: 56px;
  margin: 0 auto 12px;
  border-radius: 16px;
  background: linear-gradient(135deg, #5b8cff, #b14dff);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(91,140,255,0.4);
}
.brand h1 { margin: 0 0 6px; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.muted { color: rgba(231,235,255,0.55); font-size: 13px; }

.field { display: block; margin-bottom: 14px; }
.field span {
  display: block; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.08em; color: rgba(231,235,255,0.55);
  margin-bottom: 6px;
}
.field input, .field textarea, .acct-select {
  width: 100%;
  padding: 12px 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  color: #fff;
  font: inherit;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.field input:focus, .field textarea:focus, .acct-select:focus {
  border-color: rgba(91,140,255,0.6);
  background: rgba(255,255,255,0.10);
}
.field textarea { resize: vertical; min-height: 140px; font-family: inherit; }
.field-grow { flex: 1; min-height: 180px; display: flex; flex-direction: column; }
.field-grow textarea { flex: 1; }

.btn {
  border: 0; cursor: pointer;
  padding: 12px 18px;
  border-radius: 12px;
  font: inherit; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.08s, opacity 0.15s, background 0.15s;
  min-height: 44px;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, #5b8cff, #7a5bff);
  color: #fff;
  box-shadow: 0 6px 18px rgba(91,140,255,0.35);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  background: rgba(255,255,255,0.06);
  color: #e7ebff;
  border: 1px solid rgba(255,255,255,0.14);
}
.btn-ghost:hover { background: rgba(255,255,255,0.10); }
.btn-block { width: 100%; margin-top: 8px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  margin: 8px;
  border-radius: 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 6px; }
.topbar h2 { margin: 0 0 0 4px; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.iconbtn {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  width: 38px; height: 38px;
  border-radius: 10px;
  color: #e7ebff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; line-height: 1;
}
.iconbtn:hover { background: rgba(255,255,255,0.10); }
.iconbtn[hidden] { display: none; }
.acct-select {
  padding: 8px 10px;
  width: auto; min-width: 0;
  font-size: 13px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #e7ebff 50%), linear-gradient(135deg, #e7ebff 50%, transparent 50%);
  background-position: calc(100% - 14px) center, calc(100% - 9px) center;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}
.acct-select option { background: #1a1f4d; color: #fff; }

.content { padding: 0 12px 80px; max-width: 720px; margin: 0 auto; }
.status-line { padding: 8px 6px 14px; font-size: 13px; color: rgba(231,235,255,0.55); }

.list { display: flex; flex-direction: column; gap: 10px; }
.email-item {
  padding: 14px 16px;
  border-radius: 14px;
  cursor: pointer;
  position: relative;
  display: flex; flex-direction: column; gap: 4px;
  transition: transform 0.08s, background 0.15s;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10);
}
.email-item:hover { background: rgba(255,255,255,0.09); }
.email-item:active { transform: scale(0.99); }
.email-item.unread { background: rgba(91,140,255,0.10); border-color: rgba(91,140,255,0.30); }
.email-item.unread .ei-from { color: #fff; }
.email-item.unread::before {
  content: ''; position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  width: 6px; height: 6px; border-radius: 50%; background: #5b8cff;
}
.email-item .ei-row1 {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.email-item .ei-from { font-weight: 600; font-size: 14px; color: rgba(231,235,255,0.92); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-item .ei-date { font-size: 12px; color: rgba(231,235,255,0.50); flex-shrink: 0; }
.email-item .ei-subject {
  font-size: 14px; color: rgba(231,235,255,0.80);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.detail { padding: 18px 18px 22px; margin-top: 4px; }
.detail-head h3 { margin: 0 0 12px; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.meta { display: flex; flex-direction: column; gap: 4px; font-size: 13px; margin-bottom: 16px; }
.meta strong { font-weight: 600; }
.email-body {
  background: rgba(0,0,0,0.18);
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 14.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 55vh;
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.06);
}
.detail-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.detail-actions .btn { flex: 1; min-width: 140px; }

.drawer {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.drawer-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
}
.drawer-panel {
  position: relative;
  width: 100%; max-width: 560px;
  max-height: 92dvh;
  border-radius: 22px 22px 0 0;
  padding: 18px;
  display: flex; flex-direction: column;
  animation: slideUp 0.25s ease-out;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.drawer-head h3 { margin: 0; font-size: 18px; font-weight: 700; }
.drawer-body { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.drawer-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.drawer-foot .btn { flex: 1; max-width: 200px; }

.mic-row {
  display: flex; align-items: center; gap: 14px;
  background: rgba(0,0,0,0.18);
  border-radius: 14px;
  padding: 12px 14px;
  margin-top: 4px;
}
.mic-btn {
  position: relative;
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(135deg, #5b8cff, #b14dff);
  color: #fff; font-size: 22px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(91,140,255,0.4);
  transition: transform 0.1s;
}
.mic-btn:active { transform: scale(0.95); }
.mic-btn.recording { background: linear-gradient(135deg, #ff5b8c, #ff7a5b); animation: pulse 1.5s infinite; }
.mic-btn .mic-pulse {
  position: absolute; inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(255,91,140,0.5);
  opacity: 0; pointer-events: none;
}
.mic-btn.recording .mic-pulse { animation: ring 1.5s infinite; }
@keyframes pulse {
  0%,100% { box-shadow: 0 6px 18px rgba(255,91,140,0.4); }
  50%     { box-shadow: 0 6px 24px rgba(255,91,140,0.8); }
}
@keyframes ring {
  0%   { transform: scale(0.9); opacity: 0.8; }
  100% { transform: scale(1.6); opacity: 0; }
}
.mic-info { flex: 1; min-width: 0; }
.mic-status { font-size: 13px; color: rgba(231,235,255,0.75); }
.mic-interim { font-size: 13px; color: rgba(231,235,255,0.45); font-style: italic; margin-top: 2px; min-height: 18px; }

.toast {
  position: fixed; left: 50%; bottom: 80px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20,24,55,0.95);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: rgba(120,30,60,0.95); border-color: rgba(255,91,140,0.4); }
.toast.success { background: rgba(30,80,60,0.95); border-color: rgba(91,255,140,0.4); }

.error-msg {
  color: #ff8da8;
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}

.skel {
  height: 64px; border-radius: 14px;
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.10) 50%, rgba(255,255,255,0.04) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (max-width: 480px) {
  .topbar h2 { font-size: 16px; }
  .iconbtn { width: 36px; height: 36px; font-size: 16px; }
  .detail { padding: 16px; }
  .detail-head h3 { font-size: 17px; }
  .acct-select { font-size: 12px; max-width: 130px; text-overflow: ellipsis; }
}
