:root {
  color-scheme: light;
  --page: #f3f5f7;
  --surface: #ffffff;
  --surface-muted: #f7f8fa;
  --line: #dce1e6;
  --line-strong: #c6cdd4;
  --text: #1d252c;
  --text-muted: #68737d;
  --accent: #087f5b;
  --accent-hover: #066747;
  --accent-soft: #e9f6f1;
  --warning: #ad6800;
  --danger: #c92a2a;
  --danger-soft: #fff1f1;
  --shadow: 0 10px 30px rgba(29, 37, 44, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

[hidden] {
  display: none !important;
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef2f4;
}

.login-panel {
  width: min(100%, 400px);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-mark,
.brand-icon {
  display: inline-grid;
  place-items: center;
  color: #ffffff;
  background: var(--accent);
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 8px;
}

.brand-mark svg {
  width: 24px;
  height: 24px;
}

.login-heading {
  margin: 20px 0 28px;
}

.login-heading h1,
.workspace-heading h1,
.empty-state h2 {
  margin: 0;
  letter-spacing: 0;
}

.login-heading h1 {
  font-size: 24px;
  line-height: 1.25;
}

.login-heading p,
.workspace-heading p,
.empty-state p {
  margin: 6px 0 0;
  color: var(--text-muted);
}

.login-form,
.create-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-form label,
.ttl-control legend,
.alias-control > span {
  color: #374149;
  font-size: 13px;
  font-weight: 650;
}

.secret-field {
  position: relative;
}

.secret-field input {
  width: 100%;
  height: 44px;
  padding: 0 48px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: none;
}

.secret-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 127, 91, 0.14);
}

.secret-field .icon-button {
  position: absolute;
  top: 4px;
  right: 4px;
}

.form-error {
  margin: -4px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.primary-button {
  padding: 0 16px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 650;
}

.primary-button:hover {
  background: var(--accent-hover);
}

.secondary-button,
.danger-button {
  padding: 0 12px;
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.secondary-button:hover {
  background: var(--surface-muted);
  border-color: var(--line-strong);
}

.danger-button {
  color: var(--danger);
}

.danger-button:hover {
  background: var(--danger-soft);
  border-color: #ffc9c9;
}

.icon-button {
  width: 38px;
  padding: 0;
  background: transparent;
  color: var(--text-muted);
}

.icon-button:hover {
  color: var(--text);
  background: #edf0f2;
}

.login-button {
  width: 100%;
  height: 44px;
  margin-top: 4px;
}

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

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.header-inner {
  width: min(100% - 32px, 1180px);
  height: 60px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-inline,
.header-actions,
.section-bar,
.mailbox-meta,
.mailbox-actions,
.otp-row,
.message-meta {
  display: flex;
  align-items: center;
}

.brand-inline {
  gap: 10px;
  font-size: 15px;
  font-weight: 720;
}

.brand-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
}

.brand-icon svg {
  width: 17px;
  height: 17px;
}

.header-actions {
  gap: 4px;
}

.connection-state {
  margin-right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 13px;
}

.connection-state span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2f9e44;
}

.connection-state.offline span {
  background: var(--danger);
}

.workspace {
  width: min(100% - 32px, 1180px);
  margin: 0 auto;
  padding: 34px 0 64px;
}

.workspace-heading {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 28px;
  align-items: end;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.workspace-heading h1 {
  font-size: 25px;
  line-height: 1.25;
}

.workspace-heading p {
  font-size: 14px;
}

.create-controls {
  flex-direction: row;
  align-items: end;
}

.alias-control {
  width: 176px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.alias-control input {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

.alias-control input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 127, 91, 0.14);
}

.ttl-control {
  margin: 0;
  padding: 0;
  border: 0;
}

.ttl-control legend {
  margin-bottom: 7px;
}

.segments {
  height: 38px;
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #e9edf0;
}

.segments label {
  position: relative;
}

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

.segments span {
  min-width: 68px;
  height: 30px;
  padding: 0 9px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.segments input:checked + span {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(29, 37, 44, 0.12);
}

.segments input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.mailbox-section {
  padding-top: 26px;
}

.section-bar {
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-bar h2 {
  margin: 0;
  font-size: 15px;
}

.count-label {
  color: var(--text-muted);
  font-size: 13px;
}

.address-list {
  display: grid;
  gap: 14px;
}

.mailbox-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 3px 12px rgba(29, 37, 44, 0.04);
}

.mailbox-header {
  min-height: 64px;
  padding: 13px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.address-name {
  min-width: 0;
  margin: 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.mailbox-meta {
  margin-top: 5px;
  gap: 10px;
  color: var(--text-muted);
  font-size: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
}

.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.countdown {
  min-width: 72px;
  font-variant-numeric: tabular-nums;
}

.mailbox-actions {
  gap: 6px;
}

.mailbox-content {
  display: grid;
  grid-template-columns: minmax(210px, 0.34fr) minmax(0, 0.66fr);
  border-top: 1px solid var(--line);
}

.otp-panel,
.messages-panel {
  min-width: 0;
  padding: 18px 16px;
}

.otp-panel {
  border-right: 1px solid var(--line);
  background: #fbfcfc;
}

.panel-label {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
}

.otp-row {
  min-height: 42px;
  justify-content: space-between;
  gap: 12px;
}

.otp-code {
  min-width: 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 28px;
  font-weight: 760;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.otp-code.pending {
  color: #a1a9b0;
  font-size: 18px;
  font-weight: 600;
}

.message-list {
  display: grid;
}

.message-row {
  min-width: 0;
  padding: 12px 0;
  border-top: 1px solid #edf0f2;
}

.message-row:first-child {
  padding-top: 0;
  border-top: 0;
}

.message-subject {
  margin: 0;
  font-size: 13px;
  font-weight: 680;
  overflow-wrap: anywhere;
}

.message-meta {
  justify-content: space-between;
  gap: 12px;
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 11px;
}

.message-sender {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-preview {
  margin: 7px 0 0;
  color: #4f5b64;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.panel-empty {
  min-height: 52px;
  display: flex;
  align-items: center;
  color: var(--text-muted);
  font-size: 13px;
}

.empty-state {
  min-height: 280px;
  border-top: 1px solid var(--line);
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  color: var(--text-muted);
}

.empty-state svg {
  width: 34px;
  height: 34px;
  margin-bottom: 14px;
  color: #8b969f;
}

.empty-state h2 {
  color: var(--text);
  font-size: 16px;
}

.empty-state p {
  font-size: 13px;
}

.api-docs {
  margin-top: 34px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.api-docs-summary {
  min-height: 68px;
  padding: 14px 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  cursor: pointer;
  list-style: none;
}

.api-docs-summary::-webkit-details-marker {
  display: none;
}

.api-docs-summary > span:first-child {
  display: grid;
  gap: 5px;
}

.api-docs-summary strong {
  font-size: 15px;
}

.api-docs-summary small {
  color: var(--text-muted);
  font-size: 12px;
}

.api-docs-disclosure {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  transition: transform 160ms ease;
}

.api-docs[open] .api-docs-disclosure {
  transform: rotate(180deg);
}

.api-docs-content {
  padding: 22px 0 26px;
  border-top: 1px solid var(--line);
}

.api-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.api-meta > div {
  min-width: 0;
  padding: 14px 16px;
  display: grid;
  gap: 7px;
}

.api-meta > div + div {
  border-left: 1px solid var(--line);
}

.api-label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 680;
}

.api-meta code,
.endpoint-row code,
.api-request-bodies code,
.api-example code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  overflow-wrap: anywhere;
}

.api-meta code {
  font-size: 12px;
}

.endpoint-list {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.endpoint-row {
  min-height: 48px;
  padding: 9px 12px;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) minmax(170px, 0.34fr);
  align-items: center;
  gap: 12px;
}

.endpoint-row + .endpoint-row {
  border-top: 1px solid var(--line);
}

.endpoint-row code {
  color: #26333c;
  font-size: 12px;
}

.method-badge {
  width: 56px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  font-weight: 760;
}

.method-badge.get {
  color: #087f5b;
  background: #e9f6f1;
}

.method-badge.post {
  color: #145da0;
  background: #eaf3fb;
}

.method-badge.delete {
  color: var(--danger);
  background: var(--danger-soft);
}

.endpoint-description {
  color: var(--text-muted);
  font-size: 12px;
}

.api-request-bodies {
  margin-top: 18px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.api-request-bodies .api-label {
  margin-right: 4px;
}

.api-request-bodies code {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  font-size: 11px;
}

.api-example {
  margin-top: 18px;
}

.api-example-header {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.api-example pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  border-radius: 6px;
  background: #20282e;
  color: #edf2f4;
  line-height: 1.65;
}

.api-example code {
  font-size: 12px;
  white-space: pre;
}

.toast-region {
  position: fixed;
  z-index: 50;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  width: min(340px, calc(100vw - 40px));
  padding: 11px 14px;
  border: 1px solid #b8dfd1;
  border-radius: 6px;
  background: #f0faf6;
  box-shadow: var(--shadow);
  color: #145c45;
  font-size: 13px;
}

.toast.error {
  border-color: #ffc9c9;
  background: var(--danger-soft);
  color: var(--danger);
}

.spinning svg {
  animation: spin 0.9s linear infinite;
}

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

@media (max-width: 1040px) {
  .workspace-heading {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .create-controls {
    justify-content: space-between;
  }
}

@media (max-width: 820px) {
  .mailbox-content {
    grid-template-columns: 1fr;
  }

  .otp-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 620px) {
  .header-inner,
  .workspace {
    width: min(100% - 24px, 1180px);
  }

  .connection-state {
    display: none;
  }

  .workspace {
    padding-top: 24px;
  }

  .create-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .alias-control {
    width: 100%;
  }

  .segments {
    width: 100%;
  }

  .segments label {
    flex: 1;
  }

  .segments span {
    min-width: 0;
    padding: 0 4px;
  }

  .mailbox-header {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .mailbox-actions {
    justify-content: flex-start;
  }

  .mailbox-actions .secondary-button,
  .mailbox-actions .danger-button {
    flex: 1;
  }

  .message-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .message-sender {
    width: 100%;
  }

  .login-panel {
    padding: 26px 22px;
  }

  .api-meta {
    grid-template-columns: 1fr;
  }

  .api-meta > div + div {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .endpoint-row {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 8px;
  }

  .endpoint-description {
    grid-column: 1 / -1;
    padding-left: 72px;
  }

  .api-request-bodies {
    align-items: flex-start;
    flex-direction: column;
  }

  .api-example pre {
    padding: 14px;
  }

  .api-example code {
    font-size: 11px;
  }
}

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