/* Cloud9 Hub — design system */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface2: #eef1f0;
  --text: #16211d;
  --text2: #5b6b65;
  --text3: #93a29c;
  --line: rgba(22, 33, 29, .08);
  --accent: #0da678;
  --accent-soft: rgba(13, 166, 120, .12);
  --accent-text: #067a57;
  --violet: #8b5cf6;
  --violet-soft: rgba(139, 92, 246, .12);
  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, .1);
  --amber: #d97706;
  --amber-soft: rgba(217, 119, 6, .12);
  --shadow: 0 1px 2px rgba(16, 24, 20, .05), 0 8px 24px rgba(16, 24, 20, .06);
  --shadow-lg: 0 24px 64px rgba(16, 24, 20, .22);
  --radius: 18px;
  --nav-h: calc(78px + env(safe-area-inset-bottom, 0px));
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1210;
    --surface: #151d1a;
    --surface2: #1c2622;
    --text: #e8efec;
    --text2: #9db0a9;
    --text3: #64756f;
    --line: rgba(232, 239, 236, .08);
    --accent: #2dd4a0;
    --accent-soft: rgba(45, 212, 160, .13);
    --accent-text: #5ce8bb;
    --violet: #a78bfa;
    --violet-soft: rgba(167, 139, 250, .14);
    --danger: #ff6369;
    --danger-soft: rgba(255, 99, 105, .12);
    --amber: #fbbf24;
    --amber-soft: rgba(251, 191, 36, .13);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
  }
}

html { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100%;
  font-size: 16px; line-height: 1.45;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

/* ── Icons ── */
.ic { width: 20px; height: 20px; flex-shrink: 0; }
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 24px; height: 24px; }

/* ── Boot splash ── */
.boot { display: grid; place-items: center; height: 100vh; }
.boot-logo {
  width: 88px; height: 88px; border-radius: 24px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff; font-weight: 800; font-size: 34px; letter-spacing: -1px;
  box-shadow: var(--shadow-lg);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.06); opacity: .85; } }

/* ── Auth ── */
.auth-wrap {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; gap: 28px;
}
.auth-hero { text-align: center; }
.auth-logo {
  width: 76px; height: 76px; border-radius: 22px; margin: 0 auto 16px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #10b981, #047857);
  color: #fff; font-weight: 800; font-size: 30px; letter-spacing: -1px;
  box-shadow: 0 12px 32px rgba(16, 185, 129, .35);
}
.auth-hero h1 { font-size: 26px; letter-spacing: -.5px; }
.auth-hero p { color: var(--text2); margin-top: 6px; font-size: 15px; }
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border-radius: 24px; box-shadow: var(--shadow);
  padding: 24px; display: flex; flex-direction: column; gap: 12px;
  border: 1px solid var(--line);
}
.auth-switch { text-align: center; color: var(--text2); font-size: 14px; }
.auth-switch a { color: var(--accent-text); font-weight: 600; text-decoration: none; cursor: pointer; }

/* ── Inputs / buttons ── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text2); }
input, textarea, select {
  font: inherit; color: var(--text);
  background: var(--surface2); border: 1.5px solid transparent; border-radius: 13px;
  padding: 12px 14px; width: 100%; outline: none;
  transition: border-color .15s, background .15s;
  appearance: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); background: var(--surface); }
textarea { resize: vertical; min-height: 72px; }
input[type="date"], input[type="time"] { min-height: 46px; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--text3) 50%), linear-gradient(135deg, var(--text3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }

.btn {
  font: inherit; font-weight: 700; font-size: 15px;
  border: none; border-radius: 14px; padding: 13px 18px;
  cursor: pointer; transition: transform .1s, opacity .15s, background .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, #10b981, #059669); color: #fff; box-shadow: 0 6px 18px rgba(16, 185, 129, .3); }
.btn-ghost { background: var(--surface2); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: 8px 14px; font-size: 13.5px; border-radius: 11px; }
.btn[disabled] { opacity: .55; pointer-events: none; }

.err-msg {
  background: var(--danger-soft); color: var(--danger);
  font-size: 13.5px; font-weight: 600; border-radius: 12px; padding: 10px 14px;
}

/* ── App shell ── */
.shell { min-height: 100vh; min-height: 100dvh; padding-bottom: var(--nav-h); }
.page { max-width: 680px; margin: 0 auto; padding: 0 16px 32px; animation: fadein .18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 10px;
  border-bottom: 1px solid var(--line);
  margin: 0 -16px 16px;
}
.topbar-inner { max-width: 648px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.topbar h1 { font-size: 21px; letter-spacing: -.4px; flex: 1; }
.topbar .sub { font-size: 13px; color: var(--text2); font-weight: 500; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px;
  cursor: pointer; flex-shrink: 0;
}

/* ── Bottom tab bar (iOS style) ── */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(24px) saturate(1.6); -webkit-backdrop-filter: blur(24px) saturate(1.6);
  border-top: 0.5px solid var(--line);
  display: flex; justify-content: space-around; align-items: flex-start;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
}
.nav-item {
  flex: 1; max-width: 110px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 4px; border: none; background: none; cursor: pointer;
  color: var(--text3); font: inherit; font-size: 10px; font-weight: 600; letter-spacing: .01em;
  transition: color .15s;
}
.nav-item .ic { width: 25px; height: 25px; transition: transform .18s cubic-bezier(.34, 1.56, .64, 1); }
.nav-item.active { color: var(--accent-text); }
.nav-item.active .ic { transform: scale(1.08); }
.nav-item:active .ic { transform: scale(.88); }

