/* =========================================================================
   iMail — iOS Mail design, pure CSS. SF Pro fallback, iOS colors, blur, spring.
   ========================================================================= */

/* ---- Base tokens (iOS light + dark) ----------------------------------- */
:root {
  color-scheme: light dark;

  /* iOS System Colors */
  --ios-blue: #007AFF;
  --ios-blue-pressed: #0062CC;
  --ios-red: #FF3B30;
  --ios-green: #34C759;
  --ios-orange: #FF9500;
  --ios-yellow: #FFCC00;
  --ios-purple: #AF52DE;
  --ios-pink: #FF2D55;
  --ios-indigo: #5856D6;
  --ios-teal: #5AC8FA;
  --ios-gray: #8E8E93;
  --ios-gray2: #AEAEB2;
  --ios-gray3: #C7C7CC;
  --ios-gray4: #D1D1D6;
  --ios-gray5: #E5E5EA;
  --ios-gray6: #F2F2F7;

  /* Backgrounds */
  --bg: #F2F2F7;
  --bg-grouped: #F2F2F7;
  --bg-elevated: #FFFFFF;
  --bg-fill: rgba(120, 120, 128, 0.12);
  --bg-fill-2: rgba(120, 120, 128, 0.08);

  /* Text */
  --text: #000000;
  --text-2: rgba(60, 60, 67, 0.60);
  --text-3: rgba(60, 60, 67, 0.30);
  --text-on-tint: #FFFFFF;

  /* Separator */
  --sep: rgba(60, 60, 67, 0.29);
  --sep-opaque: #C6C6C8;

  /* Glass & effects */
  --glass-bg: rgba(255, 255, 255, 0.70);
  --glass-bg-strong: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(255, 255, 255, 0.50);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.08);
  --shadow-card: 0 20px 60px rgba(0, 0, 0, 0.20);

  /* Tint */
  --tint: var(--ios-blue);

  /* Typography */
  --font-sf: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
             "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Motion */
  --spring-fast: cubic-bezier(0.32, 0.72, 0, 1);
  --spring: cubic-bezier(0.25, 1, 0.5, 1);
  --spring-soft: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout */
  --sidebar-w: 320px;
  --list-w: 420px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-grouped: #1C1C1E;
    --bg-elevated: #1C1C1E;
    --bg-fill: rgba(118, 118, 128, 0.24);
    --bg-fill-2: rgba(118, 118, 128, 0.14);

    --text: #FFFFFF;
    --text-2: rgba(235, 235, 245, 0.60);
    --text-3: rgba(235, 235, 245, 0.30);

    --sep: rgba(84, 84, 88, 0.65);
    --sep-opaque: #38383A;

    --glass-bg: rgba(28, 28, 30, 0.70);
    --glass-bg-strong: rgba(28, 28, 30, 0.88);
    --glass-border: rgba(84, 84, 88, 0.35);
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.60);
    --shadow-card: 0 20px 60px rgba(0, 0, 0, 0.80);

    --ios-gray5: #2C2C2E;
    --ios-gray6: #1C1C1E;
  }
}

/* ---- Reset & base ----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sf);
  font-size: 16px;
  line-height: 1.35;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.01em;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

button { font-family: inherit; font-size: inherit; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
a { color: var(--tint); }

.hidden { display: none !important; }
.screen { height: 100dvh; width: 100vw; overflow: hidden; }

/* ---- Glass / blurs --------------------------------------------------- */
.glass {
  background: var(--glass-bg-strong);
  backdrop-filter: saturate(180%) blur(36px);
  -webkit-backdrop-filter: saturate(180%) blur(36px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card);
}
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: saturate(180%) blur(30px);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
}
.glass-bar {
  background: var(--glass-bg);
  backdrop-filter: saturate(200%) blur(24px);
  -webkit-backdrop-filter: saturate(200%) blur(24px);
  border-bottom: 0.5px solid var(--sep);
}

/* ========================================================================
   LOGIN SCREEN
   ======================================================================== */
.login-screen {
  position: relative;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}
