:root {
  --bg: #f6f4f1; --card: #ffffff; --ink: #1b1a19; --dim: #7a746d; --line: #e9e5df; --soft: #efece7;
  --accent: #e8452c; --accent-ink: #ffffff; --green: #1f9d62; --amber: #c97f00; --warn-bg: #fff4dc; --warn-ink: #7a5200;
  --shadow: 0 1px 2px rgba(30, 20, 10, .05), 0 8px 24px rgba(30, 20, 10, .06);
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121110; --card: #1e1c1a; --ink: #f3efe9; --dim: #9a938a; --line: #2e2b28; --soft: #262321; --accent: #ff5a3d; --green: #35c486; --amber: #f0a92b; --warn-bg: #3a2c0c; --warn-ink: #ffd98a; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35); }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; overflow: hidden; overscroll-behavior: none; user-select: none; -webkit-user-select: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; text-align: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, h3, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
.dim { color: var(--dim); } .small { font-size: 13px; }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; padding-top: var(--sat); }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 16px calc(96px + var(--sab)); overscroll-behavior: contain; }

/* header */
.top { display: flex; align-items: flex-end; justify-content: space-between; padding: 14px 20px 10px; }
.top h1 { font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1.05; }
#status { font-size: 13px; color: var(--dim); min-height: 18px; margin-top: 2px; }
#status.warn { color: var(--amber); }
.syncing #status::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 6px; animation: pulse 1s infinite; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--dim); position: relative; }
.icon-btn:active { background: var(--soft); }
.demo { position: absolute; right: 46px; font: 600 11px/1 inherit; font-style: normal; background: var(--warn-bg); color: var(--warn-ink); padding: 5px 8px; border-radius: 99px; }

/* pile switch */
.seg { display: flex; gap: 4px; margin: 2px 16px 12px; padding: 4px; background: var(--soft); border-radius: 14px; }
.seg button { flex: 1; text-align: center; padding: 9px 6px; border-radius: 11px; font-weight: 600; font-size: 15px; color: var(--dim); transition: background .2s, color .2s; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.seg b { font-weight: 700; margin-left: 4px; color: var(--accent); }
.seg button:not(.on) b { color: inherit; }

/* rows */
.rows { display: flex; flex-direction: column; gap: 8px; }
.row { position: relative; border-radius: 18px; overflow: hidden; touch-action: pan-y; animation: rise .35s var(--ease) both; }
.row.gone { transition: max-height .2s, opacity .2s, margin .2s; max-height: 0 !important; opacity: 0; margin-top: -8px; }
.under { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; font-weight: 700; color: #fff; border-radius: 18px; opacity: 0; }
.swiping .under { opacity: 1; }
.under span { display: flex; align-items: center; gap: 8px; transition: transform .15s var(--ease); }
.row[data-dir="left"] .under { background: var(--green); } .row[data-dir="left"] .u-left { visibility: hidden; }
.row[data-dir="right"] .under { background: var(--amber); } .row[data-dir="right"] .u-right { visibility: hidden; }
.row.armed .under span { transform: scale(1.18); }
.row-in { position: relative; display: flex; gap: 12px; align-items: flex-start; width: 100%; padding: 14px 16px; background: var(--card); border-radius: 18px; box-shadow: var(--shadow); transition: transform .25s var(--ease); }
.swiping .row-in { transition: none; }
button.row-in:active { filter: brightness(.97); }
.av { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 700; font-size: 14px; color: hsl(var(--h) 45% 32%); background: hsl(var(--h) 60% 90%); }
@media (prefers-color-scheme: dark) { .av { color: hsl(var(--h) 60% 82%); background: hsl(var(--h) 30% 24%); } }
.r-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.r-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.r-top strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-top time { font-size: 13px; color: var(--dim); flex: none; }
.unread .r-top strong { font-weight: 800; }
.unread .r-top strong::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 7px; vertical-align: 1px; }
.r-sub { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-why { font-size: 14px; color: var(--dim); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.r-why.late { color: var(--accent); font-weight: 600; }
.count { font-style: normal; font-size: 12px; color: var(--dim); border: 1px solid var(--line); border-radius: 99px; padding: 0 6px; margin-left: 4px; }
.bulk { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 14px; margin-bottom: 10px; border-radius: 16px; font-weight: 700; background: var(--soft); color: var(--green); }
.bulk.go { color: var(--accent); }
.bulk:active { transform: scale(.98); }

/* tasks */
.grp { margin-bottom: 6px; }
.grp-h { width: 100%; padding: 12px 4px 8px; font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--dim); }
.grp-h.late { color: var(--accent); }
.grp-h b { font-weight: 600; opacity: .7; margin-left: 4px; }
.grp-h::after { content: "›"; float: right; font-size: 18px; line-height: 14px; transition: transform .2s; }
.grp.open .grp-h::after { transform: rotate(90deg); }
.grp:not(.open) .rows { display: none; }
.task .row-in { align-items: center; padding: 12px 14px; }
.task .r-main { padding: 2px 0; }
.task .r-sub { white-space: normal; }
.tick { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); flex: none; transition: all .15s; }
.tick:active { background: var(--green); border-color: var(--green); transform: scale(.9); }

/* empty and zero */
.empty, .zero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 18vh 24px 0; gap: 8px; color: var(--dim); position: relative; }
.empty h2, .zero h2 { color: var(--ink); font-size: 24px; font-weight: 800; }
.big-check { width: 84px; height: 84px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; margin-bottom: 10px; animation: pop .5s var(--ease) both; }
.big-check svg { width: 44px; height: 44px; stroke-width: 2.6; stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw .45s .25s ease-out forwards; }
.confetti { position: absolute; top: 20vh; left: 50%; }
.confetti i { position: absolute; width: 8px; height: 12px; border-radius: 2px; background: hsl(calc(var(--i) * 47) 80% 58%); animation: burst 1.1s calc(.2s + var(--i) * 12ms) var(--ease) both; --a: calc(var(--i) * 25.7deg); }
.spin { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .7s linear infinite; display: inline-block; }
.ptr { height: 0; overflow: hidden; display: grid; place-items: center; color: var(--dim); transition: height .2s; }
.ptr svg { transition: transform .2s; } .ptr.ready { color: var(--accent); } .ptr.ready svg { transform: rotate(180deg); }