/* ── Cards / lists ── */
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--line);
  padding: 16px; margin-bottom: 14px;
}
.section-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text3); margin: 20px 4px 10px; display: flex; align-items: center; gap: 8px;
}
.section-title .count {
  background: var(--surface2); color: var(--text2); border-radius: 99px;
  font-size: 11.5px; padding: 1px 8px;
}
.empty {
  text-align: center; color: var(--text3); padding: 28px 16px; font-size: 14.5px;
}
.empty .ic { width: 36px; height: 36px; margin-bottom: 10px; opacity: .6; }

/* ── Task rows ── */
.task {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 13px 14px; margin-bottom: 8px; box-shadow: var(--shadow);
  cursor: pointer; transition: transform .1s;
}
.task:active { transform: scale(.99); }
.task.done { opacity: .55; }
.task.done .task-title { text-decoration: line-through; }
.checkbox {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; margin-top: 1px;
  border: 2px solid var(--text3); display: grid; place-items: center;
  background: none; cursor: pointer; transition: all .15s; color: transparent; padding: 0;
}
.checkbox .ic { width: 14px; height: 14px; }
.checkbox.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 15px; word-wrap: break-word; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; align-items: center; }
.chip {
  font-size: 11.5px; font-weight: 700; border-radius: 8px; padding: 2.5px 8px;
  display: inline-flex; align-items: center; gap: 4px;
}
.chip .ic { width: 12px; height: 12px; }
.chip-date { background: var(--surface2); color: var(--text2); }
.chip-date.today { background: var(--accent-soft); color: var(--accent-text); }
.chip-date.overdue { background: var(--danger-soft); color: var(--danger); }
.chip-sub { background: var(--violet-soft); color: var(--violet); }
.chip-prio { background: var(--amber-soft); color: var(--amber); }
.chip-att { background: var(--surface2); color: var(--text2); }
.chip-user { color: #fff; }

/* ── Calendar ── */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head h2 { font-size: 18px; letter-spacing: -.3px; text-transform: capitalize; }
.cal-btns { display: flex; gap: 6px; }
.cal-nav-btn {
  height: 38px; min-width: 38px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer;
  display: grid; place-items: center; transition: background .15s;
  font: inherit; font-size: 12px; font-weight: 700; padding: 0 10px;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--text3); padding: 5px 0; text-transform: uppercase; }