.login-bg {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(0,122,255,0.35), transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(90,200,250,0.35), transparent 50%),
    radial-gradient(ellipse at 50% 110%, rgba(175,82,222,0.25), transparent 60%),
    var(--bg);
  filter: saturate(140%);
}
.login-card {
  position: relative; z-index: 1;
  width: min(420px, 100%);
  padding: 36px 28px 28px;
  border-radius: 28px;
  text-align: center;
  animation: popIn 540ms var(--spring-soft);
}
.login-logo {
  display: grid; place-items: center; margin-bottom: 16px;
}
.login-logo svg {
  filter: drop-shadow(0 12px 28px rgba(0,122,255,0.30));
  animation: floaty 6s ease-in-out infinite;
}
.login-title {
  margin: 0 0 4px;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.login-sub {
  margin: 0 0 24px;
  font-size: 15px;
  color: var(--text-2);
}
.login-foot {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: 0;
}
.login-error {
  background: rgba(255,59,48,0.12);
  color: var(--ios-red);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  margin-top: 12px;
  animation: shake 380ms var(--spring-fast);
}

/* iOS text field */
.ios-field {
  display: block;
  text-align: left;
  background: var(--bg-fill);
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 10px;
  transition: background .2s var(--spring-fast), box-shadow .2s var(--spring-fast);
}
.ios-field:focus-within {
  background: var(--bg-elevated);
  box-shadow: 0 0 0 2px var(--tint) inset, 0 6px 18px rgba(0,122,255,0.18);
}
.ios-field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.ios-field input {
  width: 100%;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 17px;
  padding: 4px 0;
  color: var(--text);
}
.ios-field input::placeholder { color: var(--text-3); }

/* ---- Buttons --------------------------------------------------------- */
.ios-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 18px;
  border-radius: 14px;
  border: 0;
  background: var(--bg-fill);
  color: var(--text);
  font-weight: 600;
  font-size: 17px;
  cursor: pointer;
  transition: transform 160ms var(--spring-fast), background 160ms var(--spring-fast), opacity .2s;
}
.ios-btn:active { transform: scale(0.965); background: var(--bg-fill-2); }
.ios-btn.primary { background: var(--tint); color: #fff; box-shadow: 0 10px 22px rgba(0,122,255,0.30); }
.ios-btn.primary:active { background: var(--ios-blue-pressed); }
.ios-btn.block { display: flex; width: 100%; }
.ios-btn .spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.5); border-top-color: #fff;
  animation: spin .8s linear infinite;
}

.ios-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 11px;
  background: transparent; border: 0; cursor: pointer;
  color: var(--tint);
  transition: transform 160ms var(--spring-fast), background 200ms var(--spring-fast);
}
.ios-icon-btn:hover { background: var(--bg-fill-2); }
.ios-icon-btn:active { transform: scale(0.92); background: var(--bg-fill); }
.ios-icon-btn.destructive { color: var(--ios-red); }
.ios-icon-btn svg { width: 22px; height: 22px; }

.ios-text-btn {
  display: inline-flex; align-items: center; gap: 4px;
  background: transparent; border: 0; padding: 6px 10px;
  color: var(--tint); font-size: 17px; font-weight: 400;
  cursor: pointer; border-radius: 8px;
  transition: opacity .15s ease, transform 160ms var(--spring-fast);
}
.ios-text-btn:active { transform: scale(0.97); opacity: .7; }
.ios-text-btn.strong { font-weight: 600; }
.ios-text-btn.primary { color: var(--tint); }
.ios-text-btn.subtle { color: var(--text-2); }
.ios-text-btn .chev { width: 16px; height: 20px; }

/* ========================================================================
   APP LAYOUT
   ======================================================================== */
