:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --text2: #6e6e73;
  --text3: #8e8e93;
  --sep: #e5e5ea;
  --accent: #0a84ff;
  --green: #34c759;
  --orange: #ff9f0a;
  --red: #ff3b30;
  --nav-h: 50px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
svg { display: block; flex: none; }
html { -webkit-text-size-adjust: 100%; }
body {
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: env(safe-area-inset-bottom);
}

#app { min-height: 100dvh; }

/* ---------- nav ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(249,249,249,.94);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid #c6c6c8;
  display: flex;
}
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; text-decoration: none; color: var(--text3); font-size: 10px; font-weight: 500;
}
.nav a svg { width: 24px; height: 24px; }
.nav a.active { color: var(--accent); }
.nav a:active { opacity: .55; }

/* ---------- main ---------- */
.main {
  max-width: 600px; margin: 0 auto;
  padding: 0 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
}
.page-title {
  font-size: 30px; font-weight: 700; letter-spacing: -.4px;
  padding: 14px 0 6px;
}
.page-sub { color: var(--text2); font-size: 14px; padding-bottom: 12px; }

/* ---------- section / group (iOS inset list) ---------- */
.section-label {
  font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text3); padding: 18px 16px 7px;
}
.group {
  background: var(--card); border-radius: 12px; overflow: hidden;
}
.group + .section-label { padding-top: 24px; }