.cal-day {
  aspect-ratio: 1 / 1.05; border-radius: 12px; border: none; background: none;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding-top: 6px; gap: 3px; cursor: pointer; font: inherit; color: var(--text);
  position: relative; transition: background .12s;
}
.cal-day:active { background: var(--surface2); }
.cal-day.dim { color: var(--text3); opacity: .45; }
.cal-day .n {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-size: 14.5px; font-weight: 600;
}
.cal-day.today .n { background: var(--accent-soft); color: var(--accent-text); font-weight: 800; }
.cal-day.sel .n { background: var(--accent); color: #fff; font-weight: 800; }
.cal-dots { display: flex; gap: 2.5px; height: 5px; }
.dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.dot.t { background: var(--amber); }
.dot.more { background: var(--text3); }

.agenda { margin-top: 18px; }
.agenda h3 { font-size: 15.5px; margin-bottom: 10px; color: var(--text2); font-weight: 600; }
.event-row {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: pointer;
  transition: transform .1s;
}
.event-row:active { transform: scale(.99); }
.event-stripe { width: 4px; align-self: stretch; border-radius: 4px; background: var(--accent); flex-shrink: 0; }
.event-time { font-size: 12.5px; font-weight: 700; color: var(--text2); min-width: 44px; padding-top: 2px; }
.event-body { flex: 1; min-width: 0; }
.event-title { font-weight: 600; font-size: 15px; }
.event-notes { font-size: 13px; color: var(--text2); margin-top: 3px; white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ── Today ── */
.hero-date { margin: 6px 4px 16px; }
.hero-date .dow { color: var(--accent-text); font-weight: 700; font-size: 13.5px; text-transform: uppercase; letter-spacing: .05em; }
.hero-date .d { font-size: 28px; font-weight: 800; letter-spacing: -.6px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 6px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 12px 14px; box-shadow: var(--shadow); cursor: pointer;
}
.stat .v { font-size: 24px; font-weight: 800; letter-spacing: -.5px; }
.stat .l { font-size: 11.5px; color: var(--text2); font-weight: 600; margin-top: 1px; }
.stat.warn .v { color: var(--danger); }

/* ── Installations ── */
.inst-head { display: flex; align-items: center; gap: 10px; }
.inst-head .dev-ic {
  width: 40px; height: 40px; border-radius: 13px; background: var(--accent-soft);
  color: var(--accent-text); display: grid; place-items: center; flex-shrink: 0;
}
.inst-head h3 { font-size: 16px; flex: 1; }
.inst-head .loc { font-weight: 500; color: var(--text3); font-size: 13px; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text3); }
.online-dot.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .2); }