.app-screen { display: flex; flex-direction: row; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 0.5px solid var(--sep);
  background: var(--bg-grouped);
  padding-top: max(12px, var(--safe-t));
  padding-left: max(0px, var(--safe-l));
  z-index: 50;
  transition: transform 320ms var(--spring-fast);
}
.sidebar-header {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 16px 8px;
  position: relative;
}
.sidebar-title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.sidebar-close { display: none; }
.sidebar-account {
  display: flex; align-items: center; gap: 12px;
  margin: 8px 12px 12px;
  padding: 12px;
  background: var(--bg-fill-2);
  border-radius: 14px;
}
.account-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, #60C6FF, #007AFF);
  color: #fff; font-weight: 700; font-size: 17px;
  display: grid; place-items: center;
  text-transform: uppercase;
  flex-shrink: 0;
  box-shadow: 0 6px 14px rgba(0,122,255,0.25);
}
.account-text { flex: 1; min-width: 0; }
.account-name { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.account-email { font-size: 13px; color: var(--text-2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.account-logout { color: var(--ios-red); }

.folder-list {
  padding: 0 10px 16px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}
.folder-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  transition: background 180ms var(--spring-fast), transform 160ms var(--spring-fast);
  margin-bottom: 2px;
}
.folder-item:hover { background: var(--bg-fill-2); }
.folder-item:active { transform: scale(0.985); background: var(--bg-fill); }
.folder-item.active {
  background: linear-gradient(180deg, rgba(0,122,255,0.08), rgba(0,122,255,0.04));
  font-weight: 600;
}
@media (prefers-color-scheme: dark) {
  .folder-item.active { background: linear-gradient(180deg, rgba(0,122,255,0.18), rgba(0,122,255,0.08)); }
}
.list-row.active {
  background: linear-gradient(180deg, rgba(0,122,255,0.07), rgba(0,122,255,0.03));
}
@media (prefers-color-scheme: dark) {
  .list-row.active { background: linear-gradient(180deg, rgba(0,122,255,0.16), rgba(0,122,255,0.06)); }
}
.folder-icon {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  color: #fff;
  background: var(--tint);
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}
.folder-icon svg { width: 18px; height: 18px; }
.folder-name { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.folder-count {
  background: var(--ios-red);
  color: #fff;
  min-width: 22px; height: 22px; padding: 0 7px;
  border-radius: 999px;
  font-size: 12px; font-weight: 700;
  display: inline-grid; place-items: center;
  letter-spacing: 0;
  box-shadow: 0 4px 10px rgba(255,59,48,0.35);
}
.folder-count.muted { background: var(--bg-fill); color: var(--text-2); box-shadow: none; }

/* LIST PANE */
.list-pane {
  width: var(--list-w);
  flex-shrink: 0;
  border-right: 0.5px solid var(--sep);
  display: flex; flex-direction: column;
  position: relative;
  background: var(--bg);
  min-width: 0;
}
.list-header {
  display: flex; align-items: center; gap: 8px;
  padding: max(8px, var(--safe-t)) 10px 8px;
  position: sticky; top: 0; z-index: 5;
}
.list-menu { display: none; }
.list-titles { flex: 1; min-width: 0; padding-left: 6px; }
.list-folder-kicker { font-size: 12px; color: var(--text-2); letter-spacing: 0.02em; text-transform: uppercase; font-weight: 600; }
.list-folder-title { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.03em; }
.list-actions { display: flex; gap: 4px; padding-right: 4px; }

.list-search-wrap { padding: 0 12px 8px; }
.ios-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-fill);
  padding: 7px 10px;
  border-radius: 10px;
  transition: background .2s var(--spring-fast);
}
.ios-search .ios-search-icon { width: 18px; height: 18px; color: var(--text-2); }
.ios-search input {
  flex: 1;
  background: transparent;
  border: 0; outline: none;
  font-size: 16px;
  padding: 2px 0;
}
.ios-search input::placeholder { color: var(--text-2); }
.ios-search-cancel {
  background: transparent; border: 0;
  color: var(--tint); font-size: 16px;
  cursor: pointer;
  padding: 2px 2px;
}

/* Pull-to-refresh hint */
.pull-hint {
  position: absolute; left: 0; right: 0; top: 96px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--text-2); font-size: 13px;
  opacity: 0; transform: translateY(-12px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.pull-hint.visible { opacity: 1; transform: translateY(0); }
.pull-spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--sep); border-top-color: var(--tint);
  animation: spin .9s linear infinite;
}

/* List */
.list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding-bottom: 100px;
}
.list-row {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px 10px 14px;
  border-bottom: 0.5px solid var(--sep);
  cursor: pointer;
  background: var(--bg);
  touch-action: pan-y;
  transition: background .18s var(--spring-fast), transform 160ms var(--spring-fast);
  user-select: none;
  will-change: transform;
}
.list-row:active { background: var(--bg-fill-2); }
.list-row .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--tint);
  margin-top: 7px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,122,255,0.35);
  transition: opacity .15s ease;
}
.list-row.seen .dot { background: transparent; box-shadow: none; }
.list-row .row-body { flex: 1; min-width: 0; }
.list-row .row-top { display: flex; align-items: center; gap: 8px; }
.list-row .sender { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; letter-spacing: -0.01em; }
.list-row.seen .sender { font-weight: 400; }
.list-row .date { color: var(--text-2); font-size: 13px; flex-shrink: 0; }
.list-row .chev { color: var(--text-3); width: 12px; height: 16px; margin-top: 4px; }
.list-row .subject { font-size: 15px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.list-row .preview { font-size: 13px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.35; margin-top: 2px; }
.list-row.flagged .subject::after { content: ""; display: inline-block; width: 12px; height: 12px; background: var(--ios-orange); border-radius: 50%; margin-left: 6px; vertical-align: middle; }

/* Swipe actions */
.list-row-wrap {
  position: relative;
  overflow: hidden;
  background: var(--bg);
}
.swipe-actions {
  position: absolute; top: 0; bottom: 0; right: 0;
  display: flex;
  transform: translateX(100%);
  transition: transform 280ms var(--spring-fast);
  pointer-events: none;
}
.list-row-wrap.revealed .swipe-actions { pointer-events: auto; }
.swipe-action {
  display: grid; place-items: center;
  width: 72px;
  color: #fff; font-weight: 600; font-size: 13px;
  border: 0; cursor: pointer;
  user-select: none;
  transition: filter .15s ease;
}
.swipe-action.trash { background: var(--ios-red); }
.swipe-action.archive { background: var(--ios-orange); }
.swipe-action.flag { background: var(--ios-yellow); color: #000; }
.swipe-action.unread { background: var(--ios-blue); }
.swipe-action:active { filter: brightness(0.92); }
.swipe-action svg { width: 22px; height: 22px; }

.list-empty { display: grid; place-items: center; padding: 64px 32px; color: var(--text-2); text-align: center; }
.empty-icon { color: var(--text-3); margin-bottom: 12px; }
.empty-icon svg { width: 56px; height: 56px; }
.empty-icon.lrg svg { width: 88px; height: 88px; }
.empty-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); margin-bottom: 4px; }
.empty-sub { font-size: 15px; color: var(--text-2); }

