/* Task Manager Mini App — visual language ported from the Claude design
   (design/Mini App.dc.html): Telegram-style theme tokens, dark/light, rounded
   sections, segmented controls, board, sheets. Status/priority/label colors are
   applied inline from /api/meta (theme-aware) so this file stays structural. */

:root,
[data-theme='light'] {
  --tg-bg: #ffffff; --tg-secbg: #eef0f6; --tg-section: #ffffff; --tg-header: #ffffff;
  --tg-text: #0b0d14; --tg-subtitle: #707b92; --tg-hint: #9aa2b4;
  --tg-accent: #173dc9; --tg-link: #173dc9; --tg-btn: linear-gradient(135deg, #173dc9, #0052fe); --tg-btn-text: #ffffff;
  --tg-destructive: #e53935; --tg-sep: rgba(11, 13, 20, .09); --tg-sec-header: #173dc9;
  --tg-skel: rgba(11, 13, 20, .07); --tg-fill: #f3f5fa; --tg-press: rgba(11, 13, 20, .04);
}
[data-theme='dark'] {
  --tg-bg: #0a0f1f; --tg-secbg: #070b16; --tg-section: #131b30; --tg-header: #0d1426;
  --tg-text: #eef1f8; --tg-subtitle: #8b96b1; --tg-hint: #5f6982;
  --tg-accent: #6f8dff; --tg-link: #6f8dff; --tg-btn: linear-gradient(135deg, #2a4be0, #0052fe); --tg-btn-text: #ffffff;
  --tg-destructive: #ff6159; --tg-sep: rgba(255, 255, 255, .08); --tg-sec-header: #7e98ff;
  --tg-skel: rgba(255, 255, 255, .06); --tg-fill: #0f1830; --tg-press: rgba(255, 255, 255, .05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  background: var(--tg-secbg); color: var(--tg-text);
  font: 15px/1.45 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#app { display: flex; flex-direction: column; height: 100vh; max-width: 540px; margin: 0 auto; background: var(--tg-bg); overflow: hidden; }

/* ── header ── */
.topbar {
  flex: 0 0 auto; height: 50px; display: flex; align-items: center; padding: 0 6px;
  background: var(--tg-header); border-bottom: .5px solid var(--tg-sep); position: relative; z-index: 20;
}
.topbar .side { width: 96px; display: flex; align-items: center; flex: 0 0 auto; }
.topbar .side.right { justify-content: flex-end; }
.topbar .title { flex: 1; text-align: center; color: var(--tg-text); font-size: 16px; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 0 4px; }
.iconbtn { background: none; border: none; color: var(--tg-link); cursor: pointer; padding: 8px; display: inline-flex; align-items: center; gap: 2px; font-family: inherit; font-size: 16px; }
.iconbtn.menu { font-size: 22px; line-height: 1; }

/* ── scroll body ── */
.scroll { flex: 1; overflow-y: auto; overflow-x: hidden; background: var(--tg-secbg); position: relative; -webkit-overflow-scrolling: touch; }
.scroll::-webkit-scrollbar { width: 0; height: 0; }
.pad { padding: 14px; }
.sec-header { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--tg-sec-header); font-weight: 600; }
.muted { color: var(--tg-subtitle); }
.center-empty { text-align: center; padding: 40px 24px; color: var(--tg-hint); font-size: 13px; }

