/* ═══════════════════════════════════════════════════════════════
   Luma Mail — Minimal Dense Theme
   Inter + JetBrains Mono · Teal/Emerald accent · Flat surfaces
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-alt: #f0f1f3;
  --line: #e2e4e9;
  --ink: #111827;
  --muted: #6b7280;
  --accent: #10b981;
  --accent-hover: #059669;
  --accent-soft: rgba(16, 185, 129, 0.09);
  --accent-text: #065f46;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.09);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 6px;
  color-scheme: light;
}

body[data-theme="dark"] {
  --bg: #0e1015;
  --panel: #181a20;
  --panel-alt: #1e2028;
  --line: #2a2d36;
  --ink: #e2e4e9;
  --muted: #8b8f9a;
  --accent: #34d399;
  --accent-hover: #6ee7b7;
  --accent-soft: rgba(52, 211, 153, 0.1);
  --accent-text: #a7f3d0;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

/* ── Reset ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
}

body {
  height: 100vh;
  overflow: hidden;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
  border: 0;
  background: none;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.25;
}

/* ── Screens ── */
.screen {
  display: none;
}

.screen.active {
  display: block;
}

.is-hidden {
  display: none !important;
}

.hidden {
  display: none !important;
}

/* ══════════════════════════════════════════════════════════════
   LOGIN
   ══════════════════════════════════════════════════════════════ */
.login-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 1fr minmax(360px, 440px);
  gap: 0;
  overflow: hidden;
}

.login-hero {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 32px;
  padding: 48px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.hero-copy h2 {
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  font-weight: 600;
  line-height: 1.1;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.hero-copy p:last-child {
  max-width: 48ch;
  color: var(--muted);
  line-height: 1.6;
}

.login-highlight-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.auth-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  padding: 48px 40px;
  background: var(--bg);
  overflow-y: auto;
}

/* ══════════════════════════════════════════════════════════════
   BRAND
   ══════════════════════════════════════════════════════════════ */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
}

.brand h1 {
  font-size: 1rem;
  font-weight: 600;
}

.eyebrow {
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

/* ══════════════════════════════════════════════════════════════
   FORMS (shared: auth, settings, composer)
   ══════════════════════════════════════════════════════════════ */
.auth-form,
.settings-form,
.composer-form {
  display: grid;
  gap: 14px;
}

.auth-form label,
.settings-form label,
.composer-form label {
  display: grid;
  gap: 5px;
}

.auth-form span,
.settings-form span,
.composer-form span {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.auth-form input,
.settings-form input,
.settings-form textarea,
.settings-form select,
.composer-form input,
.composer-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--ink);
  font-size: 14px;
  outline: none;
  transition: border-color 150ms;
}

.auth-form input:focus,
.settings-form input:focus,
.settings-form textarea:focus,
.settings-form select:focus,
.composer-form input:focus,
.composer-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth-form input::placeholder,
.settings-form input::placeholder,
.composer-form input::placeholder,
.composer-form textarea::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.checkbox-row input,
.toggle-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.text-link {
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
}

.form-feedback {
  min-height: 1.4em;
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.form-feedback[data-kind="error"] {
  color: var(--danger);
}

.form-feedback[data-kind="success"] {
  color: var(--accent);
}

.form-meta {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-family: "JetBrains Mono", monospace;
}

.auth-divider {
  position: relative;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.auth-divider::before {
  content: "";
  position: absolute;
  inset: 50% 0 auto;
  border-top: 1px solid var(--line);
}

.auth-divider span {
  position: relative;
  padding: 0 10px;
  background: var(--bg);
}

.auth-actions {
  display: flex;
  gap: 10px;
}

/* ══════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════ */
.compose-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
  font-weight: 500;
  font-size: 13px;
  transition: background 150ms;
}

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

body[data-theme="dark"] .compose-button {
  color: #0e1015;
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  transition: background 150ms, border-color 150ms;
}

.ghost-button:hover {
  background: var(--panel-alt);
  border-color: var(--muted);
}

.ghost-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.toolbar-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  transition: all 150ms;
}

.toolbar-pill:hover {
  color: var(--ink);
  background: var(--panel-alt);
}

.toolbar-pill.active {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: transparent;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 150ms;
}

