@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-root: #070914;
  --bg-soft: rgba(255, 255, 255, 0.06);
  --bg-card: rgba(13, 18, 36, 0.78);
  --bg-card-strong: rgba(15, 23, 42, 0.92);
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.2);
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #7c8aa5;
  --accent: #8b5cf6;
  --accent-2: #06b6d4;
  --accent-3: #f59e0b;
  --success: #34d399;
  --danger: #fb7185;
  --danger-bg: rgba(251, 113, 133, 0.13);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  --shadow-soft: 0 16px 50px rgba(2, 6, 23, 0.28);
  --radius-sm: 14px;
  --radius: 22px;
  --radius-lg: 32px;
  --transition: 180ms ease;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-primary);
  background:
    linear-gradient(135deg, rgba(139, 92, 246, 0.12), transparent 28%),
    radial-gradient(circle at 80% 10%, rgba(6, 182, 212, 0.16), transparent 34%),
    radial-gradient(circle at 10% 80%, rgba(245, 158, 11, 0.12), transparent 30%),
    var(--bg-root);
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: linear-gradient(to bottom, #000, transparent 78%);
}

.ambient {
  position: fixed;
  width: 360px;
  height: 360px;
  border-radius: 999px;
  filter: blur(34px);
  opacity: 0.34;
  pointer-events: none;
  animation: floaty 9s ease-in-out infinite alternate;
}

.ambient-one {
  top: -90px;
  left: -90px;
  background: #8b5cf6;
}

.ambient-two {
  right: -120px;
  bottom: 18%;
  background: #06b6d4;
  animation-delay: -3s;
}

@keyframes floaty {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(34px, 20px, 0) scale(1.08); }
}

.app {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.topbar,
.quick-create,
.new-box,
.control-panel,
.panel,
.address-card {
  border: 1px solid var(--border);
  background: linear-gradient(145deg, rgba(255,255,255,0.1), rgba(255,255,255,0.045));
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(22px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-radius: 999px;
  margin-bottom: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 26px rgba(139, 92, 246, 0.36);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--success);
  background: rgba(52, 211, 153, 0.1);
  font-size: 12px;
  font-weight: 700;
}

.status-pill span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 6px rgba(52, 211, 153, 0.13);
}

.hero-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  align-items: stretch;
  margin-bottom: 20px;
}

.hero-copy {
  min-height: 310px;
  padding: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(139, 92, 246, 0.34), rgba(6, 182, 212, 0.12)),
    rgba(15, 23, 42, 0.68);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.hero-copy::after {
  content: '';
  position: absolute;
  right: -80px;
  top: -80px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}

.eyebrow,
.section-kicker,
.card-label {
  color: #a5f3fc;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero-copy h1 {
  max-width: 720px;
  margin-top: 14px;
  font-size: clamp(36px, 6vw, 72px);
  line-height: 0.95;
  letter-spacing: -0.07em;
}

.subtitle {
  max-width: 640px;
  margin-top: 22px;
  color: var(--text-secondary);
  font-size: 17px;
  line-height: 1.7;
}

.address-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 310px;
  padding: 26px;
  border-radius: var(--radius-lg);
}

.address-card strong {
  word-break: break-all;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -0.04em;
}

button,
select,
input {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button {
  border: 0;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition), background var(--transition);
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0) scale(0.98);
}

#heroCopyBtn,
.primary-action,
#createCustomBtn {
  padding: 14px 18px;
  border-radius: 16px;
  color: #031018;
  font-weight: 800;
  background: linear-gradient(135deg, #67e8f9, #a78bfa 52%, #fbbf24);
  box-shadow: 0 18px 42px rgba(6, 182, 212, 0.24);
}

.quick-create {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 22px;
  border-radius: var(--radius);
  margin-bottom: 14px;
}

.quick-create h2 {
  margin-top: 4px;
  font-size: 24px;
  letter-spacing: -0.04em;
}

.create-actions,
.tool-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.secondary-action,
#createRandomBtn,
.tool-grid button {
  padding: 12px 15px;
  border: 1px solid var(--border);
  border-radius: 15px;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
  font-weight: 750;
}

.new-box {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(150px, 220px) auto auto;
  gap: 12px;
  align-items: end;
  padding: 18px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  animation: slideDown 220ms ease both;
}

.new-box.hidden {
  display: none;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.field-group,
.control-panel label {
  display: grid;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text-primary);
  background: rgba(2, 6, 23, 0.58);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

input::placeholder {
  color: var(--text-muted);
}

input:focus,
select:focus {
  border-color: rgba(103, 232, 249, 0.65);
  box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.14);
}

.workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.control-panel,
.panel {
  border-radius: var(--radius);
}

.control-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
  position: sticky;
  top: 20px;
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.tool-grid button {
  min-height: 44px;
}

.tool-grid .danger {
  grid-column: 1 / -1;
  color: #fecdd3;
  background: var(--danger-bg);
  border-color: rgba(251, 113, 133, 0.26);
}

.tool-grid .danger:hover {
  color: #fff;
  background: rgba(251, 113, 133, 0.28);
}