.inst-slot { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.inst-slot-head { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.inst-week {
  width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0;
  background: var(--violet-soft); color: var(--violet);
  display: grid; place-items: center; font-weight: 800; font-size: 12px; text-align: center; line-height: 1.15;
}
.inst-week.idle { background: var(--surface2); color: var(--text3); }
.inst-body { flex: 1; min-width: 0; }
.inst-name { font-weight: 700; font-size: 14.5px; }
.inst-next { font-size: 12.5px; color: var(--text2); margin-top: 2px; }
.progress { height: 5px; border-radius: 99px; background: var(--surface2); margin-top: 7px; overflow: hidden; }
.progress > div { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #10b981, #8b5cf6); }
.inst-chev { color: var(--text3); transition: transform .2s; }
.inst-chev.open { transform: rotate(90deg); }

.week-plan { margin-top: 12px; display: flex; flex-direction: column; gap: 2px; }
.week-row {
  display: flex; gap: 12px; align-items: flex-start; padding: 9px 10px; border-radius: 12px;
}
.week-row.current { background: var(--accent-soft); }
.week-badge {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; margin-top: 1px;
  display: grid; place-items: center; font-size: 11.5px; font-weight: 800;
  background: var(--surface2); color: var(--text3);
}
.week-row.current .week-badge { background: var(--accent); color: #fff; }
.week-badge.done { background: var(--accent-soft); color: var(--accent-text); }
.week-badge.done .ic { width: 13px; height: 13px; }
.week-badge.missed { background: var(--amber-soft); color: var(--amber); }
.week-info { flex: 1; min-width: 0; }
.week-title { font-size: 13.5px; font-weight: 650; }
.week-row.current .week-title { color: var(--accent-text); }
.week-sub { font-size: 12px; color: var(--text3); margin-top: 1px; }
.week-action { font-size: 12.5px; color: var(--text2); margin-top: 5px; line-height: 1.45; }

/* ── FAB ── */
.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + 14px); z-index: 25;
  width: 58px; height: 58px; border-radius: 19px; border: none; cursor: pointer;
  background: linear-gradient(135deg, #10b981, #059669); color: #fff;
  box-shadow: 0 10px 28px rgba(16, 185, 129, .45);
  display: grid; place-items: center; transition: transform .12s;
}
.fab .ic { width: 26px; height: 26px; }
.fab:active { transform: scale(.92); }

/* ── Sheet (modal) ── */
.sheet-back {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(8, 12, 10, .5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadein .15s ease;
}
.sheet {
  width: 100%; max-width: 560px; max-height: 88vh; max-height: 88dvh; overflow-y: auto;
  background: var(--surface); border-radius: 24px 24px 0 0;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--shadow-lg);
  animation: slideup .22s cubic-bezier(.2, .9, .3, 1);
}
@keyframes slideup { from { transform: translateY(40px); opacity: .6; } }
@media (min-width: 640px) {
  .sheet-back { align-items: center; padding: 24px; }
  .sheet { border-radius: 24px; padding-bottom: 20px; }
}
.sheet-grip { width: 40px; height: 4.5px; border-radius: 99px; background: var(--line); margin: 6px auto 14px; }
.sheet h2 { font-size: 19px; letter-spacing: -.3px; margin-bottom: 16px; }
.sheet .form { display: flex; flex-direction: column; gap: 13px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions .btn-primary { flex: 1; }
.sheet-label { font-size: 13px; font-weight: 700; color: var(--text2); margin-top: 4px; }

/* ── Markdown notes ── */
.notes-head { display: flex; align-items: center; justify-content: space-between; }
.md {
  font-size: 14px; line-height: 1.55; color: var(--text);
  background: var(--surface2); border-radius: 13px; padding: 12px 14px;
  overflow-wrap: break-word; max-height: 46vh; overflow-y: auto;
}
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h2, .md h3, .md h4, .md h5 { margin: 14px 0 6px; letter-spacing: -.2px; line-height: 1.3; }
.md h2 { font-size: 17px; } .md h3 { font-size: 15.5px; } .md h4, .md h5 { font-size: 14px; }
.md p { margin: 6px 0; }
.md ul, .md ol { margin: 6px 0; padding-left: 22px; }
.md li { margin: 3px 0; }
.md .md-sub { color: var(--text2); font-size: 13px; }
.md blockquote { border-left: 3px solid var(--accent); padding: 2px 12px; margin: 8px 0; color: var(--text2); }
.md hr { border: none; border-top: 1px solid var(--line); margin: 12px 0; }
.md code {
  background: color-mix(in srgb, var(--text) 8%, transparent);
  border-radius: 5px; padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em;
}
.md pre {
  background: color-mix(in srgb, var(--text) 7%, transparent);
  border-radius: 10px; padding: 10px 12px; margin: 8px 0; overflow-x: auto;
}
.md pre code { background: none; padding: 0; font-size: 12.5px; line-height: 1.5; }
.md a { color: var(--accent-text); font-weight: 600; }
.md .tbl { overflow-x: auto; margin: 8px 0; border-radius: 10px; border: 1px solid var(--line); }
.md table { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.md th, .md td { border-bottom: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; white-space: nowrap; }
.md td { white-space: normal; min-width: 70px; }
.md th { background: color-mix(in srgb, var(--text) 5%, transparent); font-weight: 700; font-size: 12px; }
.md tr:last-child td { border-bottom: none; }

/* ── Subtasks in sheet ── */
.subtask-list { display: flex; flex-direction: column; gap: 6px; }
.subtask-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface2); border-radius: 12px; padding: 9px 12px;
}
.subtask-row .checkbox { width: 21px; height: 21px; }
.subtask-row .st-title { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; cursor: pointer; }
.subtask-row.done .st-title { text-decoration: line-through; opacity: .6; }
.subtask-row .st-date { font-size: 11.5px; font-weight: 700; color: var(--text2); }
.subtask-row .st-date.overdue { color: var(--danger); }
.st-del { background: none; border: none; color: var(--text3); cursor: pointer; padding: 2px; display: grid; place-items: center; }
.st-del .ic { width: 15px; height: 15px; }
.subtask-add { display: flex; gap: 8px; }
.subtask-add input { flex: 1; padding: 10px 12px; border-radius: 12px; }
.subtask-add .btn { padding: 0 14px; border-radius: 12px; }

/* ── Attachments ── */
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.att-item {
  position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden;
  background: var(--surface2); border: 1px solid var(--line); cursor: pointer;
}
.att-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-item .att-file {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; color: var(--text2);
  font-size: 9.5px; font-weight: 700; padding: 4px; text-align: center; word-break: break-all;
}
.att-del {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px;
  border-radius: 50%; border: none; cursor: pointer;
  background: rgba(0, 0, 0, .55); color: #fff; display: grid; place-items: center;
}
.att-del .ic { width: 12px; height: 12px; }
.att-add {
  aspect-ratio: 1; border-radius: 12px; border: 1.5px dashed var(--text3);
  background: none; color: var(--text2); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font: inherit; font-size: 10px; font-weight: 700;
}
.att-add .ic { width: 20px; height: 20px; }
.att-uploading { opacity: .5; pointer-events: none; }

/* ── Lightbox ── */
.lightbox {
  position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .92);
  display: grid; place-items: center; animation: fadein .15s ease; cursor: zoom-out;
}
.lightbox img { max-width: 100vw; max-height: 100vh; object-fit: contain; }
.lightbox .lb-close {
  position: absolute; top: calc(14px + env(safe-area-inset-top, 0px)); right: 16px;
  width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255, 255, 255, .14); color: #fff; display: grid; place-items: center;
}

/* ── Profile sheet bits ── */
.profile-row { display: flex; align-items: center; gap: 14px; padding: 8px 0 16px; }
.profile-row .avatar { width: 52px; height: 52px; font-size: 20px; }
.profile-row .nm { font-weight: 700; font-size: 17px; }
.profile-row .em { color: var(--text2); font-size: 13.5px; }

/* ── Toast ── */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 16px); z-index: 60;
  background: var(--text); color: var(--bg);
  font-size: 14px; font-weight: 600; padding: 11px 20px; border-radius: 99px;
  box-shadow: var(--shadow-lg); animation: toastin .25s cubic-bezier(.2, .9, .3, 1);
  max-width: 90vw; text-align: center;
}
@keyframes toastin { from { transform: translate(-50%, 12px); opacity: 0; } }