.icon-button:hover {
  background: var(--panel-alt);
}

/* ══════════════════════════════════════════════════════════════
   APP SHELL (mail screen)
   ══════════════════════════════════════════════════════════════ */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  min-height: 0;
  max-height: 100vh;
  overflow: hidden;
}

.sidebar .compose-button {
  width: 100%;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.nav-item-row {
  display: flex;
  align-items: center;
  gap: 0;
  border-radius: var(--radius-sm);
}

.nav-item-row:hover {
  background: var(--panel-alt);
}

.nav-item-row.active {
  background: var(--accent-soft);
}

.nav-item-row.active .nav-item {
  color: var(--accent-text);
  font-weight: 500;
}

.nav-item-row.active strong {
  color: var(--accent);
}

.nav-item-row.is-disabled {
  opacity: 0.4;
}

.nav-item-row.is-disabled .nav-item,
.nav-item-row.is-disabled .folder-delete-button {
  cursor: not-allowed;
}

.nav-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  transition: none;
}

.nav-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item-tail {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-item strong {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
}

.folder-delete-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--muted);
  opacity: 0;
  transition: opacity 150ms;
}

.nav-item-row:hover .folder-delete-button {
  opacity: 0.6;
}

.folder-delete-button:hover {
  opacity: 1 !important;
  color: var(--danger);
  background: var(--danger-soft);
}

.nav-footer-button {
  margin-top: auto;
  width: 100%;
  justify-content: center;
}

/* ── Sidebar card ── */
.sidebar-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-alt);
}

.sidebar-card h3 {
  font-size: 13px;
  margin-bottom: 4px;
}

.sidebar-card p {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

/* ══════════════════════════════════════════════════════════════
   MAIN PANEL
   ══════════════════════════════════════════════════════════════ */
.main-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.search-wrap {
  flex: 1;
}

.search-wrap input {
  width: 100%;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-alt);
  color: var(--ink);
  font-size: 13px;
  outline: none;
  transition: border-color 150ms;
}

.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--panel);
}

.search-wrap input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-chip {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

body[data-theme="dark"] .profile-chip {
  color: #0e1015;
}

/* ── Workspace ── */
.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Mail list panel ── */
.mail-list-panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}

.panel-header h2 {
  font-size: 15px;
  font-weight: 600;
}

.toolbar {
  display: flex;
  gap: 4px;
  padding: 0 16px 10px;
  border-bottom: 1px solid var(--line);
}

.mail-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-height: 0;
}

.mail-item {
  display: grid;
  gap: 3px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  text-align: left;
  transition: background 100ms;
}

.mail-item:hover {
  background: var(--panel-alt);
}

.mail-item.active {
  background: var(--accent-soft);
}

.mail-item.unread {
  background: var(--panel);
}

.mail-item.unread .mail-sender,
.mail-item.unread .mail-meta h3 {
  font-weight: 600;
}

.mail-item.unread::before {
  content: "";
  grid-column: 1 / -1;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
}

.mail-item {
  position: relative;
}

.mail-item.active.unread::before {
  background: var(--accent-hover);
}

.mail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.mail-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.mail-meta h3 {
  font-size: 13px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-sender {
  font-size: 13px;
  font-weight: 500;
}

.mail-time {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}

.mail-count {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  font-weight: 500;
  color: var(--accent);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}

.mail-preview {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 500;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.badge.urgent {
  background: var(--danger-soft);
  color: var(--danger);
}

.mail-pager {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
}

.mail-list-status {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* ══════════════════════════════════════════════════════════════
   READER PANEL
   ══════════════════════════════════════════════════════════════ */
.reader-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.reader-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.reader-head h2 {
  font-size: 15px;
  font-weight: 600;
}

.reader-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.reader-actions .ghost-button {
  padding: 6px 10px;
  font-size: 12px;
}

/* ── Reader card (message content) ── */
.reader-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin: 16px 24px;
  padding: 20px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  min-height: 0;
  overflow: hidden;
}

.reader-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

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

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 600;
}

.reader-card h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

.reader-card p {
  margin: 0;
}

.message-time {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--muted);
}

.message-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.message-tags:empty {
  display: none;
}

