:root {
  --ink: #17212b;
  --muted: #62707f;
  --line: #d9e2ea;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-strong: #ffffff;
  --blue: #2563eb;
  --green: #10976d;
  --coral: #e45f4f;
  --amber: #c58916;
  --soft-blue: #dceafe;
  --soft-green: #def7ec;
  --soft-coral: #ffe4de;
  --shadow: 0 18px 50px rgba(31, 44, 59, 0.14);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.35)),
    repeating-linear-gradient(
      135deg,
      rgba(37, 99, 235, 0.07) 0,
      rgba(37, 99, 235, 0.07) 1px,
      transparent 1px,
      transparent 26px
    ),
    linear-gradient(135deg, #f6fbff 0%, #effaf5 47%, #fff4ef 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 32px;
}

.workspace {
  animation: rise-in 520ms ease both;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 3.6vw, 4.4rem);
  line-height: 0.94;
}

h2 {
  font-size: 1.25rem;
  line-height: 1.2;
}

.status-pill,
.cap-line,
.provider-note,
.result-counts span,
.alias-meta span {
  border: 1px solid rgba(23, 33, 43, 0.08);
  background: rgba(255, 255, 255, 0.72);
}

.status-pill {
  flex: 0 0 auto;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.88rem;
  box-shadow: 0 10px 24px rgba(31, 44, 59, 0.08);
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(420px, 1fr) minmax(260px, 330px);
  gap: 16px;
  align-items: start;
}

.panel {
  border: 1px solid rgba(23, 33, 43, 0.08);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.controls-panel,
.results-panel,
.history-panel {
  padding: 18px;
}

.controls-panel,
.history-panel {
  position: sticky;
  top: 24px;
}

.field-group {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 126px;
  gap: 12px;
}

label,
legend,
.search-box span {
  color: #293845;
  font-size: 0.86rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  color: var(--ink);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

input,
select {
  height: 46px;
  padding: 0 12px;
}

textarea {
  min-height: 96px;
  resize: vertical;
  padding: 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(37, 99, 235, 0.72);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.13);
}

.cap-line {
  margin: 0 0 16px;
  padding: 12px;
  border-radius: var(--radius);
  color: #445364;
  font-size: 0.9rem;
  line-height: 1.45;
}

.method-box {
  display: grid;
  gap: 12px;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.method-list {
  display: grid;
  gap: 10px;
}

.method-card {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  cursor: pointer;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease,
    background 180ms ease;
}

.method-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(31, 44, 59, 0.1);
}

.method-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.method-check {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid #b7c3cf;
  border-radius: 6px;
  background: #fff;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    transform 180ms ease;
}

.method-check::before {
  color: #fff;
  font-size: 0.76rem;
  font-weight: 900;
  content: "\2713";
  transform: scale(0);
  transition: transform 180ms ease;
}

.method-card:has(input:checked) {
  border-color: rgba(37, 99, 235, 0.48);
  background: linear-gradient(135deg, rgba(220, 234, 254, 0.78), #fff);
}

.method-card:has(input:checked) .method-check {
  border-color: var(--blue);
  background: var(--blue);
  transform: rotate(-4deg);
}

.method-card:has(input:checked) .method-check::before {
  transform: scale(1);
}

.method-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.95rem;
}

.method-card small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.action-row,
.tool-strip,
.history-head,
.results-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.action-row {
  margin-top: 6px;
}

.primary-button,
.ghost-button {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  font-weight: 800;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.primary-button {
  flex: 1;
  position: relative;
  overflow: hidden;
  padding: 0 16px;
  background: linear-gradient(135deg, var(--blue), #0f8a75 72%, var(--green));
  color: #fff;
  box-shadow: 0 14px 26px rgba(37, 99, 235, 0.24);
}

.primary-button::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  content: "";
  transform: translateX(-100%);
}

.primary-button:hover::after {
  animation: sheen 800ms ease;
}

.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-2px);
}

.ghost-button {
  padding: 0 13px;
  border: 1px solid var(--line);
  background: #fff;
  color: #273746;
}

.ghost-button.compact {
  min-height: 36px;
  padding: 0 10px;
  font-size: 0.84rem;
}

.provider-note {
  margin-top: 16px;
  padding: 12px;
  border-radius: var(--radius);
  color: #445364;
  font-size: 0.86rem;
  line-height: 1.45;
}

.provider-note:empty {
  display: none;
}

.results-panel {
  min-height: 640px;
}

.results-toolbar {
  justify-content: space-between;
  margin-bottom: 14px;
}

.result-counts {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.result-counts span,
.alias-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
}

