:root {
  --ink: #0a2b3e;
  --muted: #526975;
  --line: #dbe6e3;
  --paper: #ffffff;
  --mist: #f5f8f7;
  --accent: #1e6f78;
  --accent-dark: #0f5259;
  --danger: #9b2c2c;
  --shadow: 0 18px 48px rgba(10, 43, 62, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--mist);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

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

.sidebar {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  background: #061f2d;
  color: var(--paper);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.72);
}

.compose-button,
.button,
.icon-button,
.logout-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.compose-button,
.button {
  padding: 10px 16px;
  background: var(--accent);
  color: var(--paper);
  font-weight: 760;
}

.compose-button:hover,
.button:hover {
  background: var(--accent-dark);
}

.button-secondary {
  background: var(--paper);
  border-color: var(--line);
  color: var(--ink);
}

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

.folder-list {
  display: grid;
  gap: 6px;
}

.folder-item,
.logout-button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  text-align: left;
}

.folder-item:hover,
.folder-item.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--paper);
}

.folder-item {
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

.calendar-item {
  margin-top: 8px;
}

.folder-item span:last-child {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.82rem;
}

.folder-section h2 {
  margin: 0 0 10px;
  color: rgba(255, 255, 255, 0.58);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.logout-button {
  margin-top: auto;
  border-color: rgba(255, 255, 255, 0.16);
}

.workspace {
  min-width: 0;
  padding: 22px;
}

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

.topbar h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.45rem);
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.search-box {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 11px 12px;
}

input:focus,
textarea:focus {
  outline: 3px solid rgba(30, 111, 120, 0.18);
  border-color: var(--accent);
}

.icon-button {
  width: 42px;
  background: var(--paper);
  border-color: var(--line);
  color: var(--ink);
  font-size: 1.2rem;
}

.mail-layout {
  height: calc(100vh - 124px);
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  gap: 18px;
}

.message-list-panel,
.reading-pane,
.calendar-grid {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.message-list {
  display: grid;
}

.message-item {
  position: relative;
  display: grid;
  gap: 7px;
  padding: 16px;
  border: 0;
  border-left: 4px solid transparent;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.message-item:hover,
.message-item.is-active {
  background: #edf7f6;
}

.message-item.is-unread .message-subject {
  font-weight: 850;
}

.message-item.is-unread {
  border-left-color: var(--accent);
  background: #eefafa;
}

.message-item.is-unread::after {
  content: "";
  position: absolute;
  top: 18px;
  right: 14px;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--accent);
}

.message-item.is-unread .message-meta,
.message-item.is-unread .message-preview {
  color: var(--ink);
  font-weight: 780;
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.84rem;
}

.message-subject {
  font-weight: 700;
}

.message-preview {
  color: var(--muted);
  font-size: 0.92rem;
}

.reading-pane {
  padding: 28px;
}

.reading-header {
  display: grid;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.reading-header h2 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
}

.reading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.restore-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-top: 4px;
}

.restore-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 760;
}

.restore-controls select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 9px 12px;
}

.message-body {
  margin-top: 22px;
  color: var(--ink);
  line-height: 1.65;
}

.message-body iframe {
  width: 100%;
  min-height: 480px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  padding: 0;
  list-style: none;
}

.attachment-list a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.empty-state,
.loading-state {
  min-height: 280px;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
}

.empty-state h2,
.loading-state h2 {
  margin: 0 0 8px;
  color: var(--ink);
}

.calendar-grid {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.event-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--mist);
}

.event-card h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.event-card p {
  margin: 0;
  color: var(--muted);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(rgba(6, 31, 45, 0.72), rgba(6, 31, 45, 0.78)),
    url("https://images.unsplash.com/photo-1497366754035-f200968a6e72?auto=format&fit=crop&w=1800&q=82") center/cover;
}

.login-card {
  width: min(100%, 460px);
  padding: 34px;
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.login-brand {
  color: var(--ink);
}

.login-brand .brand-mark {
  background: var(--ink);
  color: var(--paper);
}

.login-brand small {
  color: var(--muted);
}

.login-card h1 {
  margin: 28px 0 10px;
  line-height: 1.1;
}

.login-card p,
.form-status {
  color: var(--muted);
}

.login-card form {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

dialog {
  width: min(760px, calc(100vw - 24px));
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(6, 31, 45, 0.48);
}

.compose-form {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.compose-form header,
.compose-form footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.compose-form h2 {
  margin: 0;
}

.compose-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 760;
}

.file-field input {
  padding: 10px;
}

.error-text {
  color: var(--danger);
  font-weight: 760;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .folder-section {
    display: none;
  }

  .mail-layout {
    height: auto;
    grid-template-columns: 1fr;
  }

  .message-list-panel,
  .reading-pane {
    max-height: none;
  }
}

@media (max-width: 640px) {
  .workspace {
    padding: 14px;
  }

  .topbar,
  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box {
    width: 100%;
  }
}