.message-details {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-alt);
  font-size: 13px;
}

.message-detail-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px;
  align-items: start;
}

.message-detail-row strong {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.message-detail-row span {
  overflow-wrap: anywhere;
}

.message-notice {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  border: 1px solid rgba(16, 185, 129, 0.2);
  font-size: 13px;
}

.message-notice.visible {
  display: flex;
}

.message-notice p {
  color: var(--muted);
}

.message-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin-top: 16px;
  padding-right: 8px;
}

.message-body p {
  line-height: 1.7;
  color: var(--ink);
  margin-bottom: 0.6em;
}

.message-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}

.message-body a {
  color: var(--accent);
  word-break: break-word;
}

.message-body table {
  max-width: 100%;
  border-collapse: collapse;
}

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 16px;
  flex-shrink: 0;
}

.attachment-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-alt);
}

.attachment-card h4 {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-size {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}

/* ══════════════════════════════════════════════════════════════
   SETTINGS
   ══════════════════════════════════════════════════════════════ */
.settings-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

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

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-nav-item {
  text-align: left;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  transition: background 100ms;
}

.settings-nav-item:hover {
  background: var(--panel-alt);
}

.settings-nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.settings-nav-item.admin-only {
  border: 1px dashed var(--line);
}

.settings-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 32px;
  background: var(--bg);
  overflow-y: auto;
}

.settings-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-topbar h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.settings-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
}

.settings-card .panel-header {
  padding: 0 0 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
  background: var(--danger-soft);
  color: var(--danger);
}

.settings-note {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.admin-settings input:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.settings-form-2col {
  grid-template-columns: 1fr 1fr;
}

.settings-textarea textarea {
  min-height: 120px;
  resize: vertical;
}

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.toggle-row strong {
  font-size: 13px;
  font-weight: 500;
}

.toggle-row p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.settings-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* ── Rules ── */
.rule-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.rule-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.rule-card p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.settings-inline-action {
  display: flex;
  align-items: end;
}

/* ══════════════════════════════════════════════════════════════
   COMPOSER / MODALS
   ══════════════════════════════════════════════════════════════ */
.composer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
}

.composer-backdrop.hidden {
  display: none;
}

.composer-modal {
  width: min(640px, 100%);
  max-height: min(85vh, 900px);
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow-y: auto;
}

.composer-modal.is-expanded {
  width: min(800px, 100%);
}

.folder-modal {
  width: min(460px, 100%);
}

.composer-modal .panel-header {
  padding: 0 0 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.composer-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.composer-textarea textarea {
  min-height: 200px;
  resize: vertical;
}

.composer-modal.is-expanded .composer-textarea textarea {
  min-height: min(45vh, 480px);
}

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

.compose-attachment-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.compose-attachment-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-alt);
  font-size: 13px;
}

/* ══════════════════════════════════════════════════════════════
   TAGS (sidebar & reader)
   ══════════════════════════════════════════════════════════════ */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
}

.tag-sales {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.tag-product {
  background: rgba(99, 102, 241, 0.1);
  color: #4338ca;
}

body[data-theme="dark"] .tag-product {
  color: #a5b4fc;
}

.tag-urgent {
  background: var(--danger-soft);
  color: var(--danger);
}

.metric-card p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  body {
    height: auto;
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

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

  .workspace {
    grid-template-columns: 1fr;
  }

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

  .main-panel,
  .reader-panel,
  .reader-card {
    overflow: visible;
  }

  .mail-list {
    max-height: 400px;
  }

  .login-shell {
    grid-template-columns: 1fr;
  }

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

  .settings-shell {
    grid-template-columns: 1fr;
  }

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

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-wrap: wrap;
  }
}

@media (max-width: 720px) {
  .login-hero {
    padding: 28px 20px;
  }

  .auth-card {
    padding: 28px 20px;
  }

  .hero-copy h2 {
    font-size: 1.5rem;
  }

  .login-highlight-grid,
  .settings-form-2col {
    grid-template-columns: 1fr;
  }

  .reader-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .reader-actions {
    flex-wrap: wrap;
  }

  .reader-card {
    margin: 12px;
    padding: 16px;
  }

  .settings-main {
    padding: 20px 16px;
  }

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

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }
}
