:root{
  /* Dark theme – black/grey */
  --bg0:#050506;
  --bg1:#050607;
  --bg2:#101012;
  --card:rgba(18,18,18,.96);
  --card2:#151515;
  --text:#f5f5f5;
  --muted:#a0a0a0;
  --muted2:#777777;
  --line:#2a2a2a;
  --shadow: 0 16px 60px rgba(0,0,0,.55);
  --radius: 18px;
  --radius2: 14px;
  --primary:#f5f5f5;  /* primary accent in dark mode */
  --accent:#9b9b9b;   /* subtle grey accent */
  --gold:#d4d4d4;
  --danger:#E8697A;
}

/* Light theme overrides */
body[data-theme="light"]{
  --bg0:#f4f4f6;
  --bg1:#ffffff;
  --bg2:#e6e6ec;
  --card:#ffffff;
  --card2:#f7f7fb;
  --text:#141414;
  --muted:#707070;
  --muted2:#9b9b9b;
  --line:#dddddd;
  --shadow: 0 16px 40px rgba(0,0,0,.12);
  --primary:#111827;
  --accent:#2563eb;   /* tasteful blue for light mode */
  --gold:#f4c76a;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial,Helvetica,sans-serif;
  color:var(--text);
  background:
    radial-gradient(900px 520px at 18% -10%, rgba(255,255,255,.06), transparent 70%),
    radial-gradient(740px 520px at 110% 12%, rgba(155,155,155,.12), transparent 70%),
    radial-gradient(640px 420px at 40% 120%, rgba(90,90,90,.12), transparent 70%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
}

.container{
  width:min(1100px, calc(100% - 48px));
  margin:0 auto;
}

.topbar{
  position:sticky;
  top:0;
  z-index:20;
  backdrop-filter: blur(14px);
  background: rgba(5,5,5,.78);
  border-bottom:1px solid var(--line);
}
.topbar__inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:16px 0;
  gap:16px;
}

