:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d9dee7;
  --text: #1d2430;
  --muted: #677182;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --warn: #b42318;
  --caution: #92400e;
  --focus: #2563eb;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea { font: inherit; }
button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
}
button:hover { background: var(--accent-dark); }
button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  background: #fff;
  color: var(--text);
}
input:focus, textarea:focus, button:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
.hidden { display: none !important; }
.muted { min-height: 20px; color: var(--muted); margin: 8px 0 0; }
.warning { min-height: 20px; color: var(--caution); margin: 8px 0 0; }
.error { min-height: 20px; color: var(--warn); margin: 8px 0 0; }
.success { min-height: 20px; color: var(--accent-dark); margin: 8px 0 0; }
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-panel {
  width: min(360px, 100%);
  display: grid;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 12px 36px rgb(28 35 45 / 10%);
}
.login-panel h1 { margin: 0 0 6px; font-size: 26px; }
.mail-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px minmax(280px, 380px) minmax(0, 1fr);
}
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
  border-right: 1px solid var(--line);
  background: #111827;
  color: #f9fafb;
}
.brand { font-weight: 700; font-size: 18px; }
.compose-button { background: #f59e0b; color: #111827; }
.compose-button:hover { background: #d97706; }
.folders { display: grid; gap: 6px; }
.folder, .secondary-button, .icon-button {
  background: transparent;
  color: inherit;
  border: 1px solid transparent;
}
.folder {
  text-align: left;
  color: #d1d5db;
}
.folder.active, .folder:hover {
  background: #263142;
  color: #fff;
}
.secondary-button {
  margin-top: auto;
  border-color: var(--line);
  color: var(--text);
  background: #fff;
}
.sidebar .secondary-button {
  color: #f9fafb;
  background: transparent;
  border-color: #374151;
}
.secondary-button:hover, .icon-button:hover {
  background: #eef1f5;
  color: var(--text);
}
.list-pane, .detail-pane {
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
}
.detail-pane { border-right: 0; }
.pane-header {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}
.pane-header h2 { margin: 0; font-size: 18px; }
.icon-button {
  width: 38px;
  padding: 0;
  color: var(--text);
}
.message-list {
  display: grid;
  align-content: start;
  max-height: calc(100vh - 58px);
  overflow: auto;
}
.message-row {
  min-height: 84px;
  display: grid;
  gap: 4px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  text-align: left;
}
.message-row:hover, .message-row.active { background: #eef7f6; }
.message-row strong, .message-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-row small { color: var(--muted); }
.message-detail {
  max-width: 920px;
  margin: 0 auto;
  padding: 28px;
}
.message-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 16px;
}
.reply-button {
  width: auto;
  min-width: 72px;
}
.message-detail h1 {
  margin: 0 0 16px;
  font-size: 24px;
}
.meta {
  display: grid;
  gap: 5px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
  margin-bottom: 20px;
}
.body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.body-frame {
  width: 100%;
  min-height: min(640px, calc(100vh - 220px));
  border: 0;
  background: #fff;
}
dialog {
  width: min(720px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgb(17 24 39 / 24%);
}
dialog::backdrop { background: rgb(17 24 39 / 42%); }
.compose-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}
.compose-form header, .compose-form footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.compose-actions {
  display: flex;
  gap: 8px;
}
.compose-form h2 { margin: 0; font-size: 18px; }
.compose-form label { display: grid; gap: 6px; }
.compose-form label span { color: var(--muted); font-size: 12px; }
.alias-row, .sender-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}
.alias-row strong { color: var(--muted); white-space: nowrap; }
.sender-create {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #f8fafc;
}
.sender-create-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  background: #fff;
  color: var(--text);
}
.recipient-editor {
  min-height: 44px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
  background: #fff;
}
.recipient-editor:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
.recipient-chips {
  display: contents;
}
.recipient-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 30px;
  gap: 6px;
  border: 1px solid #b7c9c6;
  border-radius: 999px;
  background: #e7f4f2;
  color: #123b37;
  padding: 0 6px 0 10px;
}
.recipient-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recipient-chip button {
  width: 24px;
  min-height: 24px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  color: #315c57;
}
.recipient-chip button:hover {
  background: #cfe4e1;
}
.recipient-editor input {
  width: 180px;
  min-width: 140px;
  flex: 1;
  border: 0;
  padding: 5px;
}
.recipient-editor input:focus {
  outline: 0;
}
.schedule-row {
  gap: 8px;
}
.schedule-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 260px);
  align-items: center;
  gap: 10px;
}
.inline-check {
  display: inline-flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px !important;
}
.inline-check input {
  width: auto;
}
.inline-check span {
  font-size: 14px !important;
  color: var(--text) !important;
}
.preview-dialog {
  width: min(920px, calc(100vw - 32px));
}
.preview-shell {
  display: grid;
  grid-template-rows: auto auto minmax(320px, 68vh);
  min-height: min(760px, calc(100vh - 48px));
}
.preview-shell header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.preview-shell h2 {
  margin: 0;
  font-size: 18px;
}
.preview-meta {
  display: grid;
  gap: 5px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  overflow-wrap: anywhere;
}
.preview-frame-row {
  min-height: 0;
}
.preview-shell iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

@media (max-width: 860px) {
  .mail-view { grid-template-columns: 72px minmax(0, 1fr); }
  .sidebar { padding: 12px 8px; gap: 10px; }
  .brand { font-size: 12px; text-align: center; }
  .compose-button, .folder, .sidebar .secondary-button { padding: 0 8px; text-align: center; }
  .detail-pane { display: none; }
  .schedule-controls { grid-template-columns: 1fr; }
}