.link-btn {
  background: none; border: none; color: var(--accent-text); font: inherit;
  font-size: 14px; font-weight: 600; cursor: pointer; padding: 0;
  display: inline-flex; align-items: center; gap: 6px;
}

.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 2px; }
.toggle-row span { font-size: 14.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.switch { position: relative; width: 48px; height: 29px; flex-shrink: 0; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; cursor: pointer; z-index: 2; }
.switch .tr {
  position: absolute; inset: 0; border-radius: 99px; background: var(--surface2); transition: background .18s;
  border: 1px solid var(--line);
}
.switch .tr::after {
  content: ''; position: absolute; top: 2.5px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25); transition: transform .18s;
}
.switch input:checked + .tr { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .tr::after { transform: translateX(19px); }

::-webkit-scrollbar { width: 0; height: 0; }

/* ── Task list: groups / pin / inline rename (v6) ── */
.group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 6px 8px; cursor: pointer; user-select: none; -webkit-user-select: none;
  color: var(--text);
}
.group-head .ic { color: var(--accent-text); }
.group-chev { color: var(--text3); transition: transform .18s; display: grid; place-items: center; }
.group-chev .ic { color: var(--text3); }
.group-chev.open { transform: rotate(90deg); }
.group-name { font-weight: 750; font-size: 15px; letter-spacing: -.2px; }
.group-head .count {
  background: var(--surface2); color: var(--text2); border-radius: 99px;
  font-size: 11.5px; font-weight: 700; padding: 1px 8px;
}
.group-head .row-more { margin-left: auto; }
.group-body { margin-bottom: 4px; }
.group-empty { font-size: 13.5px; color: var(--text3); padding: 6px 10px 10px 34px; }

.row-more {
  border: none; background: none; color: var(--text3); cursor: pointer;
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  flex-shrink: 0; margin: -4px -6px -4px 0; transition: background .15s, color .15s;
}
.row-more:active { background: var(--surface2); color: var(--text); }

.rename-input {
  font: inherit; font-weight: 600; font-size: 15px; color: var(--text);
  background: var(--surface2); border: 1.5px solid var(--accent); border-radius: 9px;
  padding: 4px 9px; width: 100%; outline: none;
}
.chip-pin { background: var(--accent-soft); color: var(--accent-text); padding: 2.5px 5px; }
.new-group-btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1.5px dashed var(--text3); background: none; border-radius: 13px;
  color: var(--text2); font: inherit; font-size: 14px; font-weight: 650;
  padding: 10px 16px; cursor: pointer; margin-top: 10px; transition: color .15s, border-color .15s;
}
.new-group-btn:active { color: var(--accent-text); border-color: var(--accent); }
.menu-list .btn { justify-content: flex-start; padding: 14px 16px; }
.menu-list .btn.sel { outline: 2px solid var(--accent); }