.brand{display:flex; align-items:center; gap:12px;}
.brand__logo{
  width:42px;height:42px;
  display:grid;place-items:center;
  border-radius:12px;
  background: linear-gradient(135deg, #f5f5f5, #9b9b9b);
  color:#141414;
  font-weight:800;
  letter-spacing:.5px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.brand__logoImg{
  width:26px;
  height:26px;
  display:block;
}
.brand__logo--link{
  text-decoration:none;
  width:42px;height:42px;
  display:grid;place-items:center;
  border-radius:12px;
  background: rgba(18,18,18,.8);
  border:1px solid var(--line);
  color: var(--text);
  box-shadow: none;
}
.brand__logo--link:hover{border-color: var(--accent)}
.brand__badge{
  width:34px;
  height:34px;
  display:grid;
  place-items:center;
  border-radius:10px;
  background: linear-gradient(135deg, #f5f5f5, #9b9b9b);
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
  flex:0 0 auto;
}
.brand__badgeImg{
  width:20px;
  height:20px;
  display:block;
}
.brand__name{font-weight:800; letter-spacing:.2px;}
.brand__tag{font-size:12px; color:var(--muted2); margin-top:2px}

.topbar__right{display:flex; align-items:center; gap:10px; flex-wrap:wrap;}
.today{
  padding:10px 12px;
  border:1px solid var(--line);
  background: rgba(18,18,18,.75);
  border-radius:14px;
}
.today__label{font-size:11px; color:var(--muted2)}
.today__value{font-size:13px; font-weight:700}

main{padding:26px 0 40px;}

.panel{
  border:1px solid var(--line);
  background: linear-gradient(180deg, var(--card), var(--card2));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding:18px 18px 16px;
  margin-bottom:16px;
}
.panel--tight{padding:16px;}
.panel__titleRow{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:12px;
  margin-bottom:14px;
  flex-wrap:wrap;
}
.panel__title{
  margin:0;
  font-size:16px;
  letter-spacing:.2px;
}
.panel__subtitle{
  color:var(--muted2);
  font-size:13px;
}

.addForm{
  display:flex;
  gap:12px;
  align-items:flex-end;
  flex-wrap:wrap;
}
.field{display:flex; flex-direction:column; gap:6px; min-width:200px;}
.field--grow{flex:1; min-width:260px}
.field__label{font-size:12px; color:var(--muted)}
.input{
  padding:12px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(18,18,18,.7);
  color: var(--text);
  outline:none;
}
.input::placeholder{color: rgba(160,160,160,.8)}
.input:focus{border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255,255,255,.06)}
.input--color{padding:9px 10px; height:44px; min-width:110px;}

.btn{
  border:1px solid var(--line);
  background: rgba(18,18,18,.7);
  color: var(--text);
  padding:12px 14px;
  border-radius: 14px;
  cursor:pointer;
  font-weight:700;
}
.btn:hover{border-color: var(--accent)}
.btn--primary{
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color:#111;
  box-shadow: 0 14px 35px rgba(0,0,0,.45);
}
.btn--primary:hover{filter:brightness(1.02)}
.btn--ghost{background: transparent}
.btn--sm{padding:9px 12px; border-radius: 12px; font-weight:700; font-size:12px;}

.fileBtn{display:inline-flex; align-items:center; gap:8px;}
.fileBtn__input{display:none}

.grid{
  display:grid;
  grid-template-columns: repeat(12, 1fr);
  gap:12px;
}

.card{
  grid-column: span 6;
  border:1px solid var(--line);
  background: linear-gradient(180deg, var(--card), var(--card2));
  border-radius: var(--radius);
  padding:14px 14px 14px;
  box-shadow: 0 14px 45px rgba(0,0,0,.7);
}
@media (max-width: 900px){
  .card{grid-column: span 12;}
  .field{min-width: 220px;}
}

.card__top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
}
.card__titleRow{display:flex; gap:10px; align-items:flex-start}
.dot{
  width:12px;height:12px;border-radius:999px;
  margin-top:6px;
  background: var(--primary);
  box-shadow: 0 0 0 6px rgba(255,255,255,.06);
}
.card__title{font-weight:800; letter-spacing:.2px}
.card__note{font-size:12px; color:var(--muted2); margin-top:2px; max-width:38ch}
.card__actions{display:flex; gap:8px; align-items:center}
.iconBtn{
  border:1px solid var(--line);
  background: rgba(18,18,18,.7);
  color: var(--muted);
  padding:8px 10px;
  border-radius: 12px;
  font-weight:800;
  font-size:12px;
  cursor:pointer;
}
.iconBtn:hover{color:var(--text); border-color: var(--accent)}
.iconBtn--danger:hover{border-color: rgba(232,105,122,.65); color:#f5e8e8}

.stats{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:10px;
  margin-top:12px;
}
.stat{
  border:1px solid var(--line);
  background: rgba(18,18,18,.7);
  border-radius: var(--radius2);
  padding:10px 10px;
}
.stat__label{font-size:11px; color:var(--muted2)}
.stat__value{margin-top:4px; font-weight:900; font-size:18px; letter-spacing:.2px}

.todayRow{
  margin-top:12px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.check{display:flex; align-items:center; gap:10px; cursor:pointer; user-select:none}
.check__input{display:none}
.check__box{
  width:22px;height:22px;border-radius:7px;
  border:1px solid var(--line);
  background: rgba(18,18,18,.7);
  position:relative;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}
.check__input:checked + .check__box{
  background: var(--habit-color, var(--accent));
  border-color: var(--habit-color, var(--accent));
}
.check__input:checked + .check__box:after{
  content:"";
  position:absolute;
  left:7px; top:4px;
  width:6px; height:11px;
  border: solid var(--habit-ink, #111);
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}
.check__text{font-weight:800; font-size:13px;}

.calendar{
  margin-top:12px;
  border:1px solid var(--line);
  background: rgba(18,18,18,.6);
  border-radius: var(--radius2);
  padding:10px 10px 10px;
}
.calendar__header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
}
.calendar__title{font-weight:900; font-size:12px; color:var(--muted)}
.calendar__legend{display:flex; gap:10px; color:var(--muted2); font-size:11px}
.legend{display:inline-flex; align-items:center; gap:6px}
.legend__swatch{width:10px;height:10px;border-radius:3px;border:1px solid var(--line)}
.legend__swatch--on{background: var(--habit-color, var(--accent)); border-color: var(--habit-color, var(--accent))}
.legend__swatch--off{background: rgba(18,18,18,.7)}

.calendar__grid{
  margin-top:10px;
  display:grid;
  grid-template-columns: repeat(14, 1fr);
  gap:6px;
}
.day{
  height:28px;
  border-radius:10px;
  border:1px solid var(--line);
  background: rgba(18,18,18,.7);
  position:relative;
  cursor:pointer;
  display:grid;
  place-items:center;
  color: rgba(200,200,200,.9);
  font-weight:900;
  font-size:11px;
}
.day:hover{border-color: var(--habit-color, var(--accent))}
.day:disabled{
  opacity:.45;
  cursor:not-allowed;
}
.day:disabled:hover{border-color: var(--line)}
.day--on{
  background: var(--habit-color, var(--accent));
  border-color: var(--habit-color, var(--accent));
  color: var(--habit-ink, #fff);
}
.day--today{
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.day__tip{
  position:absolute;
  left:50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  padding:6px 8px;
  border-radius: 10px;
  font-size:11px;
  color: var(--text);
  background: rgba(10,10,10,.96);
  border:1px solid var(--line);
  white-space:nowrap;
  box-shadow: 0 12px 30px rgba(0,0,0,.35);
  opacity:0;
  pointer-events:none;
  transition: opacity .12s ease;
}
.day:hover .day__tip{opacity:1}

.empty{
  padding:24px 10px 10px;
  text-align:center;
  color:var(--muted);
}
.empty__title{font-weight:900; color:var(--text)}
.empty__text{margin-top:6px; color:var(--muted2)}

.footer{padding: 16px 0 26px;}
.footer__inner{
  border-top:1px solid var(--line);
  padding-top:16px;
}
.footer__hint{color:var(--muted2); font-size:12px}

.modal::backdrop{background: rgba(0,0,0,.55)}
.modal{
  border:none;
  padding:0;
  background: transparent;
}
.modal__panel{
  width:min(520px, calc(100vw - 32px));
  border:1px solid var(--line);
  background: rgba(10,10,10,.96);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding:16px;
}
.modal__title{font-weight:900; margin-bottom:8px;}
.modal__body{color:var(--muted); font-size:13px; line-height:1.5}
.modal__actions{display:flex; justify-content:flex-end; margin-top:14px;}

/* Detail page tweaks */
.stats--big .stat__value{font-size:22px}
.todayRow--detail{margin-top:14px}

/* Hero (home) */
.hero{
  padding:22px 0 8px;
}
.hero__content{
  text-align:center;
  padding:32px 18px 16px;
}
.hero__logoWrap{
  width:88px;
  height:88px;
  margin:0 auto 18px;
  display:grid;
  place-items:center;
  border-radius:26px;
  background: linear-gradient(135deg, #f5f5f5, #9b9b9b);
  box-shadow: 0 20px 48px rgba(0,0,0,.38);
}
.hero__logo{
  width:50px;
  height:50px;
  display:block;
}
.hero__title{
  margin:0 0 8px;
  font-size:28px;
  letter-spacing:.4px;
}
.hero__subtitle{
  margin:0;
  font-size:14px;
  color:var(--muted2);
}
.hero__addBtn{
  margin-top:24px;
  width:64px;
  height:64px;
  border-radius:999px;
  border:none;
  background:var(--primary);
  color:#111;
  font-size:36px;
  font-weight:800;
  cursor:pointer;
  box-shadow:0 20px 45px rgba(0,0,0,.6);
  display:grid;
  place-items:center;
  text-decoration:none;
}
.hero__addBtn:hover{
  filter:brightness(1.05);
}

.homeAdd{
  display:flex;
  justify-content:center;
  padding:4px 0 22px;
}
.hero__menu{
  margin-top:18px;
  display:flex;
  justify-content:center;
}
.hero__menuItem{
  border-radius:999px;
  border:1px solid var(--line);
  padding:8px 16px;
  background:rgba(18,18,18,.9);
  color:var(--text);
  font-size:13px;
  cursor:pointer;
}

/* Weekday picker */
.weekdayPicker{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  margin-top:4px;
}
.weekdayPicker__day{
  min-width:32px;
  padding:6px 8px;
  border-radius:999px;
  border:1px solid var(--line);
  background:rgba(18,18,18,.9);
  color:var(--muted2);
  font-size:11px;
  cursor:pointer;
}
.weekdayPicker__day--active{
  background:var(--accent);
  color:#111;
  border-color:var(--accent);
}
.weekdayPicker__hint{
  margin-top:6px;
  font-size:11px;
  color:var(--muted2);
}

/* Habit status on detail page */
.habitStatus{
  display:flex;
  align-items:center;
  gap:12px;
  margin-bottom:10px;
}
.habitStatus__icon{
  width:32px;
  height:32px;
  border-radius:999px;
  display:grid;
  place-items:center;
  border:2px solid var(--line);
  color:var(--muted2);
  font-weight:800;
  font-size:18px;
}
.habitStatus__icon--on{
  border-color:var(--habit-color, var(--accent));
  background:var(--habit-color, var(--accent));
  color:var(--habit-ink, #111);
}
.habitStatus__label{
  font-size:13px;
  color:var(--muted2);
}

/* GitHub-style grid */
.gh{
  border:1px solid var(--line);
  background: rgba(10,10,10,.9);
  border-radius: var(--radius2);
  padding:12px;
}
.gh__header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
}
.gh__legend{
  display:flex;
  gap:10px;
  color:var(--muted2);
  font-size:11px;
}
.gh__hint{font-size:11px; color: var(--muted2)}
.gh__grid{
  margin-top:12px;
  display:grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 1fr);
  gap:6px;
  align-items:start;
}
.gh__cell{
  width:14px;
  height:14px;
  border-radius:4px;
  border:1px solid var(--line);
  background: rgba(18,18,18,.7);
  cursor:pointer;
  position:relative;
  padding:0;
}
.gh__cell:hover{border-color: var(--habit-color, var(--accent))}
.gh__cell:disabled{
  opacity:.45;
  cursor:not-allowed;
}
.gh__cell:disabled:hover{border-color: var(--line)}
.gh__cell--0{background: rgba(18,18,18,.7)}
.gh__cell--1{
  background: var(--habit-color, var(--accent));
  border-color: var(--habit-color, var(--accent));
  box-shadow: none;
}
.gh__cell--today{
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.gh__tip{
  position:absolute;
  left:50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  padding:6px 8px;
  border-radius: 10px;
  font-size:11px;
  color: var(--text);
  background: rgba(10,10,10,.96);
  border:1px solid var(--line);
  white-space:nowrap;
  box-shadow: 0 12px 30px rgba(0,0,0,.35);
  opacity:0;
  pointer-events:none;
  transition: opacity .12s ease;
}
.gh__cell:hover .gh__tip{opacity:1}
.gh__swatch--0{background: rgba(18,18,18,.7)}
.gh__swatch--1{background: var(--habit-color, var(--accent)); border-color: var(--habit-color, var(--accent))}
/* header “today” pill – light theme needs a lighter background so the value is readable */
body[data-theme="light"] .today {
  background: rgba(0, 0, 0, .05);
}

body[data-theme="light"] .today__value {
  /* make sure the date text is dark, some themes accidentally made it pale */
  color: var(--text);
}

body[data-theme="light"] .gh {
  background: rgba(255,255,255,.82);
}

body[data-theme="light"] .gh__legend,
body[data-theme="light"] .gh__hint {
  color: var(--muted);
}

body[data-theme="light"] .gh__swatch--0 {
  background: #d1d5db;
  border-color: #cbd5e1;
}

body[data-theme="light"] .gh__tip {
  background: #111827;
  color: #f9fafb;
  border-color: #111827;
}

/* big “+” button on the home page: use the accent colour in light mode and a
   contrasting text colour */
body[data-theme="light"] .hero__addBtn {
  background: var(--accent);
  color: #fff;
}

body[data-theme="light"] .brand__badge,
body[data-theme="light"] .hero__logoWrap {
  box-shadow: 0 12px 28px rgba(15,23,42,.12);
}

/* scrollable history grid */
.gh__grid {
  margin-top:12px;
  display:grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 1fr);
  gap:6px;
  align-items:start;

  /* new: allow the grid to overflow horizontally so older days are reachable */
  overflow-x: auto;
  max-width: 100%;
  padding-bottom: 4px;       /* give a little room for the scrollbar */
}

/* optional scrollbar styling */
.gh__grid::-webkit-scrollbar {
  height:8px;
}
.gh__grid::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius:4px;
}

/* checked cells: light for dark-theme, dark/colourful for light-theme */
.day--on {
  background: var(--habit-color, var(--accent));
  border-color: var(--habit-color, var(--accent));
  color: var(--habit-ink, #fff);
}

body[data-theme="light"] .day--on {
  background: var(--habit-color, var(--accent));
  color: var(--habit-ink, #fff);
}

.gh__cell--1 {
  background: var(--habit-color, var(--accent));
  border-color: var(--habit-color, var(--accent));
  box-shadow: none;
}

body[data-theme="light"] .gh__cell--1 {
  background: var(--habit-color, var(--accent));
  border-color: var(--habit-color, var(--accent));
  box-shadow: none;
}
