/* Daytility Mail — brand tokens from daytility.com (day + night themes) */
:root {
  --blue: #1264E8; --cyan: #19C8D2; --emerald: #10B981; --amber: #F59E0B; --indigo: #6366F1; --coral: #FF5E57; --navy: #0D2146;
  --brand-grad: linear-gradient(135deg, #1264E8 0%, #19C8D2 100%);
  --bg: #F4F8FE; --bg-grad: linear-gradient(180deg, #FFFFFF 0%, #EAF2FD 100%);
  --surface: #FFFFFF; --surface-2: #F3F7FD; --surface-3: #E8F0FB;
  --text: #0D2146; --muted: #5B6B86; --faint: #8A99B3;
  --line: #DDE6F3; --line-strong: #C7D4E8;
  --accent: #1264E8; --accent-hover: #0E55C9; --accent-soft: #E4EEFE; --accent-text: #0E55C9;
  --danger: #E5484D; --danger-hover: #CE3A3F; --danger-soft: #FDECEC;
  --success: #10B981; --warn-soft: #FFF6E0; --warn-text: #92570A;
  --unread: #1264E8; --star: #F59E0B; --star-empty: #E5EAF3;
  --shadow-sm: 0 1px 2px rgba(13, 33, 70, .06), 0 1px 3px rgba(13, 33, 70, .06);
  --shadow: 0 8px 24px rgba(13, 33, 70, .10), 0 2px 6px rgba(13, 33, 70, .06);
  --shadow-lg: 0 24px 60px rgba(13, 33, 70, .22);
  --scroll-thumb: #C3D2E8; --scroll-thumb-hover: #9FB5D6; --scroll-track: transparent;
  --dim: rgba(6, 12, 28, .62);
  --radius: 14px; --radius-sm: 10px; --radius-lg: 20px;
  --font: 'Inter', 'Noto Sans Thai', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0A1020; --bg-grad: linear-gradient(180deg, #111C36 0%, #070B16 100%);
  --surface: #111A2E; --surface-2: #16213A; --surface-3: #1C2946;
  --text: #E6EDF8; --muted: #9AA8C2; --faint: #6D7C98;
  --line: #22304D; --line-strong: #2E3F63;
  --accent: #38BDF8; --accent-hover: #5CCBFA; --accent-soft: rgba(56, 189, 248, .14); --accent-text: #7DD3FC;
  --danger: #F26D71; --danger-hover: #F58A8D; --danger-soft: rgba(242, 109, 113, .14);
  --warn-soft: rgba(245, 158, 11, .14); --warn-text: #FCD34D;
  --unread: #38BDF8; --star-empty: #2A3654;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);
  --scroll-thumb: #2B3A5C; --scroll-thumb-hover: #3B4E78;
  --dim: rgba(2, 5, 12, .72);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--text); background: var(--bg-grad) fixed, var(--bg); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
a { color: var(--accent-text); }
.muted { color: var(--muted); }
.grow { flex: 1; }
.ic { flex: none; display: block; }

/* ---- scrollbars ---- */
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) var(--scroll-track); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--scroll-track); }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-thumb:active { background: var(--accent); background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-corner { background: transparent; }

/* ---- buttons ---- */
button { font: inherit; color: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 999px; font-weight: 600; font-size: 14px; cursor: pointer;
  transition: background-color .15s, border-color .15s, box-shadow .15s, transform .08s, color .15s; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(.98); }
.btn:focus-visible, .icon-btn:focus-visible, .menu-item:focus-visible, .folder:focus-visible, .msg:focus-visible, .avatar:focus-visible, .chip-dev:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand-grad); color: #fff; box-shadow: 0 6px 16px rgba(18, 100, 232, .28); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 8px 22px rgba(18, 100, 232, .38); filter: brightness(1.05); }
:root[data-theme="dark"] .btn-primary { background: linear-gradient(135deg, #2F80FF 0%, #22D3EE 100%); color: #04101F; box-shadow: 0 6px 18px rgba(34, 211, 238, .22); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--accent-text); }
.btn-ghost:hover:not(:disabled) { background: var(--accent-soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent;
  color: var(--muted); cursor: pointer; transition: background-color .15s, color .15s, transform .08s; flex: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.on { color: var(--star); }
.icon-btn-sm { width: 32px; height: 32px; }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---- form fields ---- */
input, textarea { font: inherit; color: var(--text); }
.field { display: grid; gap: 6px; text-align: left; font-weight: 500; font-size: 13px; color: var(--muted); }
.field input, .field textarea {
  height: 44px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface);
  transition: border-color .15s, box-shadow .15s; font-size: 15px;
}
.field textarea { height: auto; min-height: 90px; padding: 10px 14px; resize: vertical; }
.field input:focus, .field textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.check { display: flex; gap: 10px; align-items: center; cursor: pointer; font-size: 14px; color: var(--text); }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-error { margin: 0; color: var(--danger); font-size: 13px; }

/* ---- logo follows in-app theme ---- */
.boot { position: fixed; inset: 0; display: grid; place-items: center; }
.boot .logo-img { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); opacity: .8; } }

/* ---- login ---- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 32px 28px 20px; display: grid; gap: 16px; text-align: center;
}
.login-card .logo-img { margin: 0 auto; }
.login-card h1 { font-size: 22px; }
.login-card p { margin: -8px 0 4px; }
.login-prefs { display: flex; justify-content: center; }
.login-prefs [data-slot] { display: flex; gap: 4px; }

/* ---- app shell ---- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  height: 64px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 12px 0 16px;
  background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
  position: relative; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; width: 220px; flex: none; }
.search { flex: 1; max-width: 680px; position: relative; }
.search input {
  width: 100%; height: 44px; border-radius: 999px; border: 1px solid transparent; background: var(--surface-3);
  padding: 0 16px 0 44px; font-size: 15px; transition: background .15s, border-color .15s, box-shadow .15s;
}
.search input:focus { outline: 0; background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search-ic { position: absolute; left: 14px; top: 12px; color: var(--muted); pointer-events: none; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; border: 0; margin-left: 6px; cursor: pointer; font-weight: 700; color: #fff;
  background: var(--brand-grad); box-shadow: var(--shadow-sm); transition: transform .1s;
}
.avatar:hover { transform: scale(1.06); }
.chip-dev {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; margin-right: 6px; border-radius: 999px;
  border: 1px dashed var(--amber); background: var(--warn-soft); color: var(--warn-text); font-weight: 600; font-size: 12px; cursor: pointer;
}
.chip-dev:hover { border-style: solid; }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 248px minmax(320px, 420px) 1fr; }
.sidebar { padding: 16px 12px; overflow-y: auto; }
.btn-compose { height: 52px; padding: 0 24px 0 20px; border-radius: 18px; font-size: 15px; margin: 0 0 16px 4px; }
.folders { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.folder {
  width: 100%; display: flex; align-items: center; gap: 14px; height: 40px; padding: 0 14px 0 16px; border: 0; border-radius: 999px;
  background: transparent; color: var(--text); cursor: pointer; text-align: left; transition: background .12s;
}
.folder:hover { background: var(--surface-3); }
.folder.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.folder .count { margin-left: auto; font-size: 12px; font-weight: 700; }
.folder .ic { color: var(--muted); }
.folder.active .ic { color: var(--accent-text); }

.list-pane { border-left: 1px solid var(--line); border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 8px 12px 20px; border-bottom: 1px solid var(--line); min-height: 60px; }
.list-head h2 { font-size: 18px; }
.list-tools { display: flex; align-items: center; gap: 4px; }
.msg-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.msg {
  display: grid; grid-template-columns: 36px 1fr auto; gap: 2px 10px; padding: 12px 14px 12px 12px; border-bottom: 1px solid var(--line);
  cursor: pointer; position: relative; transition: background .1s; outline-offset: -3px;
}
.msg:hover { background: var(--surface-2); }
.msg.active { background: var(--accent-soft); }
.msg.unread::before { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--unread); }
.msg .av { grid-row: span 3; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; }
.msg .who { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.msg.unread .who, .msg.unread .subj { color: var(--text); font-weight: 700; }
.msg .when { font-size: 12px; color: var(--faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.msg .subj { grid-column: 2 / 4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.msg .snip { grid-column: 2 / 3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--faint); font-size: 13px; }
.msg .flags { grid-column: 3; display: flex; gap: 4px; justify-content: flex-end; align-items: center; color: var(--faint); }
.msg .flags .starred { color: var(--star); }
.msg .cnt { font-size: 12px; color: var(--faint); font-weight: 500; margin-left: 4px; }
.list-empty { padding: 56px 24px; text-align: center; color: var(--muted); display: grid; justify-items: center; gap: 12px; }
.list-empty .ic { color: var(--line-strong); }
.list-foot { padding: 8px; text-align: center; }

/* ---- reader ---- */
.reader { overflow-y: auto; min-width: 0; }
.reader-empty { height: 100%; display: grid; place-items: center; align-content: center; gap: 14px; color: var(--muted); text-align: center; padding: 24px; }
.reader-empty img { opacity: .9; }
.r-toolbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 2px; padding: 10px 16px; min-height: 60px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.r-toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
.r-subject { padding: 22px 28px 6px; font-size: 22px; font-weight: 600; overflow-wrap: anywhere; }
.r-count { padding: 0 28px 10px; color: var(--muted); font-size: 13px; }
.r-msg { margin: 10px 20px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.r-msg.collapsed .r-body, .r-msg.collapsed .r-atts, .r-msg.collapsed .r-note, .r-msg.collapsed .r-actions { display: none; }
.r-head { display: grid; grid-template-columns: 40px 1fr auto; gap: 0 12px; padding: 16px 18px; cursor: pointer; align-items: center; }
.r-head .av { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; grid-row: span 2; }
.r-from { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-from small { font-weight: 400; color: var(--muted); margin-left: 6px; font-size: 13px; }
.r-to { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-when { color: var(--faint); font-size: 12px; grid-row: 1; grid-column: 3; font-variant-numeric: tabular-nums; }
.r-snip { color: var(--faint); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-note { display: flex; align-items: center; gap: 10px; margin: 0 18px 12px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn-text); font-size: 13px; }
.r-note.danger { background: var(--danger-soft); color: var(--danger); }
.r-note .btn { margin-left: auto; }
.r-body { padding: 4px 18px 18px; }
.r-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.6; margin: 0; font-family: inherit; }
.r-frame { width: 100%; border: 0; display: block; min-height: 60px; background: #fff; border-radius: var(--radius-sm); }
.r-atts { display: flex; flex-wrap: wrap; gap: 10px; padding: 0 18px 16px; }
.att {
  display: inline-flex; align-items: center; gap: 10px; padding: 8px 12px 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); text-decoration: none; max-width: 260px; transition: border-color .15s, background .15s;
}
.att:hover { border-color: var(--accent); background: var(--accent-soft); }
.att .att-ic { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); flex: none; }
.att .att-name { font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att .att-size { font-size: 12px; color: var(--faint); }
.r-actions { display: flex; gap: 8px; padding: 0 18px 18px; flex-wrap: wrap; }

/* ---- compose ---- */
.compose {
  position: fixed; right: 24px; bottom: 0; width: min(560px, calc(100vw - 32px)); height: min(620px, calc(100vh - 80px));
  background: var(--surface); border: 1px solid var(--line); border-bottom: 0; border-radius: 16px 16px 0 0; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; z-index: 40; animation: rise .22s ease-out;
}
.compose.min { height: 52px; }
.compose.min .compose-body { display: none; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.compose-head { display: flex; align-items: center; gap: 2px; padding: 8px 8px 8px 18px; background: var(--surface-3); border-radius: 16px 16px 0 0; cursor: pointer; }
.compose-head h2 { font-size: 15px; flex: 1; }
.compose-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.c-row { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding: 0 12px 0 18px; min-height: 44px; }
.c-row label { color: var(--muted); font-size: 13px; min-width: 64px; }
.c-row input { flex: 1; border: 0; background: transparent; height: 42px; font-size: 14px; min-width: 0; }
.c-row input:focus { outline: 0; }
.c-row:focus-within { border-bottom-color: var(--accent); }
#cBody { flex: 1; border: 0; resize: none; padding: 14px 18px; background: transparent; font-size: 15px; line-height: 1.6; min-height: 120px; }
#cBody:focus { outline: 0; }
.c-files { list-style: none; margin: 0; padding: 0 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.c-files li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 4px 4px 10px; background: var(--surface-3); border-radius: 999px; font-size: 12px; max-width: 240px; }
.c-files li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-actions { display: flex; align-items: center; gap: 6px; padding: 12px 14px; border-top: 1px solid var(--line); }
#attachLbl { cursor: pointer; }

/* ---- menus ---- */
.menu {
  position: fixed; z-index: 100; min-width: 220px; padding: 6px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); opacity: 0; transform: translateY(-4px) scale(.98); transform-origin: top right; transition: opacity .12s, transform .12s;
}
.menu.show { opacity: 1; transform: none; }
.menu-item { width: 100%; display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; text-align: left; color: var(--text); }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-3); outline: none; }
.menu-item.danger { color: var(--danger); }
.menu-item .menu-ic { color: var(--muted); width: 18px; }
.menu-item .menu-label { flex: 1; }
.menu-item .menu-check { color: var(--accent-text); width: 16px; }
.menu-item[aria-checked="true"] { font-weight: 600; }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu-head { padding: 10px 12px 8px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }

/* ---- modal ---- */
.modal-backdrop { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px; background: var(--dim); backdrop-filter: blur(6px); opacity: 0; transition: opacity .2s; }
.modal-backdrop.show { opacity: 1; }
.modal { width: min(440px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); transform: translateY(12px) scale(.97); transition: transform .2s; }
.modal-backdrop.show .modal { transform: none; }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 18px 12px 4px 22px; }
.modal-head h2 { font-size: 18px; flex: 1; }
.modal-body { padding: 8px 22px 6px; display: grid; gap: 14px; color: var(--muted); }
.modal-body p { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px 20px; flex-wrap: wrap; }

