:root {
  --bg: #f4f5f8;
  --panel: #ffffff;
  --panel-soft: #fafafa;
  --panel-muted: #f6f7f9;
  --text: #171717;
  --muted: #667085;
  --subtle: #98a2b3;
  --line: #e5e7eb;
  --line-strong: #d9dce3;
  --black: #111111;
  --blue: #3867f0;
  --blue-soft: #eef3ff;
  --green: #16a34a;
  --green-soft: #ecfdf3;
  --red: #dc3545;
  --red-soft: #fff1f2;
  --shadow: 0 16px 36px rgba(15, 23, 42, 0.08);
  --shadow-strong: 0 24px 56px rgba(15, 23, 42, 0.16);
  --radius-lg: 18px;
  --radius-md: 14px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0d1117;
  --panel: #111827;
  --panel-soft: #151d2b;
  --panel-muted: #172033;
  --text: #edf2f7;
  --muted: #a3adbd;
  --subtle: #7d8795;
  --line: #263244;
  --line-strong: #334155;
  --black: #f8fafc;
  --blue: #60a5fa;
  --blue-soft: rgba(96, 165, 250, 0.14);
  --green: #4ade80;
  --green-soft: rgba(74, 222, 128, 0.12);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.12);
  --shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
  --shadow-strong: 0 24px 56px rgba(0, 0, 0, 0.34);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.5;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: #a3a3a3;
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

.navbar {
  height: 56px;
  display: grid;
  grid-template-columns: minmax(220px, 430px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.navbar-brand,
.navbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.navbar-brand {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
}

.navbar-center {
  display: flex;
  justify-content: center;
  min-width: 0;
}

.current-account {
  max-width: min(520px, 100%);
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 22px;
  border: none;
  border-radius: 999px;
  background: var(--panel-muted);
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.navbar-btn,
.language-toggle,
.theme-toggle,
.primary-button,
.secondary-button,
.refresh-btn,
.folder-tab,
.mail-filter-btn,
.sort-btn,
.detail-action {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-weight: 700;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.navbar-btn {
  min-height: 38px;
  padding: 0 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-muted) 100%);
  color: #475467;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.04);
}

.language-toggle,
.theme-toggle {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px 0 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-muted) 100%);
  color: #475467;
}

.language-toggle {
  justify-content: center;
  min-width: 58px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--text);
}

.theme-toggle-icon {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--black);
  color: var(--panel);
  font-size: 14px;
  line-height: 1;
}

.navbar-btn:hover,
.language-toggle:hover,
.theme-toggle:hover,
.secondary-button:hover,
.refresh-btn:hover:not(:disabled),
.folder-tab:hover,
.mail-filter-btn:hover,
.sort-btn:hover,
.detail-action:hover {
  transform: translateY(-1px);
  border-color: #cbd5e1;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
}

.main-container {
  display: flex;
  height: calc(100vh - 56px);
  min-height: 0;
}

.group-panel {
  width: 210px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--panel-soft);
}

.panel-header {
  height: 56px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title {
  font-size: 15px;
  font-weight: 800;
}

.group-list {
  flex: 1;
  overflow: auto;
}

.group-item {
  width: 100%;
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  border: none;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: background-color 0.15s, border-color 0.15s;
}

.group-item:hover {
  background: #f0f0f0;
}

.group-item.active {
  border-left-color: var(--black);
  background: #e9e9e9;
}

:root[data-theme="dark"] .group-item:hover {
  background: #182235;
}

:root[data-theme="dark"] .group-item.active {
  background: #1f2a3d;
}

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

.group-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: 0 0 auto;
}

.dot-blue {
  background: #45b8ef;
}

.dot-dark {
  background: var(--black);
}

.dot-gray {
  background: #666666;
}

.group-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 750;
}

.group-count {
  min-height: 25px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  width: fit-content;
  margin-left: 20px;
}

.group-count {
  padding: 0 10px;
  background: #eeeeee;
  color: #9a9a9a;
}

:root[data-theme="dark"] .group-count,
:root[data-theme="dark"] .account-total,
:root[data-theme="dark"] .method-tag {
  background: #202b3c;
  color: #a3adbd;
}

.account-panel {
  width: 360px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.account-panel-header {
  min-height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-panel-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 800;
}

.account-panel-title span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-color {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: #666666;
  flex: 0 0 auto;
}

.import-box {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-muted) 100%);
}

