/* DUY.OS — giao diện trẻ trung, đơn giản */
:root {
  --bg: #f5f6fb; --card: #ffffff; --soft: #f0f1f7; --line: #e6e8f0;
  --ink: #171a2b; --ink2: #4b5068; --mute: #8b90a7;
  --brand: #6366f1; --brand-soft: #eef0ff; --danger: #ef4444; --ok: #10b981;
  --c-today: #6366f1; --c-cal: #6366f1;
  --c-reading: #f59e0b; --c-work: #3b82f6; --c-fitness: #10b981; --c-money: #14b8a6;
  --c-music: #ef4444; --c-talk: #ec4899; --c-philo: #8b5cf6; --c-free: #f97316; --c-journal: #84cc16;
  --r: 18px; --r-sm: 12px;
  --shadow: 0 1px 2px rgba(23,26,43,.04), 0 6px 20px rgba(23,26,43,.05);
  --side: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1120; --card: #181b2e; --soft: #20243a; --line: #2a2f4a;
    --ink: #eef0fb; --ink2: #b7bbd3; --mute: #7d82a0; --brand-soft: #262a4d;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
.boot { min-height: 100vh; display: grid; place-items: center; font-weight: 800; font-size: 28px; letter-spacing: -.03em; }
.boot span, .logo span { color: var(--c-free); }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 22px 14px;
  border-right: 1px solid var(--line); background: var(--card); display: flex; flex-direction: column; gap: 4px;
}
.logo { font-weight: 800; font-size: 22px; letter-spacing: -.03em; padding: 0 10px 14px; display: flex; align-items: baseline; gap: 8px; }
.logo b { font-weight: 800; }
.logo small { font-size: 11px; font-weight: 600; color: var(--mute); letter-spacing: 0; }
.searchbtn {
  display: flex; align-items: center; gap: 8px; margin: 0 4px 12px; padding: 9px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--soft); color: var(--mute); cursor: pointer; font-size: 14px; text-align: left;
}
.searchbtn kbd { margin-left: auto; font-size: 11px; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.navlabel { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--mute); padding: 14px 12px 6px; }
.navitem {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--r-sm);
  color: var(--ink2); font-weight: 500; font-size: 14.5px;
}
.navitem:hover { background: var(--soft); }
.navitem.on { background: var(--brand-soft); color: var(--ink); font-weight: 700; }
.navitem .ic { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; font-size: 15px; background: var(--soft); flex: none; }
.navitem.on .ic { background: var(--card); }
.sidebar .grow { flex: 1; }
.sidefoot { font-size: 12px; color: var(--mute); padding: 10px 12px 0; }

.main { min-width: 0; overflow-x: clip; padding: 28px clamp(16px, 4vw, 40px) 110px; max-width: 1100px; }
.tabbar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 18px 16px calc(96px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a, .tabbar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--mute);
    background: none; border: 0; padding: 4px 0; cursor: pointer; font-weight: 500;
  }
  .tabbar .ti { font-size: 20px; line-height: 1.2; }
  .tabbar .on { color: var(--brand); font-weight: 700; }
}

/* ---------- page header ---------- */
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.ph .kick { font-size: 13px; color: var(--mute); font-weight: 500; }
.ph h1 { font-size: clamp(24px, 3.4vw, 30px); letter-spacing: -.025em; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.ph .em { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-size: 22px; }
.ph .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- building blocks ---------- */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .g2, .g3 { grid-template-columns: 1fr; } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 16px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.card h2 .sub { font-weight: 500; color: var(--mute); font-size: 13px; }
.hero { color: #fff; border: 0; }
.hero .muted { color: rgba(255,255,255,.8); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row .grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--mute); font-size: 13px; }
.big { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; }
.mid { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp { height: 16px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line);
  background: var(--card); padding: 8px 14px; border-radius: 12px; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--soft); }
.btn.pri { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.pri:hover { filter: brightness(1.05); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 10px; }
.btn.danger { color: var(--danger); }
.btn.white { background: #fff; color: var(--ink); border-color: #fff; }
.btn.glass { background: rgba(255,255,255,.2); border-color: transparent; color: #fff; }
.icon-btn { border: 0; background: transparent; cursor: pointer; color: var(--mute); padding: 4px 6px; border-radius: 8px; font-size: 14px; }
.icon-btn:hover { background: var(--soft); color: var(--ink); }

.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--soft); color: var(--ink2); white-space: nowrap; }
.chip.on { background: var(--brand); color: #fff; }
button.chip { border: 0; cursor: pointer; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }

.bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; transition: width .3s; }
.hero .bar { background: rgba(255,255,255,.25); }
.hero .bar > i { background: #fff; }

/* checklist item */
.item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 14px; background: var(--soft);
  border: 1px solid transparent; min-width: 0;
}
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 600; font-size: 14.5px; }
.item.done .t { text-decoration: line-through; color: var(--mute); }
.check {
  width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--line); background: var(--card); flex: none;
  cursor: pointer; display: grid; place-items: center; color: #fff; font-size: 14px; padding: 0;
}
.check.on { border-color: transparent; }
.tag-app { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; font-size: 17px; flex: none; }

