:root {
  color-scheme: light;
  --bg: #f5f5f5;
  --panel: #ffffff;
  --soft: #f5f5f5;
  --soft-hover: #efefef;
  --line: #e0e0e0;
  --line-soft: #ebebeb;
  --text: #171717;
  --muted: #787878;
  --accent: #fa2424;
  --accent-hover: #df1e1e;
  --accent-soft: #ffe5e5;
  --danger: #a32626;
  --shadow: 0 12px 32px #00000008;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  min-height: 44px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 600;
  transition: background-color .15s ease, transform .15s ease;
}

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

button.secondary {
  background: var(--soft);
  color: var(--text);
  border: 1px solid var(--line);
}

button.secondary:hover {
  background: var(--soft-hover);
}

.app {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand small,
.field span,
.meta,
.empty,
#viewSubtitle {
  color: var(--muted);
}

.mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.field {
  display: grid;
  gap: 6px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
  color: var(--text);
  padding: 12px 14px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  background: transparent;
  color: var(--text);
  text-align: left;
  border-radius: 18px;
}

.nav button.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.content {
  padding: 26px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

.panel,
.mail-layout {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 32px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
  max-width: 780px;
}

.hidden {
  display: none !important;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 14px;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

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

.mail-layout {
  display: grid;
  grid-template-columns: minmax(320px, 38%) minmax(0, 1fr);
  min-height: 640px;
  overflow: hidden;
}

.message-list {
  border-right: 1px solid var(--line);
  overflow: auto;
}

.message-row {
  width: 100%;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: white;
  color: var(--text);
  text-align: left;
  border-radius: 0;
}

.message-row:hover,
.message-row.active {
  background: var(--soft);
}

.message-row strong,
.message-row span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-detail {
  padding: 22px;
  overflow: auto;
}

.message-body {
  white-space: pre-wrap;
  margin-top: 18px;
}

.attachments,
.attachment-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.attachments a,
.attachment-preview span {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  padding: 7px 9px;
  text-decoration: none;
}

.attachments span,
.attachment-preview small {
  color: var(--muted);
  margin-left: 6px;
}

@media (max-width: 820px) {
  .app,
  .mail-layout,
  .grid {
    grid-template-columns: 1fr;
  }

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