/* ── Documents (v7) ── */
.search-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 4px 8px 4px 14px; margin-bottom: 14px; box-shadow: var(--shadow);
  color: var(--text3);
}
.search-box input { background: none; border: none; padding: 10px 0; border-radius: 0; }
.search-box input:focus { background: none; border: none; }
.doc-row {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 13px 14px; margin-bottom: 8px; box-shadow: var(--shadow);
  cursor: pointer; transition: transform .1s;
}
.doc-row:active { transform: scale(.99); }
.doc-ic {
  width: 42px; height: 42px; border-radius: 13px; flex-shrink: 0;
  background: var(--amber-soft); color: var(--amber);
  display: grid; place-items: center;
}
.doc-ic.link { background: var(--accent-soft); color: var(--accent-text); }
.doc-body { flex: 1; min-width: 0; }
.doc-title { font-weight: 650; font-size: 15px; word-wrap: break-word; display: inline-flex; align-items: center; gap: 5px; }
.doc-title .ext { color: var(--text3); }
.doc-desc {
  font-size: 13px; color: var(--text2); margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.doc-meta { font-size: 11.5px; color: var(--text3); margin-top: 4px; font-weight: 600; }
.seg .ic-sm { vertical-align: -3px; margin-right: 3px; }

/* ── v8: mobile overflow fixes, drag&drop, quick add ── */
html, body { overflow-x: hidden; max-width: 100vw; }
.task-title, .event-title, .doc-title, .doc-desc, .doc-meta, .st-title, .inst-name, .group-name, .week-title
  { overflow-wrap: anywhere; }
.field { min-width: 0; }
.form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row > * { min-width: 0; }
.task-meta { min-width: 0; }
.chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.task { touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.task.dragging { opacity: .35; }
.drag-ghost {
  position: fixed; z-index: 100; pointer-events: none; margin: 0;
  box-shadow: var(--shadow-lg); opacity: .97; will-change: transform;
}
.task.drop-before { box-shadow: 0 -3px 0 0 var(--accent), var(--shadow); }
.task.drop-after { box-shadow: 0 3px 0 0 var(--accent), var(--shadow); }
.group-head.drop-target, .section-title.drop-target {
  background: var(--accent-soft); border-radius: 12px; color: var(--accent-text);
}
.group-head.drop-target .group-name { color: var(--accent-text); }

.qa-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px 14px; border: none; background: none; cursor: pointer;
  color: var(--text3); font: inherit; font-size: 14.5px; font-weight: 600;
  border-radius: 14px; text-align: left; margin-bottom: 4px;
}
.qa-row .ic { color: var(--accent-text); }
.qa-row:active { background: var(--surface2); }
.qa-row.active {
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  cursor: text;
}
.qa-row input { background: none; border: none; padding: 2px 0; font-size: 15px; border-radius: 0; }
.qa-row input:focus { background: none; border: none; }

/* ── v10: Telegram-style folder chips + modern tab bar ── */
.chips-row {
  display: flex; gap: 8px; overflow-x: auto; align-items: center;
  max-width: 680px; margin: 10px auto 0; padding: 2px 0 2px;
  scrollbar-width: none; -ms-overflow-style: none;
}
.chips-row::-webkit-scrollbar { display: none; }
.fchip {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text2); font: inherit; font-size: 13.5px; font-weight: 650;
  cursor: pointer; transition: background .15s, color .15s, transform .1s;
  user-select: none; -webkit-user-select: none;
}
.fchip:active { transform: scale(.96); }
.fchip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.fchip .cnt { font-size: 11px; font-weight: 800; opacity: .65; }
.fchip.on .cnt { opacity: .85; }
.fchip.add { color: var(--accent-text); border-style: dashed; background: none; }
.fchip-more { display: inline-flex; margin: -2px -6px -2px 0; padding: 2px; opacity: .85; }
.fchip.drop-target { background: var(--accent-text); border-color: var(--accent-text); color: #fff; transform: scale(1.06); }

/* Tab bar — solid, big icons, tinted active (Telegram/Instagram vibe) */
.nav {
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(24px) saturate(1.5); -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border-top: 0.5px solid var(--line);
  padding: 5px 4px calc(4px + env(safe-area-inset-bottom, 0px));
}
.nav-item { gap: 3px; font-size: 9.5px; font-weight: 600; letter-spacing: .02em; padding: 5px 2px 3px; color: var(--text3); }
.nav-item .ic { width: 27px; height: 27px; transition: transform .22s cubic-bezier(.34, 1.7, .64, 1); }
.nav-item.active { color: var(--accent-text); }
.nav-item.active .ic { transform: none; }
.nav-item.active .ic * { stroke-width: 2.3; }
.nav-item:active .ic { transform: scale(.85); }

/* ── v11: floating pill tab bar + topbar edge padding fix ── */
:root { --nav-h: calc(86px + env(safe-area-inset-bottom, 0px)); }

.topbar { margin: 0 0 16px; }

.nav {
  position: fixed; left: 50%; transform: translateX(-50%); right: auto;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  width: min(calc(100% - 40px), 380px);
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(28px) saturate(1.6); -webkit-backdrop-filter: blur(28px) saturate(1.6);
  box-shadow: 0 12px 40px rgba(10, 20, 16, .22), 0 2px 8px rgba(10, 20, 16, .1);
  padding: 7px 10px;
  display: flex; justify-content: space-around; align-items: center;
}
@media (prefers-color-scheme: dark) {
  .nav { box-shadow: 0 12px 40px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .4); }
}
.nav-item { flex: 1; max-width: none; padding: 0; gap: 0; font-size: 0; }
.nav-item .nav-ico {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  transition: background .18s, color .18s;
}
.nav-item .ic { width: 25px; height: 25px; }
.nav-item.active .nav-ico { background: var(--accent-soft); }
.nav-item.active { color: var(--accent-text); }
.nav-item:active .nav-ico { transform: scale(.88); }
.nav-item .nav-ico { transition: background .18s, transform .15s; }