.import-label,
.toolbar-label {
  display: inline-flex;
  color: #475467;
  font-size: 13px;
  font-weight: 750;
}

.bulk-input {
  width: 100%;
  min-height: 104px;
  margin-top: 8px;
  padding: 12px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.bulk-input:focus,
.search-input:focus,
.toolbar-select:focus,
.mail-search-input:focus {
  border-color: var(--black);
  box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.08);
}

.import-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.primary-button,
.secondary-button {
  min-height: 38px;
  padding: 0 14px;
}

.primary-button {
  background: var(--black);
  border-color: var(--black);
  color: var(--panel);
  box-shadow: 0 12px 24px rgba(17, 17, 17, 0.16);
}

.secondary-button {
  color: #475467;
}

.account-toolbar {
  display: grid;
  gap: 11px;
  padding: 14px 16px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fafafa 0%, #f4f5f8 100%);
}

:root[data-theme="dark"] .account-toolbar {
  background: linear-gradient(180deg, #111827 0%, #151d2b 100%);
}

.search-input,
.toolbar-select,
.mail-search-input {
  width: 100%;
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  outline: none;
  box-shadow: 0 5px 14px rgba(15, 23, 42, 0.03);
}

.toolbar-select {
  appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, #667085 50%),
    linear-gradient(135deg, #667085 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 17px,
    calc(100% - 13px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.toolbar-row,
.toolbar-chip-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sort-btn {
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  color: #4b5563;
  font-size: 13px;
}

.sort-btn.active {
  background: var(--black);
  border-color: var(--black);
  color: var(--panel);
  box-shadow: 0 8px 18px rgba(17, 17, 17, 0.14);
}

.account-total {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: #eeeeee;
  color: #8a8a8a;
  font-size: 13px;
  font-weight: 750;
}

.account-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 16px 18px;
}

.account-item {
  width: 100%;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  padding: 18px 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.account-item:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.account-item.active {
  border: 2px solid var(--black);
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.12);
}

.account-avatar {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--blue), #7c3aed);
  color: #ffffff;
  font-size: 16px;
  font-weight: 900;
}

.account-main {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.account-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}

.account-tags {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.provider-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--blue);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.content-area {
  flex: 1;
  display: flex;
  min-width: 0;
  min-height: 0;
}

.mobile-quickbar {
  display: none;
}

.email-list-panel {
  width: 430px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--panel-soft);
}

.email-list-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}

.email-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.email-title-wrap h2 {
  margin: 0;
  font-size: 20px;
}

.email-count {
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.refresh-btn {
  min-height: 38px;
  padding: 0 18px;
  background: var(--panel);
}

.refresh-btn:not(:disabled) {
  background: var(--black);
  border-color: var(--black);
  color: var(--panel);
  box-shadow: 0 12px 24px rgba(17, 17, 17, 0.16);
}

.email-toolbar {
  display: grid;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-soft) 0%, var(--panel-muted) 100%);
}

.method-row {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.method-tag {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 999px;
  background: #edf2f7;
  color: #475569;
  font-size: 13px;
  font-weight: 800;
}

:root[data-theme="dark"] .method-tag {
  background: #1f2a3a;
  color: #d6deea;
}

:root[data-theme="dark"] .mobile-quickbar {
  background: linear-gradient(180deg, #111827 0%, #151d2b 100%);
}

.folder-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 4px;
  border-radius: 16px;
  background: var(--panel-muted);
}

.folder-tab {
  min-height: 40px;
  padding: 0 10px;
  border-color: transparent;
  color: #667085;
  background: transparent;
  font-size: 14px;
}

.folder-tab.active {
  background: var(--black);
  color: var(--panel);
  box-shadow: 0 10px 20px rgba(17, 17, 17, 0.16);
}

.email-filter-row {
  display: grid;
  grid-template-columns: 132px 104px minmax(0, 1fr);
  gap: 10px;
}

.toolbar-select,
.mail-search-input {
  min-height: 38px;
  border-radius: 12px;
  font-size: 13px;
}

.mail-filter-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mail-filter-btn {
  min-height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  color: #667085;
  font-size: 13px;
}

.mail-filter-btn.active {
  background: var(--black);
  border-color: var(--black);
  color: var(--panel);
}

.mail-status,
.empty-state {
  margin: 14px;
  padding: 24px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 18px;
  background: var(--panel-muted);
  color: var(--muted);
  text-align: center;
  font-size: 14px;
  font-weight: 750;
}

.email-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 16px 18px;
}

