:root {
  color-scheme: light;
  --ink: #272725;
  --muted: #67665e;
  --line: #e7e3da;
  --paper: #fffefa;
  --bg: #f5f3ed;
  --accent: #a64525;
  --accent-dark: #87371e;
  --accent-wash: #f8eae0;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
[hidden] { display: none !important; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
a { color: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, h3, p, ul { margin: 0; }
ul { list-style: none; padding: 0; }

.topbar { border-bottom: 1px solid var(--line); background: var(--paper); }
.topbar-inner {
  min-height: 65px; max-width: 1480px; margin: auto; padding: 0 36px;
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
}
.brand, .top-actions { display: flex; align-items: center; gap: 12px; }
.brand { font-size: 16px; font-weight: 750; letter-spacing: .05em; }
.brand-icon, .current-icon, .empty-icon {
  display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px;
}
.brand-icon { width: 34px; height: 34px; background: var(--accent); color: white; }
.top-actions { gap: 20px; font-size: 12px; color: var(--muted); }
.mode { background: #eeeae1; color: #545149; border-radius: 20px; padding: 5px 10px; white-space: nowrap; }
.mode.demo { background: var(--accent-wash); color: var(--accent-dark); }
.lang-toggle {
  border: 1px solid var(--line); background: var(--paper); color: var(--muted);
  border-radius: 20px; padding: 5px 12px; font-size: 12px; font-weight: 650;
  letter-spacing: .02em; line-height: 1.4; white-space: nowrap;
}
.lang-toggle:hover { border-color: var(--accent); color: var(--accent-dark); }

.layout {
  max-width: 1480px; margin: auto; padding: 30px 36px 22px;
  display: grid; grid-template-columns: minmax(250px, 300px) minmax(0, 1fr); gap: 26px; align-items: start;
}
.sidebar { min-width: 0; display: grid; align-content: start; gap: 12px; }
.access-card {
  display: grid; gap: 10px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 15px; padding: 18px;
}
.access-card h1 { font-size: 23px; }
.access-card h2 { font-size: 15px; font-weight: 700; }
.access-card label { font-size: 13px; font-weight: 650; margin-top: 4px; }
.access-help { color: var(--muted); font-size: 13px; line-height: 1.55; }
.access-card input, .access-card select, .token-export {
  width: 100%; min-width: 0; height: 45px; padding: 8px 12px;
  border: 1px solid #d9d3c7; border-radius: 8px; background: #fff; color: var(--ink);
}
.access-card .primary { min-height: 46px; margin-top: 4px; font-size: 14px; }
.access-card .alert { overflow-wrap: anywhere; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.known { display: grid; gap: 4px; max-height: 270px; overflow: auto; }
.known-item {
  display: grid; gap: 3px; width: 100%; padding: 10px; text-align: left; font-size: 12px; line-height: 1.4;
  border: 1px solid transparent; border-radius: 8px; color: var(--ink); background: transparent; overflow-wrap: anywhere;
}
.known-item:hover { background: #f5f1e9; }
.known-item[aria-current="true"] { border-color: #eedacc; background: var(--accent-wash); color: var(--accent-dark); }
.known-item:focus-visible { outline-offset: -3px; }
.known-item span { color: var(--muted); font-size: 11px; }
.create-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.create-actions button { padding-inline: 5px; }
.custom-form { display: grid; gap: 7px; }
.workspace-empty {
  display: grid; justify-items: center; place-content: center; gap: 12px;
  min-height: 395px; padding: 28px; border: 1px solid var(--line); border-radius: 15px;
  background: var(--paper); text-align: center;
}
.workspace-empty h2 { font-size: 20px; }
.workspace-empty p { font-size: 14px; color: var(--muted); }
.inbox-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.inbox-tools .button { min-height: 34px; padding-inline: 10px; font-size: 12px; }
.token-export { font: 13px Consolas, monospace; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 40px; padding: 0 13px; border-radius: 9px; border: 1px solid transparent;
  font-size: 13px; font-weight: 650; white-space: nowrap;
}
.primary { color: white; background: var(--accent); }
.primary:hover:enabled { background: var(--accent-dark); }
.outline { background: var(--paper); color: var(--ink); border-color: var(--line); }
.outline:hover:enabled { background: #f0ebe2; }
.more { color: var(--accent-dark); background: transparent; margin: 8px 11px; min-height: 32px; }
.more:hover:enabled { background: var(--accent-wash); }
.icon-button {
  width: 34px; height: 34px; display: inline-grid; place-items: center; padding: 0;
  color: var(--muted); border: 0; border-radius: 8px; background: transparent;
}
.icon-button:hover:enabled { color: var(--accent); background: var(--accent-wash); }

.workspace { min-width: 0; display: grid; gap: 14px; }
.current {
  display: flex; gap: 16px; align-items: center; min-height: 94px; padding: 16px 20px;
  border: 1px solid var(--line); border-radius: 15px; background: var(--paper);
}
.current-icon { width: 48px; height: 48px; background: var(--accent-wash); color: var(--accent-dark); }
.current-text { flex: 1; min-width: 0; }
.caption { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
#address { font-size: clamp(18px, 2.5vw, 26px); line-height: 1.25; font-weight: 730; overflow-wrap: anywhere; }
.alert { color: #7f321a; background: var(--accent-wash); border: 1px solid #eedacc; padding: 12px 16px; border-radius: 9px; font-size: 13px; }
.mailbox {
  display: grid; grid-template-columns: minmax(235px, .83fr) minmax(0, 1.5fr);
  min-height: clamp(510px, 68vh, 830px); background: var(--paper); border: 1px solid var(--line); border-radius: 15px; overflow: clip;
}
.mail-list { min-width: 0; border-right: 1px solid var(--line); }
.list-header { padding: 15px 15px 6px 19px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.list-heading { display: flex; align-items: center; gap: 9px; }
.list-heading h2 { font-size: 18px; font-weight: 740; white-space: nowrap; }
.count { min-width: 24px; padding: 3px 7px; border-radius: 20px; text-align: center; color: var(--muted); background: #f0ede6; font-size: 11px; font-variant-numeric: tabular-nums; }
.inbox-options {
  min-height: 42px; padding: 0 17px 9px 19px; display: flex; align-items: center;
  justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line);
}
.poll { color: var(--muted); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.poll input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.text-button { border: 0; padding: 4px 0; background: transparent; color: var(--accent-dark); font-size: 12px; white-space: nowrap; }
.text-button:hover:enabled { text-decoration: underline; }
.list-state { font-size: 13px; color: var(--muted); padding: 22px 19px; }
.message-button {
  display: grid; grid-template-columns: 36px minmax(0, 1fr); align-items: start; gap: 10px;
  width: 100%; min-height: 83px; padding: 14px 15px 13px 17px;
  text-align: left; color: var(--ink); border: 0; border-left: 3px solid transparent;
  border-bottom: 1px solid #f0ece4; background: transparent;
}
.message-button:focus-visible { outline-offset: -4px; }
.message-button:hover { background: #f8f5ee; }
.message-button[aria-current="true"] { border-left-color: var(--accent); background: #fbefe6; }
.message-meta { min-width: 0; display: grid; gap: 5px; }
.subject-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.subject-line strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread { flex: 0 0 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.preview-meta { display: flex; justify-content: space-between; gap: 7px; font-size: 11px; color: var(--muted); }
.preview-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-meta time { white-space: nowrap; }
.avatar {
  display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px;
  color: #755134; background: #f2e6d5; border-radius: 50%; font-size: 13px; font-weight: 720;
}

.reading { min-width: 0; position: relative; }
.reading-state { min-height: 410px; height: 100%; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 25px; color: var(--muted); text-align: center; font-size: 14px; }
.empty-icon { width: 62px; height: 62px; background: #f0ebe2; color: #826850; }
.empty-icon .icon { transform: scale(1.25); }
.reading-content { padding: 25px clamp(18px, 3vw, 35px) 32px; }
.letter-header h2 { font-size: clamp(20px, 2vw, 25px); line-height: 1.35; overflow-wrap: anywhere; }
.sender { display: flex; align-items: center; gap: 10px; margin: 14px 0 19px; }
.sender-text { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.sender strong { font-size: 13px; }
.sender-text span, .sender time { font-size: 11px; color: var(--muted); }
.sender time { margin-left: auto; text-align: right; flex: 0 0 auto; }
.verification { display: grid; gap: 10px; margin-bottom: 23px; }
.otp-card {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 15px 17px; background: #f8ebe1; border: 1px solid #f0ddd0; border-radius: 10px;
}
.otp-card div { min-width: 0; }
.otp-card h3 { color: #734b36; font-size: 12px; font-weight: 650; margin-bottom: 5px; }
.otp-card output { font: 750 clamp(22px, 3vw, 32px)/1.25 Consolas, monospace; color: var(--accent-dark); letter-spacing: .12em; overflow-wrap: anywhere; }
.otp-card .button { min-height: 34px; font-size: 12px; }
.related { display: grid; gap: 7px; }
.related h3, .body-section h3 { color: var(--muted); font-size: 12px; font-weight: 660; }
.related ul { display: flex; flex-wrap: wrap; gap: 7px; min-width: 0; }
.link-item, .candidate { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; font-size: 12px; background: var(--paper); }
.link-item a { color: var(--accent-dark); overflow-wrap: anywhere; }
.link-item button { flex: 0 0 auto; }
.candidate { color: var(--accent-dark); overflow-wrap: anywhere; }
.candidate:hover { background: var(--accent-wash); }
.body-section { border-top: 1px solid var(--line); padding-top: 14px; }
.body-text { margin-top: 10px; font-size: 14px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.workspace-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 7px 12px; padding: 1px 3px; font-size: 12px; color: var(--muted); min-height: 20px; }

.icon { display: inline-block; position: relative; flex: 0 0 auto; color: inherit; }
.envelope { width: 17px; height: 12px; border: 1.5px solid currentColor; border-radius: 2px; overflow: hidden; }
.envelope::after { content: ""; position: absolute; width: 10px; height: 10px; left: 2px; top: -6px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.refresh { width: 13px; height: 13px; border: 1.5px solid currentColor; border-right-color: transparent; border-radius: 50%; transform: rotate(-35deg); }
.refresh::after { content: ""; position: absolute; width: 5px; height: 5px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; top: -.5px; right: -1px; }
.copy { width: 11px; height: 12px; border: 1.25px solid currentColor; border-radius: 2px; margin: 2px 2px 0 0; }
.copy::after { content: ""; position: absolute; width: 9px; height: 10px; border: solid currentColor; border-width: 1.25px 1.25px 0 0; border-radius: 2px; left: 3px; top: -4px; }

@media (max-width: 1000px) {
  .topbar-inner { padding-inline: 22px; }
  .layout { grid-template-columns: minmax(200px, 240px) minmax(0, 1fr); gap: 16px; padding-inline: 22px; }
  .mailbox { grid-template-columns: minmax(198px, .85fr) minmax(0, 1.5fr); }
}
@media (max-width: 780px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding-top: 16px; }
  .workspace-empty { min-height: 225px; }
}
@media (max-width: 565px) {
  .topbar-inner { padding-inline: 14px; min-height: 56px; }
  .top-actions { gap: 10px; }
  .layout { padding-inline: 12px; }
  .current { flex-wrap: wrap; padding: 12px; gap: 9px; min-height: auto; }
  .current-icon { width: 36px; height: 36px; }
  .current .button { min-height: 34px; padding-inline: 8px; font-size: 12px; }
  .mailbox { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .mail-list { border-right: 0; border-bottom: 1px solid var(--line); }
  .messages { max-height: 245px; overflow: auto; }
  .reading-state { min-height: 200px; }
  .reading-content { padding-top: 18px; }
  .sender { flex-wrap: wrap; }
}