.fab { bottom: calc(var(--nav-h) + 6px); }
.toast { bottom: calc(var(--nav-h) + 10px); }

/* ── v13: task comments ── */
.cmt-list { display: flex; flex-direction: column; gap: 12px; }
.cmt { display: flex; gap: 10px; align-items: flex-start; }
.cmt-main { flex: 1; min-width: 0; }
.cmt-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 3px;
  font-size: 12.5px;
}
.cmt-head b { font-size: 13px; }
.cmt-head span { color: var(--text3); font-weight: 500; }
.cmt-head .st-del { margin-left: auto; }
.cmt-body { font-size: 14px; padding: 10px 12px; max-height: none; }
.cmt-add { display: flex; gap: 8px; align-items: flex-end; }
.cmt-add textarea { flex: 1; min-height: 0; resize: none; }
.cmt-send { padding: 12px; border-radius: 13px; flex-shrink: 0; }
.cmt-send .ic { width: 18px; height: 18px; }

/* ── v14: autosave hint ── */
.autosave-hint { font-size: 11.5px; font-weight: 600; color: var(--text3); letter-spacing: 0; }

/* ── QR-карточка ───────────────────────────────────────────────────────────
   Плитки, а не диаграмма: три числа на экране телефона читаются сразу,
   а круговая из пяти долей — нет. Полоски по ролям в один цвет: роль
   называет подпись, цвет здесь носит только величину. */
/* Код во всю ширину карточки: его снимают с экрана чужой камерой, и каждый
   лишний миллиметр — это лишняя секунда наведения. */
.qr-card { padding: 14px; }
.qr-big { width: 100%; height: auto; display: block; background: #fff; border-radius: 12px; padding: 12px; }
.qr-url { color: var(--text3); font-size: 13px; text-align: center; margin-top: 10px; }
.qr-icons { display: flex; gap: 8px; margin-top: 14px; }
.qr-icons a, .qr-icons button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 11px 4px; border: 0; border-radius: 12px; background: var(--surface2);
  color: var(--text); text-decoration: none; font: inherit; font-size: 11px; cursor: pointer;
}
.qr-icons .ic { width: 21px; height: 21px; color: var(--accent-text); }
.card-acts { display: flex; gap: 8px; margin-top: 16px; }
.card-acts a {
  flex: 1; text-align: center; padding: 11px 6px; border-radius: 12px;
  background: var(--surface2); color: var(--text); text-decoration: none; font-size: 13.5px; font-weight: 600;
}
.c-acts { display: flex; gap: 8px; margin-bottom: 12px; }
.c-acts button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 12px 4px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 11.5px; cursor: pointer;
}
.c-acts .ic { width: 20px; height: 20px; color: var(--accent-text); }
.scan-shot {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px; border: 1px dashed var(--line); border-radius: 14px; background: var(--surface2);
  color: var(--accent-text); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
.scan-thumb { width: 100%; border-radius: 12px; margin-bottom: 10px; display: block; }
.scan-msg { font-size: 13.5px; color: var(--text2); margin: 10px 0 2px; display: flex; align-items: center; gap: 8px; }
.scan-msg.err { color: var(--danger); }
.scan-msg.ok { color: var(--accent-text); }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--surface2);
        border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.kpi-row { display: flex; gap: 12px; }