.email-item {
  width: 100%;
  display: grid;
  grid-template-columns: 5px minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 12px;
  padding: 18px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.email-accent {
  width: 5px;
  align-self: stretch;
  border-radius: 999px;
  background: #d7dce5;
}

.email-item.active .email-accent {
  background: var(--black);
}

.email-item:hover {
  transform: translateY(-1px);
  border-color: #cbd5e1;
  box-shadow: var(--shadow);
}

.email-item.active {
  border: 2px solid var(--black);
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.12);
}

.email-card-main {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.email-card-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.email-card-top strong,
.email-subject,
.email-preview {
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-card-top strong {
  white-space: nowrap;
  font-size: 15px;
}

.email-card-top span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.email-subject {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}

.email-preview {
  display: -webkit-box;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.email-tags {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.folder-badge,
.mail-code,
.latest-badge {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.folder-badge {
  border: 1px solid #bbf7d0;
  background: var(--green-soft);
  color: var(--green);
}

.mail-code {
  background: var(--blue-soft);
  color: var(--blue);
}

.latest-badge {
  background: #fef3c7;
  color: #b45309;
}

.email-detail-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
}

.detail-empty {
  height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: var(--muted);
}

.detail-empty-icon {
  width: 70px;
  height: 70px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 22px;
  background: var(--panel-muted);
  color: var(--muted);
  font-size: 32px;
}

.detail-empty-icon svg {
  width: 34px;
  height: 34px;
}

.detail-empty h3 {
  margin: 0;
  font-size: 20px;
}

.detail-toolbar {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.detail-action {
  min-height: 38px;
  padding: 0 18px;
}

.detail-action.primary {
  border-color: transparent;
  background: var(--black);
  color: var(--panel);
}

.detail-header {
  padding: 30px 42px 26px;
  border-bottom: 1px solid var(--line);
}

.detail-header h1 {
  max-width: 980px;
  margin: 0 auto 22px;
  font-size: clamp(24px, 2.2vw, 34px);
  line-height: 1.25;
  letter-spacing: -0.03em;
}

.detail-meta {
  max-width: 980px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px 18px;
  color: var(--muted);
  font-size: 16px;
}

.detail-meta strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.code-display {
  width: min(520px, calc(100% - 84px));
  margin: 36px auto 26px;
  padding: 24px;
  border-radius: 22px;
  background: var(--panel-muted);
  text-align: center;
}

.code-display span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.code-display strong {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: clamp(34px, 4vw, 52px);
  font-weight: 500;
  letter-spacing: 0.12em;
}

.detail-body {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 42px 42px;
}

.message-text,
.message-raw {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 14px;
  line-height: 1.75;
}

.message-frame {
  width: 100%;
  min-height: min(680px, 58vh);
  border: none;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px #eef2f7, 0 14px 32px rgba(15, 23, 42, 0.05);
}

.toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 200;
  display: grid;
  gap: 10px;
}

.toast {
  min-width: 220px;
  max-width: 380px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-strong);
  font-size: 14px;
  font-weight: 700;
}

.toast.success {
  border-color: #bbf7d0;
}

.toast.error {
  border-color: #fecdd3;
}

.loading {
  min-height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.loading-spinner {
  width: 30px;
  height: 30px;
  border: 3px solid #e5e7eb;
  border-top-color: var(--black);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-dots::after {
  content: "";
  animation: dots 1.1s steps(4, end) infinite;
}

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

@keyframes dots {
  0%,
  20% {
    content: "";
  }
  40% {
    content: ".";
  }
  60% {
    content: "..";
  }
  80%,
  100% {
    content: "...";
  }
}

@media (max-width: 1320px) {
  .group-panel {
    width: 180px;
  }

  .account-panel {
    width: 320px;
  }

  .email-list-panel {
    width: 380px;
  }
}

@media (max-width: 1180px) {
  .group-panel {
    width: 170px;
  }

  .account-panel {
    width: 320px;
  }

  .content-area {
    flex: 1;
    flex-direction: column;
    min-width: 0;
  }

  .email-list-panel,
  .email-detail-panel {
    width: 100%;
    min-width: 0;
    border-right: none;
  }

  .email-list-panel {
    flex: 0 0 44%;
    border-bottom: 1px solid var(--line);
  }

  .email-detail-panel {
    flex: 1;
    min-height: 0;
  }

  .email-filter-row {
    grid-template-columns: 1fr 1fr;
  }

  .mail-search-input {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  body.mobile-panels-open {
    overflow: hidden;
  }

  .main-container {
    height: calc(100dvh - 56px);
    overflow: hidden;
  }

  .group-panel {
    position: fixed;
    top: 56px;
    bottom: 0;
    left: 0;
    z-index: 140;
    width: min(380px, 90vw);
    max-width: none;
    transform: translateX(-104%);
    transition: transform 0.24s ease, box-shadow 0.24s ease;
  }

  .group-panel.show {
    transform: translateX(0);
    box-shadow: 18px 0 42px rgba(15, 23, 42, 0.18);
  }

  .mobile-quickbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 9px 10px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, #fcfcfd 0%, #f4f6f9 100%);
  }

  .mobile-quickbar-btn {
    min-width: 0;
    min-height: 50px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    color: var(--text);
    text-align: left;
  }

  .mobile-quickbar-btn span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
  }

  .mobile-quickbar-btn strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
  }

  .mobile-panel-scrim.show {
    display: block;
    position: fixed;
    inset: 56px 0 0;
    z-index: 130;
    background: rgba(15, 23, 42, 0.32);
  }

  .email-list-panel,
  .email-detail-panel {
    width: 100%;
    min-width: 0;
    border-right: none;
  }

  .email-list-panel {
    flex: 0 0 45%;
  }

  .email-detail-panel {
    flex: 1;
    min-height: 0;
    border-top: 1px solid var(--line);
  }

  .detail-toolbar {
    min-height: auto;
    padding: 10px;
    flex-wrap: wrap;
  }

  .detail-header {
    padding: 20px 18px;
  }

  .detail-meta {
    grid-template-columns: 64px minmax(0, 1fr);
    font-size: 14px;
  }

  .detail-body {
    padding: 0 18px 24px;
  }

  .code-display {
    width: calc(100% - 36px);
    margin: 22px auto;
  }
}

@media (min-width: 721px) and (max-width: 860px) {
  .mobile-quickbar {
    grid-template-columns: 1fr;
  }

  .mobile-quickbar-btn[data-mobile-panel="accounts"] {
    display: none;
  }
}

@media (max-width: 720px) {
  html,
  body {
    min-height: 100%;
    overflow-x: hidden;
  }

  body {
    overflow-y: auto;
    background:
      radial-gradient(circle at 12% 0%, rgba(96, 165, 250, 0.16), transparent 28%),
      radial-gradient(circle at 92% 8%, rgba(124, 58, 237, 0.12), transparent 30%),
      var(--bg);
  }

  body.mobile-panels-open {
    overflow: auto;
  }

  .navbar {
    position: sticky;
    top: 0;
    z-index: 160;
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 58px;
    height: auto;
    padding: 10px 12px;
    background: color-mix(in srgb, var(--panel) 92%, transparent);
    backdrop-filter: blur(18px);
  }

  .navbar-center {
    display: none;
  }

  .navbar-brand {
    gap: 8px;
    font-size: 16px;
    min-width: 0;
  }

  .navbar-brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand-icon {
    width: 22px;
    height: 22px;
  }

  .navbar-actions {
    gap: 8px;
    justify-content: flex-end;
  }

  .language-toggle {
    min-width: 44px;
    min-height: 36px;
    padding: 0 10px;
    border-radius: 999px;
  }

  .theme-toggle {
    min-width: 38px;
    min-height: 36px;
    padding: 0 7px;
    border-radius: 999px;
  }

  .theme-toggle-icon {
    width: 24px;
    height: 24px;
  }

  .theme-toggle #themeToggleText {
    display: none;
  }

  .main-container {
    display: block;
    height: auto;
    min-height: calc(100dvh - 58px);
    overflow: visible;
  }

  .mobile-quickbar,
  .mobile-panel-scrim.show {
    display: none !important;
  }

  .group-panel {
    position: static;
    width: 100%;
    max-width: none;
    min-height: 0;
    display: block;
    transform: none;
    border-right: none;
    border-bottom: 1px solid var(--line);
    background: transparent;
  }

  .group-panel .panel-header {
    display: none;
  }

  .group-list {
    display: flex;
    gap: 8px;
    padding: 10px 12px 8px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .group-list::-webkit-scrollbar {
    display: none;
  }

  .group-item {
    width: auto;
    min-width: 126px;
    flex: 0 0 auto;
    gap: 8px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-left: 1px solid var(--line);
    border-radius: 18px;
    background: color-mix(in srgb, var(--panel) 92%, transparent);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
  }

  .group-item.active {
    border-color: var(--black);
    background: var(--panel);
  }

  .group-count {
    margin-left: 0;
    min-height: 24px;
    padding: 0 9px;
  }

  .account-panel {
    position: static;
    top: auto;
    bottom: auto;
    left: auto;
    z-index: auto;
    width: 100%;
    max-width: none;
    min-height: 0;
    height: auto;
    transform: none;
    border-right: none;
    border-bottom: 1px solid var(--line);
    background: transparent;
  }

  .account-panel-header {
    min-height: 46px;
    padding: 12px 14px 8px;
    border-bottom: none;
  }

  .account-panel-title {
    font-size: 16px;
  }

  .import-box,
  .account-toolbar,
  .email-list-header,
  .email-toolbar,
  .detail-toolbar,
  .detail-header,
  .detail-body {
    width: calc(100% - 20px);
    margin-left: auto;
    margin-right: auto;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: color-mix(in srgb, var(--panel) 94%, transparent);
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.07);
  }

  .import-box {
    padding: 14px;
  }

  .bulk-input {
    min-height: 138px;
    font-size: 13px;
    border-radius: 16px;
  }

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

  .primary-button,
  .secondary-button,
  .refresh-btn {
    min-height: 44px;
    border-radius: 14px;
  }

  .account-toolbar {
    margin-top: 10px;
    padding: 12px;
  }

  .search-input,
  .toolbar-select,
  .mail-search-input {
    min-height: 44px;
    font-size: 16px;
  }

  .account-list {
    display: flex;
    gap: 10px;
    padding: 12px 10px 14px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .account-list::-webkit-scrollbar {
    display: none;
  }

  .account-item {
    min-width: min(310px, calc(100vw - 32px));
    margin: 0;
  }

  .empty-state {
    width: 100%;
    margin: 0;
  }

  .content-area {
    display: block;
    min-height: 0;
    overflow: visible;
  }

  .email-list-panel,
  .email-detail-panel {
    display: block;
    width: 100%;
    min-height: 0;
    border: none;
    background: transparent;
  }

  .email-list-header {
    min-height: 0;
    margin-top: 8px;
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
  }

  .email-toolbar {
    margin-top: 10px;
    padding: 12px;
  }

  .method-row {
    flex-wrap: wrap;
  }

  .folder-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px;
    scrollbar-width: none;
  }

  .folder-tabs::-webkit-scrollbar {
    display: none;
  }

  .folder-tab {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 0 14px;
  }

  .email-filter-row {
    grid-template-columns: 1fr;
  }

  .mail-filter-tabs {
    gap: 8px;
  }

  .mail-filter-btn {
    min-height: 36px;
  }

  .mail-status {
    margin: 10px;
  }

  .email-list {
    padding: 10px 10px 14px;
    overflow: visible;
  }

  .email-item {
    margin-bottom: 10px;
    padding: 15px 14px;
    border-radius: 20px;
  }

  .email-card-top {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  .email-card-top span {
    white-space: normal;
  }

  .email-subject {
    white-space: normal;
  }

  .detail-empty {
    min-height: 280px;
  }

  .detail-toolbar {
    margin-top: 4px;
    justify-content: flex-start;
    border-bottom: 1px solid var(--line);
  }

  .detail-header {
    margin-top: 10px;
    padding: 18px 16px;
  }

  .detail-header h1 {
    font-size: 22px;
  }

  .detail-meta {
    grid-template-columns: 60px minmax(0, 1fr);
    font-size: 14px;
  }

  .detail-scroll {
    overflow: visible;
  }

  .code-display {
    width: calc(100% - 32px);
    margin: 16px auto;
  }

  .detail-body {
    padding: 14px;
  }

  .message-frame {
    min-height: 520px;
  }
}

@media (min-width: 721px) and (max-width: 820px) {
  .navbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    padding: 0 12px;
  }

  .navbar-center {
    display: none;
  }

}

@media (max-width: 520px) {
  .navbar-brand {
    font-size: 16px;
  }

  .email-list-header,
  .email-toolbar,
  .account-toolbar,
  .import-box {
    padding-left: 12px;
    padding-right: 12px;
  }

  .email-filter-row {
    grid-template-columns: 1fr;
  }

  .folder-tabs {
    grid-template-columns: 1fr;
  }

  .account-item,
  .email-item {
    border-radius: 16px;
    padding: 14px 12px;
  }
}
