@font-face {
  font-family: "IBM Plex Sans";
  src: url("/assets/fonts/ibm-plex-sans-var.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("/assets/fonts/ibm-plex-mono-var.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
}

:root {
  --brand: #C9425E;
  --brand-hover: #B73752;
  --brand-soft: #F8E9EE;
  --on-brand: #FFFFFF;

  --page: #F4F6F8;
  --surface: #FFFFFF;
  --surface-subtle: #F7F8FA;
  --surface-active: #EEF1F4;
  --text: #171A1F;
  --muted: #68717D;
  --muted-2: #9098A3;
  --border: #DCE1E7;
  --border-strong: #C9D0D8;
  --success: #2F7A55;
  --danger: #C23B46;
  --backdrop: rgba(16, 18, 23, .52);

  --radius: 12px;
  --radius-sm: 9px;
  --shell: 1440px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --brand: #C9425E;
    --brand-hover: #D1516B;
    --brand-soft: #2B1A21;
    --on-brand: #FFFFFF;

    --page: #101217;
    --surface: #16191F;
    --surface-subtle: #1C2027;
    --surface-active: #232831;
    --text: #F5F7FA;
    --muted: #9CA4AF;
    --muted-2: #727B87;
    --border: #2A3038;
    --border-strong: #3A424C;
    --success: #67C793;
    --danger: #F07882;
    --backdrop: rgba(0, 0, 0, .68);

    color-scheme: dark;
  }
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  --brand: #C9425E;
  --brand-hover: #D1516B;
  --brand-soft: #2B1A21;
  --on-brand: #FFFFFF;

  --page: #101217;
  --surface: #16191F;
  --surface-subtle: #1C2027;
  --surface-active: #232831;
  --text: #F5F7FA;
  --muted: #9CA4AF;
  --muted-2: #727B87;
  --border: #2A3038;
  --border-strong: #3A424C;
  --success: #67C793;
  --danger: #F07882;
  --backdrop: rgba(0, 0, 0, .68);

  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--page);
  color: var(--text);
}

html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
  transition: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

code,
.mono {
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-variant-ligatures: none;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.shell {
  width: min(calc(100% - 32px), var(--shell));
  margin-inline: auto;
}

.hidden {
  display: none !important;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-small {
  width: 14px;
  height: 14px;
}

.site-header {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--border);
}

.brand {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: block;
  object-fit: contain;
  transform: translateY(-1px);
  flex: 0 0 auto;
}

.brand-word {
  color: var(--text);
  font-size: 19px;
  line-height: 1;
  font-weight: 650;
  letter-spacing: -.03em;
  display: inline-flex;
  align-items: baseline;
}

.brand-dot,
.brand-accent {
  color: var(--brand);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-switch {
  height: 34px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-subtle);
  display: inline-flex;
  align-items: center;
}

.lang-switch button {
  width: 34px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.lang-switch button:hover {
  color: var(--text);
}

.lang-switch button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}

.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  cursor: pointer;
  transition: background-color .14s ease, border-color .14s ease, color .14s ease;
}

.icon-button:hover {
  background: var(--surface-active);
  color: var(--text);
}

.header-restore {
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color .14s ease, color .14s ease;
}

.header-restore:hover {
  background: var(--surface-active);
  color: var(--text);
}

.boot-state {
  min-height: 180px;
  padding: 52px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
}

.boot-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.boot-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.boot-state.is-error .boot-spinner {
  display: none;
}

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

.button {
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .14s ease, border-color .14s ease, color .14s ease, opacity .14s ease;
}

.button:disabled {
  opacity: .56;
  cursor: wait;
}

.button-primary {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--on-brand);
}

.button-primary:hover:not(:disabled) {
  border-color: var(--brand-hover);
  background: var(--brand-hover);
}

.button-primary:active:not(:disabled) {
  transform: translateY(1px);
}

.button-primary.is-success {
  border-color: var(--success);
  background: var(--success);
}

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