/* Compose FAB */
.compose-fab {
  position: absolute;
  right: 18px; bottom: calc(18px + var(--safe-b));
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--tint); color: #fff; border: 0;
  cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 14px 30px rgba(0,122,255,0.38), 0 6px 12px rgba(0,122,255,0.25);
  transition: transform 220ms var(--spring-soft), background 180ms;
  z-index: 4;
}
.compose-fab:active { transform: scale(0.92); background: var(--ios-blue-pressed); }
.compose-fab svg { width: 24px; height: 24px; }

/* READER PANE */
.reader-pane { flex: 1; display: flex; flex-direction: column; background: var(--bg); min-width: 0; }
.reader-header {
  display: flex; align-items: center; gap: 8px;
  padding: max(8px, var(--safe-t)) 10px 8px;
  position: sticky; top: 0; z-index: 5;
}
.reader-back { color: var(--tint); font-weight: 400; }
.reader-actions { margin-left: auto; display: flex; gap: 2px; padding-right: 6px; }
.reader-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 22px 28px 120px;
}
.reader-subject { font-size: 26px; font-weight: 700; letter-spacing: -0.025em; margin: 0 0 10px; }
.reader-meta {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-bottom: 0.5px solid var(--sep);
}
.reader-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, #60C6FF, #007AFF);
  color: #fff; font-weight: 700; font-size: 18px;
  display: grid; place-items: center;
  box-shadow: 0 6px 14px rgba(0,122,255,0.25);
  text-transform: uppercase;
  flex-shrink: 0;
}
.reader-meta-text { flex: 1; min-width: 0; }
.reader-from { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.reader-from-addr { color: var(--text-2); font-size: 13px; margin-left: 4px; }
.reader-to { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-date { font-size: 13px; color: var(--text-2); flex-shrink: 0; }
.reader-content {
  padding: 16px 0;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
}
.reader-content p { margin: 0 0 14px; }
.reader-content a { color: var(--tint); word-break: break-word; }
.reader-content img { max-width: 100%; border-radius: 8px; height: auto; }
.reader-content pre { background: var(--bg-fill-2); padding: 12px; border-radius: 12px; overflow-x: auto; font-size: 14px; }
.reader-content blockquote { margin: 8px 0; padding: 4px 12px; border-left: 3px solid var(--sep); color: var(--text-2); }
.reader-empty { display: grid; place-items: center; height: 100%; text-align: center; color: var(--text-2); }

/* ========================================================================
   COMPOSE SHEET
   ======================================================================== */
.sheet {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.40);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 280ms var(--spring-fast);
}
.sheet-card {
  position: relative;
  width: 100%;
  max-width: 780px;
  height: 92dvh;
  background: var(--bg-elevated);
  border-radius: 22px 22px 0 0;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  animation: slideUp 380ms var(--spring-soft);
  padding-bottom: var(--safe-b);
}
.sheet-handle {
  display: grid; place-items: center;
  padding: 8px 0 2px;
}
.sheet-handle span {
  width: 38px; height: 5px; border-radius: 3px;
  background: var(--text-3);
}
.sheet-header {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border-bottom: 0.5px solid var(--sep);
}
.sheet-title { margin: 0 auto; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.sheet-body {
  flex: 1;
  display: flex; flex-direction: column;
  padding: 0 16px 20px;
  overflow-y: auto;
}
.compose-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0;
  border-bottom: 0.5px solid var(--sep);
}
.compose-label {
  width: 72px; color: var(--text-2); font-size: 15px; flex-shrink: 0;
}
.compose-row input {
  flex: 1;
  background: transparent; border: 0; outline: none;
  font-size: 16px; padding: 4px 0;
}
.compose-row input::placeholder { color: var(--text-3); }
.compose-row.subject input { font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
#compose-body {
  flex: 1;
  min-height: 220px;
  margin-top: 12px;
  padding: 12px;
  font-size: 16px; line-height: 1.5;
  background: var(--bg-fill-2);
  border: 0; outline: none; resize: none;
  border-radius: 14px;
  color: var(--text);
}
#compose-body:focus { background: var(--bg-elevated); box-shadow: 0 0 0 2px var(--tint) inset; }
.compose-status { padding: 12px; color: var(--text-2); text-align: center; font-size: 14px; }
.compose-status.error { color: var(--ios-red); }

/* ========================================================================
   ACTION SHEET
   ======================================================================== */
.action-sheet {
  position: fixed; inset: 0; z-index: 150;
  display: flex; align-items: flex-end;
}
.action-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.36);
  animation: fadeIn 220ms var(--spring-fast);
}
.action-wrap {
  position: relative;
  width: 100%;
  padding: 0 8px calc(8px + var(--safe-b));
  animation: slideUp 260ms var(--spring-soft);
}
.action-group, .action-cancel-wrap {
  background: var(--glass-bg-strong);
  backdrop-filter: saturate(180%) blur(30px);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 8px;
}
.action-item {
  display: block; width: 100%;
  padding: 16px;
  background: transparent; border: 0; cursor: pointer;
  font-size: 19px; font-weight: 400;
  color: var(--tint); text-align: center;
  border-top: 0.5px solid var(--sep);
}
.action-item:first-child { border-top: 0; }
.action-item.destructive { color: var(--ios-red); }
.action-item.strong { font-weight: 600; }
.action-item:active { background: var(--bg-fill-2); }
.action-cancel {
  display: block; width: 100%;
  padding: 16px;
  background: transparent; border: 0; cursor: pointer;
  font-size: 19px; font-weight: 600;
  color: var(--tint);
}
.action-cancel:active { background: var(--bg-fill-2); }