.tool-strip {
  flex-wrap: wrap;
  justify-content: space-between;
  margin-bottom: 16px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(76px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #eef4f8;
}

.segment {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.segment.active {
  background: #fff;
  color: var(--blue);
  box-shadow: 0 8px 16px rgba(31, 44, 59, 0.08);
}

.search-box {
  display: grid;
  grid-template-columns: auto minmax(150px, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 240px;
}

.search-box input {
  height: 36px;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 360px;
  border: 1px dashed #b9c8d5;
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.empty-state p {
  width: min(340px, 88%);
  margin: 0;
  line-height: 1.5;
}

.empty-mark {
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--soft-blue), var(--soft-green), var(--soft-coral));
  color: #163045;
  font-size: 1.6rem;
  font-weight: 950;
  box-shadow: 0 14px 24px rgba(31, 44, 59, 0.11);
}

.alias-list {
  display: grid;
  gap: 9px;
}

.alias-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.84);
  animation: row-in 240ms ease both;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.alias-row:hover {
  transform: translateY(-1px);
  border-color: rgba(37, 99, 235, 0.32);
  box-shadow: 0 12px 22px rgba(31, 44, 59, 0.1);
}

.alias-row.used {
  background: rgba(239, 244, 248, 0.72);
}

.used-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid #b9c8d5;
  border-radius: var(--radius);
  background: #fff;
  color: #4f5f6d;
  font-size: 0.84rem;
  font-weight: 850;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.toggle-symbol {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 5px;
  background: #f0f4f8;
  color: var(--muted);
}

.toggle-symbol::before {
  content: "\00d7";
  font-weight: 950;
}

.used .used-toggle {
  border-color: rgba(16, 151, 109, 0.38);
  background: var(--soft-green);
  color: #0e6c51;
}

.used .toggle-symbol {
  background: var(--green);
  color: #fff;
}

.used .toggle-symbol::before {
  content: "\2713";
}

.alias-main {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.alias-address {
  width: 100%;
  border: 0;
  background: transparent;
  color: #111b26;
  overflow-wrap: anywhere;
  padding: 0;
  text-align: left;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.97rem;
  font-weight: 760;
  letter-spacing: 0;
}

.alias-address:hover {
  color: var(--blue);
}

.alias-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.alias-mode.ready {
  background: var(--soft-green);
  color: #0e6c51;
}

.alias-mode.setup {
  background: #fff3d8;
  color: #7b560f;
}

.history-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.history-list {
  display: grid;
  gap: 9px;
}

.history-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.8);
  padding: 12px;
  text-align: left;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.history-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 20px rgba(31, 44, 59, 0.09);
}

.history-item.active {
  border-color: rgba(37, 99, 235, 0.45);
  background: linear-gradient(135deg, rgba(220, 234, 254, 0.82), rgba(255, 255, 255, 0.94));
}

.history-email {
  display: block;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 850;
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.toast {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 20;
  max-width: min(340px, calc(100vw - 40px));
  padding: 13px 15px;
  border: 1px solid rgba(23, 33, 43, 0.09);
  border-radius: var(--radius);
  background: #142230;
  color: #fff;
  box-shadow: 0 18px 42px rgba(31, 44, 59, 0.26);
  animation: toast-in 220ms ease both;
}

.toast.error {
  background: #8e2f28;
}

body[data-compact-view="true"] .app-shell {
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

body[data-compact-view="true"] .app-header,
body[data-compact-view="true"] .results-toolbar,
body[data-compact-view="true"] .tool-strip {
  align-items: stretch;
  flex-direction: column;
}

body[data-compact-view="true"] .layout-grid,
body[data-compact-view="true"] .field-row {
  grid-template-columns: 1fr;
}

body[data-compact-view="true"] .controls-panel,
body[data-compact-view="true"] .history-panel {
  position: static;
}

body[data-compact-view="true"] .results-panel {
  min-height: 0;
}

body[data-compact-view="true"] .result-counts {
  justify-content: flex-start;
}

body[data-compact-view="true"] .tool-strip > * {
  width: 100%;
}

body[data-compact-view="true"] .search-box {
  width: 100%;
  min-width: 0;
  grid-template-columns: 1fr;
}

body[data-compact-view="true"] .segmented {
  width: 100%;
}

body[data-compact-view="true"] .alias-row {
  grid-template-columns: 1fr;
}

body[data-compact-view="true"] .used-toggle {
  width: 100%;
}

body[data-compact-view="true"] .empty-state {
  min-height: 220px;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes row-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sheen {
  to {
    transform: translateX(100%);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1160px) {
  .layout-grid {
    grid-template-columns: minmax(300px, 0.86fr) minmax(420px, 1.14fr);
  }

  .history-panel {
    grid-column: 1 / -1;
    position: static;
  }

  .history-list {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 18px;
  }

  .app-header,
  .results-toolbar,
  .tool-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .layout-grid,
  .field-row {
    grid-template-columns: 1fr;
  }

  .controls-panel,
  .history-panel {
    position: static;
  }

  .results-panel {
    min-height: 0;
  }

  .result-counts {
    justify-content: flex-start;
  }

  .tool-strip > * {
    width: 100%;
  }

  .search-box {
    width: 100%;
    min-width: 0;
    grid-template-columns: 1fr;
  }

  .segmented {
    width: 100%;
  }

  .alias-row {
    grid-template-columns: 1fr;
  }

  .used-toggle {
    width: 100%;
  }

  .empty-state {
    min-height: 220px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