/* ---- toasts ---- */
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 120; display: grid; gap: 8px; justify-items: center; pointer-events: none; width: min(560px, calc(100vw - 32px)); }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; min-height: 48px; border-radius: 14px;
  background: var(--navy); color: #fff; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(12px); transition: opacity .2s, transform .2s;
}
:root[data-theme="dark"] .toast { background: #E6EDF8; color: #0D2146; }
.toast.show { opacity: 1; transform: none; }
.toast span { flex: 1; }
.toast-success > .ic:first-child { color: var(--emerald); }
.toast-error > .ic:first-child { color: var(--coral); }
.toast .btn-ghost { color: #7DD3FC; }
:root[data-theme="dark"] .toast .btn-ghost { color: var(--blue); }
.toast .icon-btn { color: inherit; opacity: .75; }
.toast .icon-btn:hover { background: rgba(255, 255, 255, .12); opacity: 1; }

/* ---- update bar ---- */
.update-bar {
  position: fixed; left: 16px; bottom: 16px; z-index: 60; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 8px 8px 16px; background: var(--surface); border: 1px solid var(--accent); border-radius: 16px; box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}
.update-bar > [data-ic] { color: var(--accent-text); }

/* ---- tutorial ---- */
.tut { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.tut-shade { position: fixed; background: var(--dim); pointer-events: auto; transition: all .25s ease; }
.tut-block { position: fixed; pointer-events: auto; }
.tut-ring { position: fixed; border-radius: 16px; box-shadow: 0 0 0 3px var(--amber), 0 0 0 9px rgba(245, 158, 11, .25); transition: all .25s ease; pointer-events: none; animation: ring 1.6s ease-in-out infinite; }
@keyframes ring { 50% { box-shadow: 0 0 0 3px var(--amber), 0 0 0 15px rgba(245, 158, 11, 0); } }
.tut-card {
  position: fixed; width: min(360px, calc(100vw - 32px)); pointer-events: auto; background: var(--surface); color: var(--text); border-radius: 20px;
  border: 1px solid var(--line); box-shadow: var(--shadow-lg); padding: 16px 18px 14px; transition: top .25s ease, left .25s ease;
}
.tut-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.tut-guide { width: 46px; height: 42px; flex: none; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px) rotate(-3deg); } }
.tut-meta { flex: 1; min-width: 0; }
.tut-mission { font-size: 12px; font-weight: 700; color: var(--accent-text); letter-spacing: .02em; display: flex; align-items: center; gap: 6px; }
.tut-kind { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); }
.tut-kind.quest { background: var(--warn-soft); color: var(--warn-text); }
.tut-progress { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; margin-top: 6px; }
.tut-progress i { display: block; height: 100%; background: var(--brand-grad); border-radius: 6px; transition: width .35s ease; }
.tut-stars { display: flex; align-items: center; gap: 4px; font-weight: 700; color: var(--amber); font-size: 13px; }
.tut-card h3 { font-size: 17px; margin-bottom: 4px; }
.tut-card p { margin: 0 0 12px; color: var(--muted); }
.tut-foot { display: flex; align-items: center; gap: 8px; }
.tut-hand { color: var(--amber); display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; animation: tap 1.2s ease-in-out infinite; }
@keyframes tap { 50% { transform: translateY(3px); } }
.tut-celebrate {
  position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 85; pointer-events: none; display: flex; align-items: center; gap: 10px;
  padding: 14px 22px; border-radius: 20px; background: var(--surface); border: 2px solid var(--amber); box-shadow: var(--shadow-lg); font-weight: 700; font-size: 17px;
  animation: pop .9s cubic-bezier(.2, 1.6, .4, 1) both;
}
@keyframes pop { 0% { transform: translate(-50%, -50%) scale(.3); opacity: 0; } 60% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1); } }
.tut-finish { text-align: center; }
.tut-finish .big-stars { display: flex; justify-content: center; gap: 8px; margin: 6px 0 4px; }
.tut-finish .big-stars svg { animation: pop-star .6s cubic-bezier(.2, 1.6, .4, 1) both; }
.tut-finish .big-stars svg:nth-child(2) { animation-delay: .15s; width: 72px; height: 72px; margin-top: -10px; }
.tut-finish .big-stars svg:nth-child(3) { animation-delay: .3s; }
@keyframes pop-star { from { transform: scale(0) rotate(-40deg); opacity: 0; } }
.tut-finish .modal-body { text-align: center; }