/* tab bar */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: space-around; max-width: 560px; margin: 0 auto; padding: 8px 24px calc(8px + var(--sab)); background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-top: 1px solid var(--line); }
body[data-view="card"] #tabs, body[data-view="signin"] #tabs { display: none; }
.tab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; width: 84px; padding: 4px 0; font-size: 11px; font-weight: 600; color: var(--dim); }
.tab.on { color: var(--accent); }
.tab b { position: absolute; top: -2px; left: 50px; min-width: 18px; padding: 1px 5px; border-radius: 99px; background: var(--accent); color: #fff; font-size: 11px; text-align: center; }
.fab { width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; margin-top: -26px; box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 40%, transparent); transition: transform .15s var(--ease); }
.fab svg { width: 26px; height: 26px; stroke-width: 2.4; }
.fab:active { transform: scale(.9) rotate(90deg); }

/* card */
.card-top { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; color: var(--dim); font-size: 14px; font-weight: 600; }
.card { padding-bottom: calc(110px + var(--sab)); user-select: text; -webkit-user-select: text; }
.card.enter { animation: slide .32s var(--ease) both; }
.subj { font-size: 24px; font-weight: 800; letter-spacing: -.01em; line-height: 1.15; margin: 2px 4px 10px; }
.sum { margin: 0 4px 12px; color: var(--dim); font-size: 15px; }
.sum b { color: var(--accent); font-weight: 700; margin-right: 4px; }
.warn-line, .need-line { background: var(--warn-bg); color: var(--warn-ink); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin: 0 0 12px; }
.need-line { margin: 10px 0 0; }
.thread { display: flex; flex-direction: column; gap: 8px; }
.msg { background: var(--card); border-radius: 18px; padding: 14px 16px; box-shadow: var(--shadow); }
.msg.mine { background: var(--soft); box-shadow: none; }
.msg header { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.msg .av { width: 34px; height: 34px; font-size: 12px; }
.msg header strong { display: block; font-size: 15px; }
.msg header small { color: var(--dim); font-size: 12.5px; }
.msg p { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; line-height: 1.45; }
.att { display: inline-block; margin-top: 10px; font-size: 14px; color: var(--accent); text-decoration: none; font-weight: 600; }
.acts { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 2px; scrollbar-width: none; }
.acts::-webkit-scrollbar { display: none; }
.act { display: flex; gap: 10px; align-items: center; flex: none; max-width: 78vw; padding: 10px 14px; border-radius: 14px; border: 1.5px dashed color-mix(in srgb, var(--accent) 50%, transparent); color: var(--ink); font-size: 14px; font-weight: 600; }
.act svg { color: var(--accent); }
.act span { display: flex; flex-direction: column; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act small { font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.act.used { border-style: solid; border-color: var(--green); opacity: .7; } .act.used svg, .act.used small { color: var(--green); }
.act:active { transform: scale(.97); }

.draft { margin-top: 14px; background: var(--card); border-radius: 20px; padding: 14px 16px 12px; box-shadow: var(--shadow); border: 1.5px solid color-mix(in srgb, var(--accent) 28%, transparent); }
.to-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13.5px; color: var(--dim); padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.to-line b { color: var(--ink); font-weight: 600; }
.pill { flex: none; padding: 5px 10px; border-radius: 99px; background: var(--soft); font-size: 12.5px; font-weight: 600; color: var(--ink); }
#text { width: 100%; border: 0; outline: 0; resize: none; background: none; font-size: 17px; line-height: 1.45; padding: 0; min-height: 72px; user-select: text; -webkit-user-select: text; }
.chips { display: flex; gap: 6px; overflow-x: auto; margin: 10px -16px 0; padding: 0 16px 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; margin: 8px 0 0; padding: 0; overflow: visible; }
.chip { flex: none; padding: 8px 13px; border-radius: 99px; background: var(--soft); font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; transition: transform .1s; }
.chip svg { width: 16px; height: 16px; }
.chip:active { transform: scale(.94); }
.chip.on { background: var(--ink); color: var(--bg); }
.chip.back { background: none; border: 1px solid var(--line); color: var(--dim); }
.tell { display: flex; gap: 8px; margin-top: 10px; }
.tell input, .field input, .sheet-in form > input, .sheet-in textarea, select { flex: 1; width: 100%; min-width: 0; border: 0; outline: 0; background: var(--soft); border-radius: 14px; padding: 12px 14px; font-size: 16px; user-select: text; -webkit-user-select: text; }
.tell input:focus, .field input:focus, .sheet-in textarea:focus { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent); }
.tell button { width: 46px; height: 46px; border-radius: 14px; background: var(--ink); color: var(--bg); display: grid; place-items: center; flex: none; }
.src { margin-top: 10px; font-size: 12px; color: var(--dim); }
.busy { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 15px; padding: 10px 0; }
.busy .spin { width: 18px; height: 18px; border-width: 2px; }
.err { color: var(--accent); font-size: 14px; margin-bottom: 8px; }
.link { color: var(--accent); font-weight: 600; text-decoration: underline; }

.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; max-width: 560px; margin: 0 auto; display: flex; gap: 8px; padding: 10px 12px calc(10px + var(--sab)); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-top: 1px solid var(--line); }
.bar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 0 7px; border-radius: 16px; background: var(--card); font-size: 12px; font-weight: 700; color: var(--ink); box-shadow: var(--shadow); transition: transform .12s var(--ease); }
.bar button:active { transform: scale(.94); }
.bar button:nth-child(1) svg { color: var(--green); } .bar button:nth-child(2) svg { color: var(--amber); } .bar button:nth-child(3) svg { transform: scaleX(-1); color: var(--dim); }
.bar .primary { flex: 1.6; background: var(--accent); color: var(--accent-ink); }
.bar .primary[disabled] { opacity: .45; }