/* forms */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink2); }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); outline: none; min-width: 0;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea.input { resize: vertical; min-height: 84px; }
.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fgrid .full { grid-column: 1 / -1; }
.fgrid.formrow { grid-template-columns: var(--cols); }
@media (max-width: 520px) {
  .fgrid { grid-template-columns: 1fr; }
  .fgrid.formrow { grid-template-columns: 1fr 1fr; }
  .fgrid.formrow > :first-child { grid-column: 1 / -1; }
}

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { padding: 7px 14px; border-radius: 99px; font-weight: 600; font-size: 14px; color: var(--ink2); background: var(--card); border: 1px solid var(--line); }
.tabs a.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.empty { text-align: center; color: var(--mute); padding: 18px 8px; font-size: 14px; }

/* apps grid */
.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.appcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); transition: transform .15s; }
.appcard:hover { transform: translateY(-2px); }
.appcard .ai { width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; font-size: 24px; }
.appcard b { font-size: 15px; }
.appcard.soon { opacity: .55; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background:
  radial-gradient(1200px 500px at 10% -10%, #e0e7ff 0, transparent 60%),
  radial-gradient(900px 500px at 110% 110%, #ffedd5 0, transparent 55%), var(--bg); }
@media (prefers-color-scheme: dark) { .login { background: var(--bg); } }
.login .card { width: min(400px, 100%); padding: 30px 26px; }
.login .logo { font-size: 34px; padding: 0 0 4px; }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(15,17,32,.45); z-index: 50; display: grid; place-items: start center; padding: 8vh 16px 16px; overflow-y: auto; animation: fade .15s; }
.modal { background: var(--card); border-radius: 22px; width: min(520px, 100%); padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: pop .18s; }
.modal h3 { font-size: 18px; font-weight: 800; margin-bottom: 14px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }

/* search */
.search-box { width: min(620px, 100%); background: var(--card); border-radius: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.25); overflow: hidden; animation: pop .18s; }
.search-box input { width: 100%; border: 0; padding: 18px 20px; font-size: 17px; outline: none; background: transparent; border-bottom: 1px solid var(--line); }
.sres { max-height: 60vh; overflow-y: auto; padding: 8px; }
.sres a { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; }
.sres a:hover, .sres a.sel { background: var(--soft); }
.sres .grp { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--mute); padding: 10px 12px 4px; }

/* toasts & timer */
#toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 14px; font-weight: 600; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: pop .2s; max-width: 320px; }
.timer {
  position: fixed; z-index: 40; right: 20px; bottom: 20px; background: var(--ink); color: var(--bg); border-radius: 18px;
  padding: 12px 14px 12px 18px; display: flex; align-items: center; gap: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.timer .tt { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.timer .tl { font-size: 12px; opacity: .75; max-width: 160px; }
.timer button { background: rgba(255,255,255,.15); border: 0; color: inherit; border-radius: 10px; padding: 6px 10px; cursor: pointer; font-weight: 600; }
@media (max-width: 860px) { .timer { bottom: calc(84px + env(safe-area-inset-bottom)); right: 12px; left: 12px; } }

/* calendar */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week a { text-align: center; padding: 8px 0; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.week a small { display: block; font-size: 11px; color: var(--mute); font-weight: 600; }
.week a b { font-size: 17px; }
.week a.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.week a.on small { color: inherit; opacity: .7; }
.week a.today:not(.on) { border-color: var(--brand); }
.week .dots { display: flex; justify-content: center; gap: 2px; height: 6px; margin-top: 2px; }
.week .dots i { width: 5px; height: 5px; border-radius: 50%; }
.tl { display: flex; flex-direction: column; gap: 8px; }
.ev { display: grid; grid-template-columns: 56px 1fr; gap: 10px; align-items: stretch; }
.ev .time { font-size: 13px; font-weight: 700; color: var(--ink2); padding-top: 10px; font-variant-numeric: tabular-nums; }
.ev > * { min-width: 0; }
.ev .blk { border-radius: 14px; padding: 10px 12px; border-left: 4px solid; display: flex; align-items: center; gap: 10px; }
.ev.done .blk .t { text-decoration: line-through; opacity: .6; }
.nowline { display: grid; grid-template-columns: 56px 1fr; gap: 10px; align-items: center; color: var(--danger); font-size: 12px; font-weight: 700; }
.nowline i { height: 2px; background: var(--danger); border-radius: 2px; display: block; }

/* chat */
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 52vh; min-height: 220px; overflow-y: auto; padding: 4px 2px; }
.bub { max-width: 82%; padding: 10px 14px; border-radius: 18px; font-size: 14.5px; white-space: pre-wrap; }
.bub.me { margin-left: auto; color: #fff; border-bottom-right-radius: 6px; }
.bub.ai { background: var(--soft); border-bottom-left-radius: 6px; }
.bub.sys { margin: 0 auto; background: transparent; color: var(--mute); font-size: 13px; text-align: center; }
.coach { background: var(--brand-soft); border-radius: 14px; padding: 14px; white-space: pre-wrap; font-size: 14px; }

/* quote card */
.quote { font-size: 17px; line-height: 1.6; }
.deepcard { min-height: 150px; display: flex; flex-direction: column; justify-content: center; text-align: center; font-size: 19px; font-weight: 700; line-height: 1.45; padding: 28px 22px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl td, .tbl th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.tbl th { font-size: 12px; color: var(--mute); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.right { text-align: right !important; }
.note { background: var(--soft); border-radius: 12px; padding: 10px 12px; font-size: 13px; color: var(--ink2); }
.note.warn { background: #fff7ed; color: #9a3412; }
@media (prefers-color-scheme: dark) { .note.warn { background: #3a2412; color: #fdba74; } }