.kpi { flex: 1; min-width: 0; }
.kpi b { display: block; font-size: 27px; font-weight: 700; letter-spacing: -.02em; line-height: 1.05; }
.kpi span { display: block; color: var(--text3); font-size: 11.5px; margin-top: 4px; line-height: 1.3; }
.kpi-note { color: var(--text2); font-size: 13px; line-height: 1.5; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.rrow { display: flex; align-items: center; gap: 10px; margin-top: 9px; font-size: 14px; }
.rrow .rl { width: 112px; flex: none; color: var(--text2); }
.rbar { flex: 1; height: 8px; border-radius: 999px; background: var(--surface2); overflow: hidden; }
.rbar i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.rrow .rn { width: 26px; flex: none; text-align: right; font-weight: 700; }
.ct { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.ct:first-of-type { border-top: 0; padding-top: 4px; }
.ct-main { flex: 1; min-width: 0; }
.ct-name { font-size: 15px; font-weight: 600; }
.ct-done { color: var(--accent-text); }
.ct-done .ic { width: 14px; height: 14px; vertical-align: -2px; }
.ct-sub { color: var(--text2); font-size: 13.5px; margin-top: 1px; }
.ct-ways { font-size: 13px; margin-top: 3px; }
.ct-ways a { color: var(--accent-text); text-decoration: none; }
.ct-note { color: var(--text3); font-size: 12.5px; margin-top: 4px; line-height: 1.4; }
.ct-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 7px; }
.ct-when { color: var(--text3); font-size: 11.5px; }

/* ── Контакты ── */
.c-search {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 0 12px;
}
.c-search .ic { width: 18px; height: 18px; color: var(--text3); flex: none; }
.c-search input { flex: 1; min-width: 0; border: 0; background: none; color: var(--text); font: inherit; font-size: 16px; padding: 12px 0; }
.c-search input:focus { outline: none; }
.c-search button { border: 0; background: none; color: var(--text3); padding: 4px; cursor: pointer; }
.c-filters { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 12px; -webkit-overflow-scrolling: touch; }
.c-filters::-webkit-scrollbar { display: none; }
.c-filters button {
  flex: none; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text2); font: inherit; font-size: 13.5px; cursor: pointer;
}
.c-filters button.on { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); font-weight: 700; }
.c-filters button i { font-style: normal; opacity: .55; margin-left: 3px; }
.c-quick { display: flex; gap: 8px; margin: 4px 0 6px; }
.c-quick a {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px; border-radius: 12px; background: var(--surface2); color: var(--text);
  text-decoration: none; font-size: 14px; font-weight: 600;
}
.c-quick .ic { width: 16px; height: 16px; }
.c-tasks { display: flex; flex-direction: column; gap: 7px; margin-bottom: 4px; }
.c-task { display: flex; align-items: center; gap: 6px; }
.c-task-open {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; text-align: left;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface2); color: var(--text); font: inherit; font-size: 14px; cursor: pointer;
}
.c-task-open .ic { width: 15px; height: 15px; flex: none; color: var(--text3); }
.c-task-open span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-task-open i { font-style: normal; color: var(--text3); font-size: 12px; flex: none; }
.c-none { color: var(--text3); font-size: 13.5px; padding: 2px 0 4px; }
.c-pick { width: 100%; padding: 11px 12px; border: 1px dashed var(--line); border-radius: 12px;
          background: none; color: var(--text2); font: inherit; font-size: 14px; }
.c-meta { color: var(--text3); font-size: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.ct { cursor: pointer; }
