:root {
  --bg: #0d1117;
  --panel: #151b23;
  --panel-strong: #0f141b;
  --panel-border: #26303c;
  --text: #e6edf3;
  --muted: #8b98a8;
  --accent: #4ea1ff;
  --accent-dark: #2f81f7;
  --accent-soft: rgba(78, 161, 255, 0.12);
  --success: #3fb950;
  --error: #f85149;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

code,
.mono,
.raw-response {
  font-family: "IBM Plex Mono", monospace;
}

.app-shell {
  width: min(1320px, calc(100% - 24px));
  margin: 12px auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.topbar h1,
.panel h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 1.7rem;
}

.lead {
  max-width: 680px;
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.95rem;
}

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

.topbar-actions,
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, opacity 140ms ease;
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button-primary {
  color: #f8fbff;
  background: var(--accent-dark);
}

.button-primary:hover {
  background: #1f6feb;
}

.button-secondary {
  border-color: var(--panel-border);
  color: var(--text);
  background: #10161d;
}

.button-secondary:hover {
  background: #18212b;
}

.button input {
  display: none;
}

.notice {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--panel-border);
  background: #10161d;
  color: var(--text);
}

.notice.notice-error {
  border-color: rgba(248, 81, 73, 0.4);
}

.notice.notice-success {
  border-color: rgba(63, 185, 80, 0.35);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(250px, 290px) minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.panel {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.sidebar .panel {
  position: sticky;
  top: 12px;
  padding: 16px;
}

.panel-heading,
.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.dropzone {
  margin-top: 14px;
  padding: 14px;
  border: 1px dashed #334155;
  border-radius: var(--radius-md);
  background: #10161d;
  transition: border-color 160ms ease, background 160ms ease;
}

.dropzone p {
  margin: 0;
  line-height: 1.45;
}

.dropzone p + p {
  margin-top: 6px;
}

.dropzone.is-dragging {
  border-color: var(--accent);
  background: #121c28;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.stat-card {
  padding: 10px;
  border-radius: var(--radius-md);
  background: #10161d;
  border: 1px solid var(--panel-border);
}

.stat-card strong,
.code-highlight {
  display: block;
  font-size: clamp(1.2rem, 2.4vw, 2.2rem);
  font-weight: 700;
}

.stat-card span,
.muted {
  color: var(--muted);
}

.search-field {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

.search-field span,
.result-label {
  font-size: 0.84rem;
  color: var(--muted);
}

.search-field input {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  background: #0f141b;
  color: var(--text);
}

.sidebar-button {
  width: 100%;
  margin-top: 10px;
}

.empty-state {
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  color: var(--muted);
  background: #10161d;
  border: 1px solid var(--panel-border);
}

.email-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  max-height: calc(100vh - 320px);
  overflow: auto;
}

.email-item {
  display: block;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: #121821;
  text-align: left;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}

.email-item:hover {
  border-color: #4a678d;
  background: #16202c;
}

.email-item.is-active {
  border-color: #58a6ff;
  background: #18293d;
}

.checkbox-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.email-address {
  display: block;
  color: #f8fbff;
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}

.content {
  display: grid;
  gap: 14px;
}

.hero-panel,
.detail-panel {
  padding: 18px 20px;
}

.hero-copy {
  max-width: 560px;
}

.detail-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.result-card {
  min-width: 0;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--panel-border);
  background: #10161d;
}

.result-card p {
  margin-bottom: 0;
  line-height: 1.5;
}

.result-card-primary {
  background: #111b26;
  border-color: #28415f;
}

.codes-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.code-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #1b2430;
  color: var(--text);
}

.raw-card {
  grid-column: 1 / -1;
}

.raw-response {
  margin: 12px 0 0;
  max-height: 360px;
  overflow: auto;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #202b38;
  background: #0b1016;
  color: #dbe6f1;
  font-size: 0.88rem;
  line-height: 1.55;
}

.hidden {
  display: none !important;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar .panel {
    position: static;
  }

  .email-list {
    max-height: 320px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 16px, 100%);
    margin: 8px auto 16px;
  }

  .topbar,
  .hero-panel,
  .detail-panel,
  .sidebar .panel {
    padding: 16px;
  }

  .topbar,
  .panel-heading,
  .detail-header {
    flex-direction: column;
  }

  .topbar-actions,
  .detail-actions,
  .result-grid {
    width: 100%;
  }

  .button,
  .button-primary,
  .button-secondary {
    width: 100%;
  }

  .result-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }
}