.hint-card {
  padding: 16px;
  border-radius: 18px;
  color: var(--text-secondary);
  background: rgba(6, 182, 212, 0.09);
  border: 1px solid rgba(103, 232, 249, 0.16);
}

.hint-card span {
  display: block;
  margin-bottom: 6px;
  color: #67e8f9;
  font-weight: 800;
}

.hint-card p {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

.panel {
  overflow: hidden;
  min-height: 460px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.22);
}

.panel-head h2 {
  margin-top: 5px;
  word-break: break-all;
  font-size: 22px;
  letter-spacing: -0.04em;
}

#messageCount {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  color: #fde68a;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.18);
  font-size: 12px;
  font-weight: 800;
}

.message-list {
  min-height: 340px;
}

.message-item {
  margin: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.055);
  transition: transform var(--transition), background var(--transition), border-color var(--transition);
}

.message-item:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.085);
  border-color: var(--border-strong);
}

.message-meta {
  margin-bottom: 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 750;
}

.message-item strong {
  display: block;
  margin-bottom: 10px;
  color: var(--text-primary);
  font-size: 18px;
}

.message-body {
  display: grid;
  gap: 14px;
}

.quick-codes,
.quick-links {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(245, 158, 11, 0.22);
  border-radius: 16px;
  background: rgba(245, 158, 11, 0.08);
}

.quick-links {
  border-color: rgba(103, 232, 249, 0.2);
  background: rgba(6, 182, 212, 0.08);
}

.quick-codes > span,
.quick-links > span {
  color: #fde68a;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.quick-links > span {
  color: #67e8f9;
}

.chip-row,
.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.code-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid rgba(245, 158, 11, 0.32);
  border-radius: 12px;
  color: #fde68a;
  background: rgba(245, 158, 11, 0.14);
  font-size: 20px;
  font-weight: 850;
  letter-spacing: 0.12em;
}

.extracted-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  padding: 9px 12px;
  border-radius: 12px;
  color: #031018;
  background: linear-gradient(135deg, #67e8f9, #a78bfa);
  font-weight: 850;
  text-decoration: none;
  overflow-wrap: anywhere;
  box-shadow: 0 10px 28px rgba(6, 182, 212, 0.16);
}

.email-html {
  max-width: 100%;
  overflow: auto;
  padding: 16px;
  border-radius: 16px;
  color: #e5e7eb;
  background: rgba(255, 255, 255, 0.035);
  line-height: 1.6;
}

.email-html :where(table, img, div, p) {
  max-width: 100%;
}

.email-html img {
  height: auto;
  border-radius: 10px;
}

.email-html a {
  color: #67e8f9;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.email-html a[href] {
  cursor: pointer;
}

.email-html a:has(img),
.email-html a[style*="button"],
.email-html a[style*="background"],
.email-html a[class*="button" i],
.email-html a[class*="btn" i] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 6px 0;
  padding: 10px 14px;
  border-radius: 12px;
  color: #031018 !important;
  background: linear-gradient(135deg, #67e8f9, #a78bfa) !important;
  font-weight: 850;
  text-decoration: none;
  box-shadow: 0 10px 28px rgba(6, 182, 212, 0.18);
}

.code-chip:hover,
.extracted-link:hover,
.email-html a:hover {
  filter: brightness(1.08);
}

.empty-summary {
  color: var(--text-muted);
  font-size: 14px;
}

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 340px;
  padding: 46px 20px;
  text-align: center;
}

.empty-state .icon {
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  margin-bottom: 16px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 36px;
}

.empty-state .title {
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 800;
}

.empty-state .sub {
  max-width: 360px;
  margin-top: 8px;
  color: var(--text-muted);
  line-height: 1.7;
}

footer {
  padding: 28px 0 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

footer a {
  color: inherit;
  text-decoration: none;
}

footer span {
  color: #a5f3fc;
  font-weight: 800;
}

.toast-container {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  display: grid;
  gap: 10px;
}

.toast {
  padding: 13px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text-primary);
  background: rgba(15, 23, 42, 0.88);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
  animation: toastIn 240ms ease both;
}

.toast.fadeout {
  animation: toastOut 180ms ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(8px) scale(0.97); }
}

@media (max-width: 900px) {
  .hero-card,
  .workspace {
    grid-template-columns: 1fr;
  }

  .hero-copy,
  .address-card {
    min-height: auto;
  }

  .control-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .app {
    width: min(100% - 20px, 1180px);
    padding-top: 14px;
  }

  .topbar,
  .quick-create {
    align-items: stretch;
    border-radius: 22px;
    flex-direction: column;
  }

  .hero-copy {
    padding: 28px;
  }

  .address-card {
    padding: 20px;
    gap: 24px;
  }

  .new-box {
    grid-template-columns: 1fr;
  }

  .create-actions,
  .tool-grid {
    grid-template-columns: 1fr;
  }

  .create-actions button,
  .tool-grid button {
    width: 100%;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .email-html a:has(img),
  .email-html a[style*="button"],
  .email-html a[style*="background"],
  .email-html a[class*="button" i],
  .email-html a[class*="btn" i],
  .extracted-link,
  .code-chip {
    width: 100%;
  }
}