/* ---- responsive ---- */
.only-mobile { display: none; }
.scrim { display: none; }
@media (max-width: 1100px) {
  .layout { grid-template-columns: 220px 1fr; }
  .brand { width: auto; }
  .reader { position: fixed; inset: 64px 0 0 220px; background: var(--bg); z-index: 15; transform: translateX(100%); transition: transform .25s ease; }
  .app.reading .reader { transform: none; }
}
@media (max-width: 760px) {
  .only-mobile { display: inline-grid; }
  .topbar { gap: 4px; padding: 0 6px 0 4px; height: 60px; }
  .brand span { display: none; }
  .search input { height: 40px; }
  .search-ic { top: 10px; }
  .chip-dev .lbl { display: none; }
  .chip-dev { padding: 0 8px; margin-right: 0; }
  .avatar { margin-left: 2px; width: 32px; height: 32px; }
  .top-actions .icon-btn { width: 36px; height: 36px; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 60px; bottom: 0; left: 0; width: 272px; background: var(--surface); z-index: 30; transform: translateX(-100%); transition: transform .25s ease, box-shadow .25s; }
  .app.drawer .sidebar { box-shadow: var(--shadow-lg); }
  .app.drawer .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 60px 0 0; background: var(--dim); z-index: 25; opacity: 0; pointer-events: none; transition: opacity .25s; }
  .app.drawer .scrim { opacity: 1; pointer-events: auto; }
  .list-pane { border: 0; }
  .reader { inset: 60px 0 0 0; }
  .r-subject { padding: 16px 16px 4px; font-size: 19px; }
  .r-count { padding: 0 16px 8px; }
  .r-msg { margin: 8px 8px 12px; }
  .r-toolbar { padding: 8px; overflow-x: auto; }
  .compose { right: 0; left: 0; width: 100%; height: calc(100% - 8px); border-radius: 16px 16px 0 0; }
  body .fab { display: grid; }
  .brand { display: none; }
}
.fab {
  display: none; position: fixed; right: 16px; bottom: 20px; z-index: 12; width: 56px; height: 56px; border-radius: 18px; border: 0; place-items: center;
  background: var(--brand-grad); color: #fff; box-shadow: 0 10px 24px rgba(18, 100, 232, .35); cursor: pointer;
}
.fab:active { transform: scale(.95); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.spin .ic { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.modal-body form { display: grid; gap: 14px; }
.modal-body form > p { margin: 0 0 2px; }

/* ---- user folders (tree) ---- */
.folders-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 6px 4px 16px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.folders-sep { height: 1px; background: var(--line); margin: 10px 12px; }
.ufolder { position: relative; }
.ufolder .folder { padding-left: calc(16px + var(--depth, 0) * 18px); padding-right: 40px; }
.ufolder .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ufolder .count { margin-left: auto; }
.ufolder .fmenu { position: absolute; right: 4px; top: 4px; opacity: 0; transition: opacity .12s; }
.ufolder:hover .fmenu, .ufolder .fmenu:focus-visible, .ufolder .folder.active + .fmenu { opacity: 1; }
@media (hover: none) { .ufolder .fmenu { opacity: 1; } }

/* ---- themed select / input ---- */
.select-wrap { position: relative; display: inline-flex; min-width: 0; }
.select {
  appearance: none; -webkit-appearance: none; height: 40px; padding: 0 36px 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; width: 100%; min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
.select:hover { border-color: var(--accent); }
.select:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.select option { background: var(--surface); color: var(--text); }
.select-arrow { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--muted); }
.input {
  height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text); font: inherit; font-size: 14px; min-width: 0; transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.field .select-wrap { display: flex; }
.field.inline { grid-template-columns: auto 1fr; align-items: center; gap: 12px; color: var(--text); font-size: 14px; }

/* ---- switch ---- */
.switch { flex: none; width: 42px; height: 24px; border-radius: 999px; border: 0; padding: 0; background: var(--line-strong); position: relative; cursor: pointer; transition: background .2s; }
.switch i { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s; }
.switch[aria-checked="true"] { background: var(--emerald); }
.switch[aria-checked="true"] i { transform: translateX(18px); }
.switch:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

/* ---- rules ---- */
.modal.modal-wide { width: min(680px, 100%); }
.rules-top { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.rules-top p { margin: 0; font-size: 13px; }
.rules-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rule { display: flex; align-items: center; gap: 12px; padding: 10px 8px 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.rule.off .rule-main { opacity: .55; }
.rule-main { flex: 1; min-width: 0; }
.rule-name { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rule-sum { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rule-btns { display: flex; gap: 0; flex: none; }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.rules-mgr .list-empty { padding: 28px 12px; }
.rule-form { color: var(--text); }
.rule-sec { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.rule-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.rule-sec .btn-ghost { justify-self: start; }
.cond-row { display: grid; grid-template-columns: 150px 150px 1fr 32px; gap: 8px; align-items: center; }
.cond-row .select-wrap[hidden] + .input[hidden] { display: none; }
@media (max-width: 760px) {
  .cond-row { grid-template-columns: 1fr 1fr 32px; }
  .cond-row .input { grid-column: 1 / 3; }
  .rules-top { flex-direction: column; align-items: stretch; }
  .rule { flex-wrap: wrap; }
  .rule-btns { width: 100%; justify-content: flex-end; }
}
.modal-body > * { min-width: 0; }
.rules-top p { flex: 1; min-width: 0; }
.rules-list > li, .rule-sec > * { min-width: 0; }

/* ---- Inbox with subfolders (Outlook-style) ---- */
.inbox-row { position: relative; }
.inbox-row .folder { padding-right: 40px; }
.inbox-row .count { margin-left: auto; }
.inbox-row .fmenu { position: absolute; right: 4px; top: 4px; opacity: 0; transition: opacity .12s; }
.inbox-row:hover .fmenu, .inbox-row .fmenu:focus-visible { opacity: 1; }
@media (hover: none) { .inbox-row .fmenu { opacity: 1; } }
.caret {
  position: absolute; left: -2px; top: 10px; z-index: 1; width: 20px; height: 20px; border: 0; border-radius: 6px; padding: 0;
  display: grid; place-items: center; background: transparent; color: var(--muted); cursor: pointer; transition: transform .15s, background .12s;
}
.caret:hover { background: var(--surface-3); color: var(--text); }
.caret.open { transform: rotate(90deg); }
.caret:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.menu-item:disabled { opacity: .45; cursor: default; background: transparent; }

/* ---- duplicate rule warning ---- */
.dup-body p { margin: 0; }
.dup-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dup-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); }
.dup-item .ic { margin-top: 2px; color: var(--accent-text); }
.dup-item.dup-same { border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-soft); }
.dup-item.dup-same .ic { color: var(--danger); }
.dup-item.dup-same_conditions { border-color: color-mix(in srgb, var(--amber) 50%, transparent); background: var(--warn-soft); }
.dup-item.dup-same_conditions .ic { color: var(--warn-text); }
.dup-name { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.dup-kind { font-size: 13px; color: var(--muted); }
.dup-off { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 999px; background: var(--surface-3); color: var(--muted); }
.c-row .c-from { flex: 1; min-width: 0; }
.c-row .c-from .select { border: 0; height: 40px; padding-left: 0; background: transparent; box-shadow: none; }
.c-row .c-from .select:focus { box-shadow: none; }