/* ── project header strip + tabs ── */
.proj-strip { display: flex; align-items: center; gap: 11px; padding: 12px 14px 6px; }
.avatars { display: flex; }
.avatars .av { margin-left: -9px; border: 2px solid var(--tg-secbg); }
.proj-strip .name { color: var(--tg-text); font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-strip .sub { color: var(--tg-subtitle); font-size: 11.5px; margin-top: 1px; }

.tabs { display: flex; background: var(--tg-fill); border-radius: 11px; padding: 3px; gap: 2px; margin: 6px 14px 10px; }
.tabs button { flex: 1; border: none; cursor: pointer; font-family: inherit; font-size: 11px; font-weight: 500; padding: 7px 2px; border-radius: 8px; background: transparent; color: var(--tg-subtitle); }
.tabs button.active { font-weight: 600; background: var(--tg-section); color: var(--tg-text); box-shadow: 0 1px 3px rgba(0, 0, 13, .1); }

/* ── filters ── */
.filters { display: flex; gap: 8px; padding: 0 14px 10px; overflow-x: auto; }
.filters::-webkit-scrollbar { display: none; }
.chip-filter { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 13px; border-radius: 999px; border: .5px solid var(--tg-sep); background: var(--tg-section); color: var(--tg-text); font-family: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.chip-filter.active { border-color: transparent; background: var(--tg-accent); color: #fff; }
.chip-filter .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── avatars / pills ── */
.av { border-radius: 50%; color: #fff; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.av.s34 { width: 34px; height: 34px; font-size: 12px; }
.av.s30 { width: 30px; height: 30px; font-size: 11px; }
.av.s26 { width: 26px; height: 26px; font-size: 10px; }
.av.s24 { width: 24px; height: 24px; font-size: 9.5px; }
.av.s22 { width: 22px; height: 22px; font-size: 9.5px; }
.av.dashed { background: none; border: 1.4px dashed var(--tg-hint); color: var(--tg-hint); }
.pill { font-size: 10.5px; font-weight: 500; padding: 2px 7px; border-radius: 6px; }
.pill.round { border-radius: 999px; padding: 3px 9px; }
.pdot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }

/* ── generic section card / rows ── */
.card { background: var(--tg-section); border: .5px solid var(--tg-sep); border-radius: 14px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: none; border-bottom: .5px solid var(--tg-sep); padding: 12px 14px; cursor: pointer; font-family: inherit; color: var(--tg-text); }
.row:last-child { border-bottom: none; }
.row .grow { flex: 1; min-width: 0; }
.row .label { font-size: 13.5px; color: var(--tg-subtitle); }
.row .val { font-size: 13.5px; font-weight: 500; color: var(--tg-text); text-align: right; }
.chev { flex: 0 0 auto; color: var(--tg-hint); }
.ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── project list ── */
.proj-card { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--tg-section); border: .5px solid var(--tg-sep); border-radius: 14px; padding: 13px 14px; cursor: pointer; font-family: inherit; }
.proj-glyph { width: 46px; height: 46px; border-radius: 13px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; color: #fff; font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 18px; }
.badge { flex: 0 0 auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--tg-accent); color: #fff; font-size: 11.5px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.h1 { color: var(--tg-text); font-size: 24px; font-weight: 700; letter-spacing: -.01em; }

/* ── dashboard hero ── */
.hero { display: block; width: 100%; text-align: left; border: none; cursor: pointer; border-radius: 16px; padding: 16px; background: linear-gradient(135deg, #173dc9, #000d8b); box-shadow: 0 14px 30px rgba(23, 61, 201, .32); font-family: inherit; color: #fff; }
.hero .eyebrow { font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: rgba(255, 255, 255, .7); }
.hero .tag { font-size: 11px; font-weight: 500; color: #fff; background: rgba(255, 255, 255, .16); padding: 3px 9px; border-radius: 999px; }
.hero .htitle { font-size: 18px; font-weight: 600; margin-top: 10px; }
.hero .hgoal { color: rgba(255, 255, 255, .78); font-size: 12.5px; margin-top: 3px; }
.bar { margin-top: 14px; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .22); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: #fff; }
.hero .hmeta { display: flex; justify-content: space-between; margin-top: 7px; color: rgba(255, 255, 255, .82); font-size: 11.5px; }

.stats { display: flex; gap: 8px; margin-top: 14px; overflow-x: auto; }
.stats::-webkit-scrollbar { display: none; }
.stat { flex: 0 0 auto; min-width: 78px; background: var(--tg-section); border: .5px solid var(--tg-sep); border-radius: 12px; padding: 11px 13px; }
.stat .n { font-size: 22px; font-weight: 700; line-height: 1; }
.stat .l { font-size: 11px; color: var(--tg-subtitle); margin-top: 5px; white-space: nowrap; }

/* ── board ── */
.board { display: flex; gap: 11px; padding: 2px 14px 16px; overflow-x: auto; align-items: flex-start; }
.col { flex: 0 0 auto; width: 240px; border-radius: 14px; padding: 6px; }
.col-head { display: flex; align-items: center; gap: 7px; padding: 2px 2px 10px; }
.col-tasks { display: flex; flex-direction: column; gap: 8px; }
.tcard { background: var(--tg-section); border: .5px solid var(--tg-sep); border-radius: 11px; padding: 11px; cursor: pointer; }
.tcard .t { color: var(--tg-text); font-size: 13px; font-weight: 500; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tcard .meta { display: flex; align-items: center; gap: 7px; margin-top: 10px; }
.labels { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.col-empty { text-align: center; padding: 18px 8px; color: var(--tg-hint); font-size: 11.5px; border: 1px dashed var(--tg-sep); border-radius: 10px; }

/* ── list grouped ── */
.group { margin-bottom: 8px; }
.group-head { display: flex; align-items: center; gap: 8px; padding: 8px 16px 6px; }
.list-cell { display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; background: var(--tg-section); border: none; border-bottom: .5px solid var(--tg-sep); padding: 12px 16px; cursor: pointer; font-family: inherit; }

/* ── task detail ── */
.td-title { color: var(--tg-text); font-size: 21px; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; }
.status-btn { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-top: 16px; padding: 14px; border-radius: 13px; cursor: pointer; font-family: inherit; }
.desc-box { background: var(--tg-section); border: .5px solid var(--tg-sep); border-radius: 14px; padding: 14px; color: var(--tg-text); font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.comment { display: flex; gap: 9px; }
.comment .body .head { display: flex; align-items: baseline; gap: 7px; }
.comment .body .name { font-size: 13px; font-weight: 600; color: var(--tg-text); }
.comment .body .time { font-size: 11px; color: var(--tg-hint); }
.comment .body .text { font-size: 13.5px; color: var(--tg-text); line-height: 1.45; margin-top: 2px; }
.comment-box { display: flex; align-items: center; gap: 8px; background: var(--tg-section); border: .5px solid var(--tg-sep); border-radius: 999px; padding: 6px 6px 6px 14px; }
.comment-box input { flex: 1; border: none; background: none; outline: none; color: var(--tg-text); font-family: inherit; font-size: 13.5px; }
.send-btn { width: 34px; height: 34px; border-radius: 50%; border: none; background: var(--tg-btn); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.locked-note { display: flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--tg-hint); font-size: 11.5px; }

/* ── form ── */
.input, .textarea { width: 100%; background: var(--tg-section); border: .5px solid var(--tg-sep); border-radius: 13px; padding: 14px; color: var(--tg-text); font-family: inherit; outline: none; }
.input { font-size: 16px; font-weight: 500; }
.textarea { font-size: 14px; line-height: 1.5; resize: none; min-height: 96px; margin-top: 10px; }
.err-text { color: var(--tg-destructive); font-size: 12px; margin-top: 6px; padding-left: 4px; }
.seg { display: flex; background: var(--tg-fill); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px; border: none; cursor: pointer; font-family: inherit; font-size: 11.5px; font-weight: 500; padding: 8px 2px; border-radius: 8px; background: transparent; color: var(--tg-subtitle); }
.seg button.active { font-weight: 600; background: var(--tg-section); color: var(--tg-text); box-shadow: 0 1px 3px rgba(0, 0, 13, .1); }

/* ── main button ── */
.mainbtn-wrap { flex: 0 0 auto; padding: 9px 14px 18px; background: var(--tg-bg); border-top: .5px solid var(--tg-sep); }
.mainbtn { width: 100%; height: 50px; border: none; border-radius: 13px; background: var(--tg-btn); color: var(--tg-btn-text); font-family: inherit; font-weight: 600; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 9px; }
.mainbtn:disabled { cursor: default; }
.spinner { width: 17px; height: 17px; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── overlays ── */
.sheet-scrim { position: absolute; inset: 0; z-index: 70; background: rgba(0, 0, 8, .45); display: flex; flex-direction: column; justify-content: flex-end; animation: fade .2s ease; }
.sheet { background: var(--tg-bg); border-radius: 20px 20px 0 0; max-height: 78%; display: flex; flex-direction: column; animation: sheetup .26s cubic-bezier(.22, .61, .36, 1); }
.sheet .grab { width: 38px; height: 4px; border-radius: 999px; background: var(--tg-hint); opacity: .5; margin: 10px auto 4px; }
.sheet .stitle { padding: 6px 18px 10px; color: var(--tg-text); font-size: 17px; font-weight: 600; }
.sheet .opts { overflow-y: auto; padding: 4px 12px 18px; }
.opt { display: flex; align-items: center; gap: 11px; width: 100%; padding: 12px; border: none; background: none; border-radius: 12px; cursor: pointer; font-family: inherit; color: var(--tg-text); font-size: 14.5px; font-weight: 500; }
.opt.sel { background: var(--tg-press); }
.opt .grow { flex: 1; text-align: left; }

.dialog-scrim { position: absolute; inset: 0; z-index: 75; background: rgba(0, 0, 8, .5); display: flex; align-items: center; justify-content: center; padding: 30px; animation: fade .18s ease; }
.dialog { width: 100%; max-width: 380px; background: var(--tg-bg); border-radius: 18px; overflow: hidden; animation: pop .22s ease; }
.dialog .dtop { padding: 20px 18px 16px; text-align: center; }
.dialog .dtitle { color: var(--tg-text); font-size: 16px; font-weight: 600; }
.dialog .dbody { color: var(--tg-subtitle); font-size: 13px; margin-top: 7px; line-height: 1.45; }
.dialog .dacts { display: flex; border-top: .5px solid var(--tg-sep); }
.dialog .dacts button { flex: 1; padding: 14px; background: none; border: none; font-family: inherit; font-size: 15px; cursor: pointer; }
.dialog .dacts button.cancel { border-right: .5px solid var(--tg-sep); color: var(--tg-link); font-weight: 500; }

.toast { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 60; background: rgba(20, 24, 40, .94); color: #fff; font-size: 13px; font-weight: 500; padding: 10px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); animation: toast .25s ease; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.toast .ok { color: #5fc98a; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetup { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes pop { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 12px) scale(.96); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes shimmer { 0% { opacity: .5; } 50% { opacity: 1; } 100% { opacity: .5; } }
.skel { border-radius: 12px; background: var(--tg-skel); animation: shimmer 1.3s infinite; }

/* ── toggles (settings) ── */
.toggle { width: 46px; height: 28px; border-radius: 999px; border: none; cursor: pointer; background: var(--tg-hint); position: relative; transition: background .18s; flex: 0 0 auto; padding: 0; }
.toggle.on { background: var(--tg-accent); }
.toggle .knob { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .18s; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.toggle.on .knob { left: 21px; }
.len { border: none; cursor: pointer; font-family: inherit; font-size: 12.5px; font-weight: 500; padding: 7px 11px; border-radius: 9px; background: var(--tg-fill); color: var(--tg-text); }
.len.active { background: var(--tg-accent); color: #fff; font-weight: 600; }

.status-msg { color: var(--tg-hint); padding: 40px 16px; text-align: center; }
.status-msg.error { color: var(--tg-destructive); }