/* sheets */
#sheet { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
#sheet.show { pointer-events: auto; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .38); opacity: 0; transition: opacity .25s; }
#sheet.show .sheet-bg { opacity: 1; }
.sheet-in { position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; max-height: 88vh; overflow-y: auto; background: var(--bg); border-radius: 26px 26px 0 0; padding: 10px 20px calc(22px + var(--sab)); transform: translateY(105%); transition: transform .32s var(--ease); user-select: text; -webkit-user-select: text; }
#sheet.show .sheet-in { transform: none; }
.grab { display: block; width: 38px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 12px; }
.sheet-in h3 { font-size: 22px; font-weight: 800; margin-bottom: 12px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opt { background: var(--card); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.opt b { font-size: 17px; } .opt small { color: var(--dim); }
.opt:active { transform: scale(.97); }
.lbl { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--dim); margin: 16px 0 6px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--dim); margin-top: 12px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 15px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.menu { display: flex; flex-direction: column; margin-top: 16px; background: var(--card); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.menu > * { display: flex; align-items: center; gap: 12px; padding: 15px 16px; font-weight: 600; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
.menu > *:last-child { border: 0; } .menu svg { color: var(--dim); } .menu > *:active { background: var(--soft); }
.sheet-btns { display: flex; gap: 8px; margin-top: 18px; }
.btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 15px; border-radius: 16px; font-weight: 700; font-size: 16px; }
.btn.primary { background: var(--accent); color: #fff; } .btn.ghost { background: var(--soft); }
.btn[disabled] { opacity: .4; } .btn:active { transform: scale(.98); }
details { margin-top: 16px; } summary { color: var(--dim); font-size: 14px; }

/* toast */
#toast { position: fixed; left: 12px; right: 12px; bottom: calc(92px + var(--sab)); z-index: 30; max-width: 536px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 13px 14px 13px 18px; border-radius: 18px; background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); transform: translateY(160%); opacity: 0; transition: transform .3s var(--ease), opacity .2s; overflow: hidden; }
#toast.show { transform: none; opacity: 1; }
.t-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-undo { display: flex; align-items: center; gap: 5px; padding: 7px 12px; border-radius: 12px; background: color-mix(in srgb, var(--bg) 16%, transparent); color: inherit; font-weight: 700; }
.t-undo svg { width: 17px; height: 17px; }
.t-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--accent); transform-origin: left; animation: shrink linear forwards; }

/* sign in */
.signin { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; padding: 32px; }
.signin h1 { font-size: 34px; font-weight: 800; letter-spacing: -.02em; }
.signin p { color: var(--dim); max-width: 280px; }
.signin .btn { flex: none; width: 100%; max-width: 320px; margin-top: 6px; }
.logo { width: 88px; height: 88px; border-radius: 24px; background: var(--accent); color: #fff; display: grid; place-items: center; margin-bottom: 8px; box-shadow: 0 14px 30px color-mix(in srgb, var(--accent) 35%, transparent); }
.logo svg { width: 46px; height: 46px; stroke-width: 2.8; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes slide { from { opacity: 0; transform: translateX(28px); } }
@keyframes pop { from { transform: scale(.4); opacity: 0; } 60% { transform: scale(1.08); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .3; } }
@keyframes shrink { to { transform: scaleX(0); } }
@keyframes burst { from { transform: rotate(var(--a)) translateY(0) scale(.4); opacity: 1; } to { transform: rotate(var(--a)) translateY(-130px) rotate(200deg) scale(1); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* time zones */
.zline { margin-top: 10px; padding: 11px 14px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); font-weight: 700; font-size: 15px; line-height: 1.5; }
.zline.solo { font-weight: 600; color: var(--dim); }
#zones { margin-top: 0; }

/* vault sources */
.src-h { margin-top: 14px; }
.srcs .chip { font-size: 13px; padding: 6px 11px; max-width: 70vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.note { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.5; margin-top: 12px; background: var(--card); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); }

/* compose */
.sheet-in.tall { min-height: 82vh; }
.seg.in-sheet { margin: 0 0 14px; }
.seg.in-sheet button { display: flex; align-items: center; justify-content: center; gap: 7px; }
.seg.in-sheet svg { width: 18px; height: 18px; }
.rcpt { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; background: var(--soft); border-radius: 14px; padding: 8px 12px; margin-bottom: 8px; }
.rcpt input { flex: 1; min-width: 110px; border: 0; outline: 0; background: none; padding: 6px 0; font-size: 16px; }
.rcpt .chip { padding: 5px 11px; }
.sug { display: flex; flex-direction: column; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; margin-bottom: 8px; }
.sug:empty { display: none; }
.sug button { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.sug button:last-child { border: 0; }
.sug .av { width: 32px; height: 32px; font-size: 12px; }
.sug span { display: flex; flex-direction: column; min-width: 0; } .sug small { color: var(--dim); overflow: hidden; text-overflow: ellipsis; }
#mail-form > input { margin-bottom: 8px; font-weight: 600; }
#mail-text { width: 100%; min-height: 150px; resize: none; font-size: 17px; line-height: 1.45; }
