:root {
  --bg: #f5f1ee;
  --card: #ffffff;
  --ink: #1d1a18;
  --muted: #8a817b;
  --line: #ece5e0;
  --accent: #e4572e;
  --accent-soft: #fde6de;
  --blue: #e3ecfb;  --blue-ink: #2f5cb8;
  --green: #e2f3e6; --green-ink: #2d7a45;
  --pink: #fbe3e6;  --pink-ink: #c03650;
  --yellow: #fbf0d9; --yellow-ink: #9a6a10;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(40, 20, 10, .04), 0 6px 20px rgba(40, 20, 10, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161412; --card: #201d1b; --ink: #f2ece8; --muted: #9b928c; --line: #312c29;
    --accent-soft: #3d2219;
    --blue: #1d2638; --blue-ink: #8fb0f0; --green: #1b2c21; --green-ink: #82cf97;
    --pink: #34191e; --pink-ink: #f08a9c; --yellow: #33291a; --yellow-ink: #e3b55e;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: Manrope, system-ui, sans-serif; font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

/* layout */
.topbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 14px; padding: 10px 20px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; white-space: nowrap; }
.logo i { width: 28px; height: 28px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center;
  font-style: normal; font-size: 11px; }
.nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { text-decoration: none; color: var(--muted); padding: 7px 13px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.nav a:hover { color: var(--ink); background: var(--card); }
.nav a.on { background: var(--ink); color: var(--bg); }
.who { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
main { max-width: 1280px; margin: 0 auto; padding: 22px 20px 80px; }

h1 { font-size: 28px; margin: 0 0 4px; letter-spacing: -.02em; }
h2 { font-size: 16px; margin: 0; }
.sub { color: var(--muted); margin: 0 0 20px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }
.dash { grid-template-columns: 1fr 320px; align-items: start; }
@media (max-width: 1000px) { .dash { grid-template-columns: 1fr; } .g3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 680px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3, .g2 { grid-template-columns: 1fr; }
  main { padding: 16px 16px 80px; } .topbar-in { padding: 10px 16px 6px; flex-wrap: wrap; row-gap: 8px; }
  .logo { flex: 1; } .nav { order: 3; flex-basis: 100%; margin: 0 -4px; } .who span { display: none; } h1 { font-size: 23px; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 8px; }
.stat { border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 30px; letter-spacing: -.03em; margin-top: 6px; }
.stat span { font-weight: 600; font-size: 13px; }
.s-blue { background: var(--blue); color: var(--blue-ink); } .s-green { background: var(--green); color: var(--green-ink); }
.s-pink { background: var(--pink); color: var(--pink-ink); } .s-yellow { background: var(--yellow); color: var(--yellow-ink); }

/* buttons & forms */
.btn { border: 1px solid var(--line); background: var(--card); padding: 8px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; }
.btn:hover { border-color: var(--muted); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; }
.icon-btn { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); cursor: pointer; display: grid; place-items: center; flex: none; }
.icon-btn:hover { border-color: var(--green-ink); color: var(--green-ink); }
.input, select.input, textarea.input { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); outline: none; }
.input:focus { border-color: var(--accent); }
label.f { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fgrid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .fgrid { grid-template-columns: 1fr; } }

/* tasks */
.tcard { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; gap: 10px; align-items: flex-start; }
.tcard .t { font-weight: 600; line-height: 1.35; cursor: pointer; }
.tcard .t:hover { color: var(--accent); }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; color: var(--muted); font-size: 12px; align-items: center; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--bg); color: var(--muted); }
.tag.red { background: var(--pink); color: var(--pink-ink); }
.tag.hi { background: var(--accent-soft); color: var(--accent); }
.tag.green { background: var(--green); color: var(--green-ink); }
.tag.blue { background: var(--blue); color: var(--blue-ink); }
.done .t { text-decoration: line-through; color: var(--muted); }
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
@media (max-width: 900px) { .board { grid-template-columns: 1fr; } }
.col { background: color-mix(in srgb, var(--card) 50%, var(--bg)); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-height: 120px; }
.col.drag { outline: 2px dashed var(--accent); }
.col h3 { margin: 2px 4px 12px; font-size: 14px; display: flex; justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.tcard[draggable=true] { cursor: grab; }

/* progress, habits */
.bar { height: 7px; border-radius: 99px; background: var(--bg); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.habit-row { display: grid; grid-template-columns: minmax(130px, 1fr) repeat(7, 38px) 60px; gap: 6px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.habit-row:last-child { border-bottom: 0; }
.cell { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-size: 11px; font-weight: 700; color: var(--muted); }
.cell.part { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.cell.full { background: var(--accent); color: #fff; border-color: transparent; }
.cell.today { outline: 2px solid var(--ink); outline-offset: 1px; }
.hscroll { overflow-x: auto; }
.mini-habit { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 12px; font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.plus { color: var(--green-ink); } .minus { color: var(--pink-ink); }
tr.total td { font-weight: 800; }
.tbl-wrap { overflow-x: auto; }

/* misc */
.empty { color: var(--muted); padding: 18px; text-align: center; border: 1px dashed var(--line); border-radius: 14px; }
.list-line { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list-line:last-child { border-bottom: 0; }
.dark-card { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.dark-card .muted { color: color-mix(in srgb, var(--bg) 60%, var(--ink)); }
.muted { color: var(--muted); }
.big { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--ink); color: var(--bg); }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(20, 12, 8, .35); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--card); border-radius: 22px; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; padding: 22px; }
.modal h2 { font-size: 19px; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; opacity: 0; transition: .2s; pointer-events: none; z-index: 60; }
#toast.on { opacity: 1; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.fab { position: fixed; right: 20px; bottom: 20px; width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: #fff; border: 0; font-size: 26px; cursor: pointer; box-shadow: 0 8px 24px rgba(228, 87, 46, .35); z-index: 20; }