.button-secondary:hover:not(:disabled) {
  background: var(--surface-active);
}

.button-quiet {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.button-quiet:hover:not(:disabled) {
  background: var(--surface-active);
  color: var(--text);
}

.button.full {
  width: 100%;
}

.inbox-shell {
  padding: 36px 0 64px;
}

.mailbox-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.mailbox-primary {
  padding: 24px;
}

.section-label {
  margin: 0;
}

.address-row {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
}

.address-row code {
  min-width: 0;
  color: var(--text);
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 30px;
  line-height: 1.18;
  font-weight: 650;
  letter-spacing: -.032em;
  font-variant-ligatures: normal;
  overflow-wrap: anywhere;
}

.copy-main {
  min-width: 124px;
}

.mailbox-meta {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.mailbox-meta strong {
  color: var(--text);
  font-weight: 500;
}

.meta-separator {
  color: var(--muted-2);
}

.status-active {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--success);
  font-weight: 500;
}

.mailbox-toolbar {
  min-height: 72px;
  padding: 14px 16px 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.password-tool {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.tool-icon {
  color: var(--muted);
}

.password-copy {
  min-width: 0;
}

.tool-label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  letter-spacing: .04em;
}

.password-copy code {
  display: block;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.password-copy code.is-note {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.password-note {
  display: block;
  margin-top: 4px;
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.45;
  max-width: 52ch;
}

.password-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.icon-only-tool {
  width: 36px;
  padding: 0;
  justify-content: center;
}

.tool-button {
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.tool-button:hover:not(:disabled) {
  background: var(--surface-active);
  color: var(--text);
}

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

.tool-button.is-success {
  color: var(--success);
}

.toolbar-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.latest-code-row {
  min-height: 46px;
  margin-top: 8px;
  padding: 0 4px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.utility-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
}

.utility-hint {
  display: none;
}

.latest-code-value {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--brand);
  font-size: 16px;
  font-weight: 650;
  cursor: pointer;
}

.latest-code-value.has-code:hover {
  border-color: var(--border);
  background: var(--brand-soft);
}

.latest-code-value:disabled {
  opacity: 1;
  cursor: default;
}

.clipboard-fallback {
  position: fixed;
  left: -9999px;
  top: 0;
  opacity: 0;
  pointer-events: none;
}

.inbox-workspace {
  margin-top: 16px;
  min-height: 500px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
}

.inbox-workspace.is-empty {
  min-height: 360px;
  grid-template-columns: 1fr;
}

.inbox-workspace.is-empty .messages-pane {
  border-right: 0;
}

.inbox-workspace.is-empty .reader-pane {
  display: none;
}

.inbox-workspace.is-empty .state-box {
  min-height: 300px;
}

.messages-pane {
  min-width: 0;
  border-right: 1px solid var(--border);
}

.workspace-head {
  min-height: 58px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.workspace-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -.01em;
}

.message-count {
  min-width: 26px;
  height: 24px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
}

.state-box,
.reader-empty {
  min-height: 360px;
  padding: 36px 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.state-icon,
.reader-empty-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--muted-2);
}

.state-icon .icon,
.reader-empty-icon .icon {
  width: 24px;
  height: 24px;
}

.state-box strong,
.reader-empty strong {
  margin-top: 13px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.state-box p,
.reader-empty p {
  max-width: 300px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.message-list {
  display: flex;
  flex-direction: column;
}

.message-item {
  appearance: none;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  position: relative;
}

.message-item:hover {
  background: var(--surface-subtle);
}

.message-item.active {
  background: var(--surface-active);
}

.message-item.active::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  background: var(--brand);
}

.message-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.message-from {
  min-width: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-time {
  flex: 0 0 auto;
  color: var(--muted-2);
  font-size: 10px;
}

.message-subject {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-preview {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-pane {
  min-width: 0;
}

.reader-empty {
  min-height: 498px;
}

.message-reader {
  padding: 24px;
}

.reader-head {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.reader-from {
  color: var(--muted);
  font-size: 12px;
}

.reader-head h2 {
  margin: 4px 0 0;
  color: var(--text);
  font-size: 22px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -.02em;
}

.reader-time {
  color: var(--muted-2);
  font-size: 10px;
  white-space: nowrap;
}

.code-strip {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.code-chip {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  font: 600 13px "IBM Plex Mono", monospace;
  cursor: pointer;
}

.code-chip:hover {
  border-color: var(--brand);
}

.message-reader pre {
  margin: 20px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  font: 400 14px/1.7 "IBM Plex Sans", system-ui, sans-serif;
}

.reader-links {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reader-links a {
  color: var(--brand);
  font-size: 12px;
  overflow-wrap: anywhere;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.dialog {
  width: min(calc(100% - 28px), 440px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .18);
}

.dialog::backdrop {
  background: var(--backdrop);
}

.dialog-card {
  padding: 24px;
}

.compact-dialog {
  padding-bottom: 20px;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.dialog-head h2 {
  margin: 5px 0 0;
  color: var(--text);
  font-size: 21px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -.02em;
}

.dialog-close {
  flex: 0 0 auto;
  margin-top: -6px;
  margin-right: -6px;
}

.dialog-copy {
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.dialog-card label {
  display: block;
  margin-top: 16px;
}

.dialog-card label > span {
  display: block;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
}

.dialog-card input {
  width: 100%;
  height: 44px;
  margin-top: 7px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--page);
  color: var(--text);
  outline: none;
}

.dialog-card input::placeholder {
  color: var(--muted-2);
}

.dialog-card .full {
  margin-top: 18px;
}

.dialog-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

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

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  max-width: min(90vw, 440px);
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .12);
}

@media (max-width: 720px) {
  .shell {
    width: min(calc(100% - 24px), var(--shell));
  }

  .site-header {
    min-height: 64px;
    gap: 8px;
  }

  .brand-mark {
    width: 29px;
    height: 29px;
  }

  .brand-word {
    font-size: 17px;
  }

  .header-actions {
    gap: 4px;
  }

  .lang-switch {
    height: 32px;
  }

  .lang-switch button {
    width: 30px;
    height: 26px;
    font-size: 10px;
  }

  .header-restore {
    padding-inline: 7px;
    font-size: 12px;
  }

  .inbox-shell {
    padding: 24px 0 48px;
  }

  .mailbox-primary {
    padding: 20px;
  }

  .address-row {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .address-row code {
    font-size: 22px;
    line-height: 1.3;
  }

  .copy-main {
    width: 100%;
    min-height: 44px;
  }

  .mailbox-toolbar {
    padding: 14px 16px;
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .password-tool {
    width: 100%;
  }

  .password-copy {
    flex: 1 1 auto;
  }

  .password-actions {
    flex: 0 0 auto;
  }

  .toolbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .toolbar-actions .button {
    min-height: 44px;
    padding-inline: 10px;
  }

  .latest-code-row {
    min-height: 64px;
    padding: 12px 2px;
    gap: 14px;
  }

  .latest-code-value {
    flex: 0 0 auto;
  }

  .inbox-workspace {
    margin-top: 12px;
    min-height: 0;
    grid-template-columns: 1fr;
  }

  .messages-pane {
    border-right: 0;
  }

  .reader-pane {
    border-top: 1px solid var(--border);
  }

  .state-box {
    min-height: 260px;
  }

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

  .message-reader {
    padding: 20px;
  }

  .reader-head {
    flex-direction: column;
    gap: 8px;
  }

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

  .dialog-card {
    padding: 20px;
  }

  .dialog-actions {
    flex-direction: column-reverse;
  }

  .dialog-actions .button {
    min-height: 44px;
    width: 100%;
  }
}

@media (max-width: 390px) {
  .header-restore span {
    display: none;
  }

  .header-restore {
    width: 40px;
    padding: 0;
    justify-content: center;
  }

  .lang-switch button {
    width: 28px;
  }

  .mailbox-meta {
    gap: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