/* ========================================================================
   TOAST
   ======================================================================== */
.toast {
  position: fixed; top: 16px; left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: var(--glass-bg-strong);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  font-size: 14px; font-weight: 600;
  opacity: 0;
  z-index: 200;
  transition: transform 260ms var(--spring-soft), opacity 220ms;
  pointer-events: none;
  border: 0.5px solid var(--sep);
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { color: var(--ios-green); }
.toast.error { color: var(--ios-red); }

/* ========================================================================
   ANIMATIONS
   ======================================================================== */
@keyframes popIn { 0% { opacity: 0; transform: scale(0.92) translateY(14px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes fadeOut { from { opacity: 1 } to { opacity: 0 } }
@keyframes slideUp { 0% { transform: translateY(40%); opacity: 0; } 60% { transform: translateY(-2%); opacity: 1; } 100% { transform: translateY(0); opacity: 1; } }
@keyframes slideDown { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(24%); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.fade-in { animation: fadeIn .25s var(--spring-fast); }

/* ========================================================================
   Responsive (mobile / tablet)
   ======================================================================== */
@media (max-width: 1100px) {
  .reader-pane { flex: 2; }
  :root { --sidebar-w: 280px; --list-w: 380px; }
}

@media (max-width: 860px) {
  .app-screen { position: relative; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: min(84vw, 330px);
    transform: translateX(-105%);
    box-shadow: 22px 0 50px rgba(0,0,0,0.25);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: inline-flex; color: var(--text-2); }
  .list-menu { display: inline-flex; }
  .list-pane {
    width: 100%;
    border-right: 0;
  }
  .reader-pane {
    position: fixed; inset: 0;
    transform: translateX(105%);
    transition: transform 320ms var(--spring-fast);
    z-index: 30;
  }
  .reader-pane.visible { transform: translateX(0); }
}

/* ========================================================================
   Hide scrollbars in iOS style (still scrollable)
   ======================================================================== */
.list::-webkit-scrollbar,
.folder-list::-webkit-scrollbar,
.reader-body::-webkit-scrollbar,
.sheet-body::-webkit-scrollbar {
  width: 6px;
}
.list::-webkit-scrollbar-thumb,
.folder-list::-webkit-scrollbar-thumb,
.reader-body::-webkit-scrollbar-thumb,
.sheet-body::-webkit-scrollbar-thumb {
  background: var(--bg-fill);
  border-radius: 10px;
}
.list::-webkit-scrollbar-track { background: transparent; }