.row {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 11px 16px;
  position: relative; background: var(--card); text-decoration: none; color: var(--text);
  font-size: 16px;
}
.row:not(:last-child)::after {
  content: ""; position: absolute; left: 16px; right: 0; bottom: 0;
  height: .5px; background: var(--sep);
}
.row:active { background: #d9d9de; }
.row .chev { margin-left: auto; color: #c4c4c6; flex: none; }
.row .rmain { flex: 1; min-width: 0; }
.row .rtitle { font-size: 16px; overflow: hidden; text-overflow: ellipsis; }
.row .rsub { font-size: 13px; color: var(--text2); margin-top: 2px; }
.row .rval { color: var(--text2); font-size: 15px; margin-left: auto; text-align: right; }
.row.tall { align-items: flex-start; padding-top: 13px; padding-bottom: 13px; }
.overdue { color: var(--red); font-weight: 600; }

button.row { width: 100%; border: none; text-align: left; font: inherit; cursor: pointer; }
button.row:active { background: #d9d9de; }

/* ---------- stat strip ---------- */
.counts { display: flex; flex-direction: column; }
.counts .row { gap: 10px; }
.cdot { width: 10px; height: 10px; border-radius: 5px; flex: none; }
.cdot.todo { background: var(--text3); }
.cdot.in_progress { background: var(--accent); }
.cdot.ready_for_review { background: var(--orange); }
.cdot.overdue { background: var(--red); }
.cdot.approved { background: var(--green); }
.cnum { margin-left: auto; font-size: 16px; font-weight: 600; color: var(--text2); }

/* ---------- task list ---------- */
.dot { width: 10px; height: 10px; border-radius: 5px; flex: none; margin-top: 5px; align-self: flex-start; }
.prio-bar { width: 3px; border-radius: 2px; align-self: stretch; flex: none; }
.prio-bar.urgent { background: var(--red); }
.prio-bar.high { background: var(--orange); }
.prio-bar.medium { background: var(--accent); }
.prio-bar.low { background: #c4c4c6; }

.badge-sm {
  display: inline-block; padding: 1px 7px; border-radius: 10px;
  font-size: 12px; font-weight: 600; line-height: 18px; vertical-align: middle;
}
.badge-sm.pending { background: #e9e9eb; color: #48484a; }
.badge-sm.in_progress { background: #e3f0ff; color: #0066d6; }
.badge-sm.ready_for_review { background: #fff0dc; color: #c26a00; }
.badge-sm.approved { background: #e4f7e8; color: #248a3d; }
.badge-sm.urgent { background: #ffe3e0; color: #d02f23; }
.badge-sm.high { background: #fff0dc; color: #c26a00; }

.empty { padding: 40px 20px; text-align: center; color: var(--text3); font-size: 15px; }

/* ---------- header w/ action ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0 2px;
}
.topbar h1 { font-size: 30px; font-weight: 700; letter-spacing: -.4px; }
.topbar .btn-add {
  width: 34px; height: 34px; border-radius: 17px; border: none;
  background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center;
}
.topbar .btn-add:active { opacity: .6; }
.topbar .btn-add svg { width: 20px; height: 20px; }

/* ---------- header row (bell + user) ---------- */
.util { display: flex; gap: 8px; padding: 8px 0 2px; }
.util button {
  flex: 1; height: 38px; border: none; border-radius: 10px; background: var(--card);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 14px; font-weight: 600; color: var(--text); position: relative;
}
.util button:active { background: #e5e5ea; }
.util button svg { width: 18px; height: 18px; }
.util .nbadge {
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---------- login ---------- */
.login { max-width: 320px; margin: 0 auto; padding: 10vh 16px 40px; }
.login h1 { font-size: 26px; font-weight: 700; letter-spacing: -.3px; margin-bottom: 4px; }
.login p.sub { color: var(--text2); font-size: 15px; margin-bottom: 26px; }

/* ---------- fields ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text2); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 11px 12px;
  border: .5px solid #d1d1d6; border-radius: 10px; background: var(--card);
  font: inherit; color: var(--text);
}
.field textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
}
.hint { font-size: 12.5px; color: var(--text3); }
.req { color: var(--red); }

/* ---------- segmented ---------- */
.seg { display: flex; gap: 2px; background: #e9e9eb; border-radius: 9px; padding: 2px; }
.seg button {
  flex: 1; height: 34px; border: none; background: none; border-radius: 7px;
  font-size: 14px; font-weight: 500; color: var(--text);
}
.seg button.on { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }

/* ---------- buttons ---------- */
.btn {
  min-height: 48px; width: 100%; border: none; border-radius: 12px;
  font-size: 17px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--accent); color: #fff;
}
.btn:active { opacity: .75; }
.btn.secondary { background: #e9e9eb; color: var(--accent); }
.btn.success { background: var(--green); }
.btn.danger { background: #fff; color: var(--red); border: .5px solid #d1d1d6; }
.btn.sm { min-height: 38px; font-size: 15px; width: auto; padding: 0 14px; }

/* ---------- detail ---------- */
.detail-title { font-size: 22px; font-weight: 700; line-height: 1.2; letter-spacing: -.3px; padding: 4px 0 2px; }
.link { color: var(--accent); text-decoration: none; word-break: break-all; }
.txt { white-space: pre-wrap; font-size: 16px; line-height: 1.55; }

.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb { position: relative; }
.thumb img {
  width: 92px; height: 92px; object-fit: cover; border-radius: 10px;
  border: .5px solid var(--sep); background: #fff;
}
.thumb .del {
  position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 12px;
  border: none; background: var(--red); color: #fff; font-size: 15px; line-height: 1;
}
.file-label {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; border: 1px dashed #c4c4c6; border-radius: 10px;
  color: var(--text2); font-size: 15px; font-weight: 500;
}
.file-label:active { background: #e9e9eb; }
.file-label input { display: none; }

.comment {
  padding: 12px 16px; position: relative; background: var(--card);
}
.comment + .comment::before {
  content: ""; position: absolute; left: 16px; right: 0; top: 0; height: .5px; background: var(--sep);
}
.comment .who { font-size: 14px; font-weight: 600; }
.comment .when { font-size: 12px; color: var(--text3); }
.comment .kind { font-size: 12px; font-weight: 600; }
.comment .kind.feedback { color: var(--orange); }
.comment .kind.submission { color: var(--accent); }
.comment .body { font-size: 15px; white-space: pre-wrap; margin-top: 4px; line-height: 1.5; }

.timeline { list-style: none; }
.timeline li { padding: 10px 16px; position: relative; font-size: 15px; }
.timeline li + li::before {
  content: ""; position: absolute; left: 16px; right: 0; top: 0; height: .5px; background: var(--sep);
}
.timeline .when { font-size: 12.5px; color: var(--text3); margin-top: 2px; }
.timeline .move { font-size: 13px; color: var(--text2); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(28,28,30,.92); color: #fff; padding: 11px 16px; border-radius: 20px;
  font-size: 14px; font-weight: 500; z-index: 40; max-width: 86vw;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.toast.err { background: rgba(255,59,48,.95); }

/* ---------- modal (sheet) ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  width: 100%; max-width: 560px; background: var(--bg);
  border-radius: 14px 14px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow-y: auto;
}
.modal h3 { font-size: 17px; font-weight: 600; text-align: center; padding: 6px 0 12px; }
.modal .sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }

/* ---------- dropdown (notification sheet) ---------- */
.dropdown {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  background: var(--bg); border-radius: 14px 14px 0 0;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  max-height: 80vh; overflow-y: auto;
  box-shadow: 0 -8px 40px rgba(0,0,0,.18);
}
.dropdown .head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 16px 10px; font-size: 17px; font-weight: 600;
}
.dropdown .head button { background: none; border: none; color: var(--accent); font-size: 15px; font-weight: 500; }
.dropdown .item { padding: 12px 16px; position: relative; }
.dropdown .item + .item::before {
  content: ""; position: absolute; left: 16px; right: 0; top: 0; height: .5px; background: var(--sep);
}
.dropdown .item.unread { background: rgba(10,132,255,.07); }
.dropdown .item .when { font-size: 12px; color: var(--text3); margin-top: 3px; }

/* ---------- loading ---------- */
.loading { padding: 60px 0; text-align: center; color: var(--text3); font-size: 15px; }
.loading::before {
  content: ""; display: block; width: 22px; height: 22px; margin: 0 auto 10px;
  border: 2px solid #d1d1d6; border-top-color: var(--text3); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
