:root {
  color-scheme: light;
  --bg: #f4f3f6;
  --text: #2c2330;
  --muted: #7b6f7a;
  --surface: #ffffff;
  --surface-soft: #fbf7f9;
  --border: #e7dde3;
  --border-strong: #d8c1cd;
  --active: #8a4566;
  --active-text: #ffffff;
  --accent: #d37a9d;
  --accent-soft: #f7e6ee;
  --error: #a7371d;
  --success: #1f6a3a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  min-height: 100vh;
}

.app-header {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
}

.header-inner {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 0.9rem 1.4rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.shell {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 1.15rem 1.4rem 1.75rem;
}

.workspace-shell {
  display: grid;
  gap: 1.1rem;
  padding: 0;
}

.account-shell {
  flex: 1 1 24rem;
}

.account-controls {
  display: flex;
}

.account-select {
  width: 100%;
  min-height: 3rem;
  padding: 0 0.95rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
}

.tab-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 0 1 auto;
  margin-left: auto;
  flex-wrap: wrap;
}

.tab-list {
  display: inline-flex;
  gap: 0.35rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.tab-trigger {
  border: 0;
  border-radius: 999px;
  padding: 0.75rem 1rem;
  font: inherit;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}

.tab-trigger:hover,
.tab-trigger:focus-visible {
  background: var(--accent-soft);
  color: var(--text);
  outline: none;
}

.tab-trigger.is-active {
  background: var(--active);
  color: var(--active-text);
}

.tab-action {
  display: flex;
}

.tab-action[hidden] {
  display: none;
}

.mail-toolbar,
.phone-toolbar {
  padding: 0;
  border: 0;
  background: transparent;
  backdrop-filter: none;
}

.mail-button,
.phone-button {
  min-height: 2.85rem;
  min-width: 5.5rem;
  padding: 0 1rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--active-text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.mail-button:hover,
.mail-button:focus-visible,
.phone-button:hover,
.phone-button:focus-visible {
  background: #c9658d;
  border-color: #c9658d;
  outline: none;
}

.mail-button[disabled],
.phone-button[disabled] {
  cursor: not-allowed;
  opacity: 0.55;
}

.mail-toolbar.is-loading .mail-button,
.phone-toolbar.is-loading .phone-button {
  opacity: 1;
  cursor: wait;
  background: var(--active);
  border-color: var(--active);
}

.tab-panel {
  min-height: 1px;
  display: grid;
  gap: 0.9rem;
}

.tab-panel[hidden] {
  display: none;
}

.flash {
  margin: 0;
  padding: 0.85rem 0.95rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: 0.94rem;
}

.flash-error {
  color: var(--error);
  border-color: rgba(167, 55, 29, 0.18);
  background: #fff0f0;
}

.flash-success {
  color: var(--success);
  border-color: rgba(31, 106, 58, 0.18);
  background: #f4fff8;
}

.mail-results-shell,
.sms-results-shell {
  min-height: 2rem;
}

.mail-list,
.sms-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.75rem;
  width: 100%;
}

.mail-item,
.sms-item {
  padding: 0.95rem 1rem;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.mail-item.is-open {
  border-color: var(--border-strong);
}

.mail-summary {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.mail-summary-main {
  min-width: 0;
  display: grid;
  gap: 0.35rem;
}

.mail-subject {
  font-weight: 700;
  line-height: 1.3;
}

.mail-from,
.mail-time,
.sms-time,
.sms-empty {
  color: var(--muted);
  font-size: 0.92rem;
}

.mail-time {
  white-space: nowrap;
}

.mail-panel {
  margin-top: 0.85rem;
}

.mail-panel[hidden] {
  display: none;
}

.mail-render {
  margin-top: 0.75rem;
}

.mail-body {
  margin: 0;
  padding: 0.95rem 1rem;
  border-radius: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  font: inherit;
  line-height: 1.6;
}

.mail-frame {
  width: 100%;
  min-height: 12rem;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  display: block;
  overflow: hidden;
}

.mail-empty,
.sms-empty {
  margin: 0;
  padding: 1rem;
  border-radius: 14px;
  background: var(--surface-soft);
  border: 1px dashed var(--border-strong);
}

.mail-fetching {
  display: grid;
  gap: 0.75rem;
}

.otp-fetching {
  width: 100%;
  min-height: clamp(12rem, 42vh, 22rem);
  display: grid;
  place-items: center;
}

.mail-skeleton {
  padding: 0.95rem 1rem;
  border-radius: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.mail-skeleton-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.mail-skeleton-line {
  display: block;
  height: 0.95rem;
  border-radius: 999px;
  background: #edd7e1;
  animation: skeleton-pulse 1s ease-in-out infinite alternate;
}

.mail-skeleton-line + .mail-skeleton-line {
  margin-top: 0.6rem;
}

.mail-skeleton-line.subject {
  width: min(68%, 34rem);
  height: 1.1rem;
}

.mail-skeleton-line.meta {
  width: min(32%, 14rem);
}

.mail-skeleton-line.time {
  width: min(22%, 9rem);
}

.otp-loader {
  display: grid;
  place-items: center;
}

.otp-spinner {
  width: 12px;
  height: 12px;
  display: block;
  margin: 0 auto;
  position: relative;
  border-radius: 50%;
  box-sizing: border-box;
  color: var(--accent);
  animation: otp-dot-loader 1s linear infinite alternate;
}

@keyframes skeleton-pulse {
  from {
    opacity: 0.65;
  }
  to {
    opacity: 1;
  }
}

@keyframes otp-dot-loader {
  0% {
    box-shadow:
      -38px -12px 0 0 currentColor,
      -14px 0 0 0 currentColor,
      14px 0 0 0 currentColor,
      38px 0 0 0 currentColor;
  }
  33% {
    box-shadow:
      -38px 0 0 0 currentColor,
      -14px -12px 0 0 currentColor,
      14px 0 0 0 currentColor,
      38px 0 0 0 currentColor;
  }
  66% {
    box-shadow:
      -38px 0 0 0 currentColor,
      -14px 0 0 0 currentColor,
      14px -12px 0 0 currentColor,
      38px 0 0 0 currentColor;
  }
  100% {
    box-shadow:
      -38px 0 0 0 currentColor,
      -14px 0 0 0 currentColor,
      14px 0 0 0 currentColor,
      38px -12px 0 0 currentColor;
  }
}

.mail-toolbar.is-loading .mail-button,
.phone-toolbar.is-loading .phone-button {
  position: relative;
}

.mail-toolbar.is-loading .mail-button::before,
.phone-toolbar.is-loading .phone-button::before {
  content: "";
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  margin-right: 0.55rem;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 999px;
  vertical-align: -0.1rem;
  animation: spin 700ms linear infinite;
}

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

.sms-head {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
}

.sms-parties,
.sms-from,
.sms-meta,
.sms-to,
.sms-code,
.sms-text {
  margin: 0;
}

.sms-parties {
  display: grid;
  gap: 0.45rem;
}

.sms-from {
  font-weight: 700;
  font-size: 1.02rem;
  line-height: 1.2;
}

.sms-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.sms-to {
  padding: 0.32rem 0.62rem;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.92rem;
}

.sms-code {
  padding: 0.32rem 0.68rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--active);
  border: 1px solid rgba(217, 116, 155, 0.22);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.sms-text {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 760px) {
  .header-inner {
    padding: 0.85rem 1rem;
  }

  .shell {
    padding: 0.9rem 1rem 1.25rem;
  }

  .tab-bar {
    margin-left: 0;
    width: 100%;
    align-items: stretch;
  }

  .tab-list {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .tab-action {
    margin-left: 0;
    width: 100%;
  }

  .mail-toolbar,
  .phone-toolbar {
    width: 100%;
  }

  .mail-button,
  .phone-button {
    width: 100%;
  }

  .mail-summary,
  .sms-head {
    flex-direction: column;
  }

  .mail-time {
    white-space: normal;
  }
}
