/* daily-forge: one small stylesheet, light and dark, desktop first but responsive. */
:root {
  --bg: #f6f5f2; --surface: #ffffff; --text: #1d1d1b; --muted: #6b6a66; --line: #e3e1dc;
  --accent: #c2410c; --accent-text: #ffffff; --done: #16a34a; --partial: #f59e0b; --missed: #e5e7eb;
  --slip: #dc2626; --danger: #b91c1c; --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 1px 8px rgba(0,0,0,.04);
  --c: #16a34a;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #161615; --surface: #20201e; --text: #ecebe7; --muted: #9b9a95; --line: #34332f;
    --accent: #f97316; --accent-text: #161615; --missed: #2e2d2a; --shadow: none; }
}
.c-green { --c: #16a34a; } .c-blue { --c: #2563eb; } .c-purple { --c: #9333ea; }
.c-orange { --c: #ea580c; } .c-red { --c: #dc2626; } .c-teal { --c: #0d9488; }

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: inherit; }
h1 { font-size: 1.6rem; margin: .2rem 0 .6rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .7rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; }

.topbar { display: flex; align-items: center; gap: 1.5rem; padding: .7rem 1.5rem; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; text-decoration: none; font-size: 1.1rem; }
.brand span { color: var(--accent); }
.topbar nav { display: flex; gap: .3rem; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; padding: .35rem .7rem; border-radius: 8px; color: var(--muted); }
.topbar nav a:hover { background: var(--bg); color: var(--text); }
.topbar nav a.active { background: var(--bg); color: var(--text); font-weight: 600; }
.tools { margin-left: auto; display: flex; gap: .8rem; align-items: center; }
.lang { display: flex; gap: 0; }
.lang button { border-radius: 0; padding: .2rem .5rem; font-size: .75rem; }
.lang button:first-of-type { border-radius: 6px 0 0 6px; } .lang button:last-of-type { border-radius: 0 6px 6px 0; }
.lang button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.logout { color: var(--muted); font-size: .9rem; }

main { max-width: 1040px; margin: 0 auto; padding: 1.5rem; }
main.narrow { max-width: 460px; }
footer { text-align: center; color: var(--muted); font-size: .75rem; padding: 2rem 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow); margin-bottom: 1.2rem; }
.card.narrow { max-width: 460px; margin: 1rem auto; }
.card.empty { text-align: center; padding: 2.5rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.grid2 > .card { margin-bottom: 0; }
.grid2 + * { margin-top: 1.2rem; }
.row { display: flex; gap: .8rem; align-items: center; margin-top: .6rem; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

button, .button { font: inherit; font-size: .9rem; cursor: pointer; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); padding: .45rem .9rem; border-radius: 8px; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: .3rem; line-height: 1.2; }
button:hover, .button:hover { border-color: var(--muted); }
button:disabled { opacity: .4; cursor: default; }
button.primary, .button.primary, .allauth button[type=submit] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.small, .button.small { padding: .25rem .55rem; font-size: .8rem; }
button.danger, .button.danger { color: var(--danger); }
.danger-link { color: var(--danger); font-size: .85rem; }

input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], select, textarea {
  font: inherit; width: 100%; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); }
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { font-weight: 600; font-size: .9rem; display: block; margin-bottom: .25rem; }
.field { margin-bottom: 1rem; border: 0; padding: 0; }
.field legend { font-weight: 600; font-size: .9rem; margin-bottom: .3rem; padding: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.field ul, .field > div { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .4rem .9rem; }
.field ul li label, .field > div > div label { font-weight: 400; display: inline-flex; align-items: center; gap: .35rem; }
.colors label { text-transform: capitalize; }
.help { color: var(--muted); font-size: .8rem; display: block; margin-top: .2rem; }
.errorlist { color: var(--danger); list-style: none; padding: 0; margin: .3rem 0; font-size: .85rem; }
[hidden] { display: none !important; }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { background: var(--surface); border-left: 4px solid var(--done); padding: .6rem .9rem; border-radius: 6px; }
.messages li.error { border-color: var(--danger); }

/* Today */
.dayhead { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.dayhead h1 { margin: 0; text-transform: capitalize; }
.dayhead p { margin: 0; }
.navbtn { font-size: 1.5rem; text-decoration: none; width: 2.2rem; height: 2.2rem; display: inline-grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--line); background: var(--surface); line-height: 1; }
.navbtn.disabled { opacity: .3; }
.habits { list-style: none; padding: 0; margin: 0 0 1.2rem; display: grid; gap: .5rem; }
.habit { display: grid; grid-template-columns: 7.5rem 1fr auto auto; align-items: center; gap: 1rem;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: var(--radius);
  padding: .6rem .9rem; box-shadow: var(--shadow); }
.habit .control form { display: flex; align-items: center; gap: .3rem; margin: 0; }
.tick { width: 2.4rem; height: 2.4rem; border-radius: 50%; font-size: 1.2rem; color: transparent; border: 2px solid var(--line); padding: 0; }
.tick:hover { border-color: var(--c); color: var(--c); }
.tick.on { background: var(--c); border-color: var(--c); color: #fff; }
.counter input { width: 3.6rem; text-align: center; padding: .3rem; }
.slip { font-size: .85rem; }
.state-slip .slip { background: var(--slip); color: #fff; border-color: var(--slip); }
.habit .name { font-weight: 600; text-decoration: none; }
.habit .name:hover { text-decoration: underline; }
.habit .meta { display: block; color: var(--muted); font-size: .85rem; }
.habit.state-done .name::after { content: " ✓"; color: var(--c); }
.streak { text-align: right; white-space: nowrap; }
.streak small { display: block; color: var(--muted); font-size: .75rem; }
.hnote summary { cursor: pointer; list-style: none; color: var(--muted); padding: .2rem .4rem; }
.hnote summary::-webkit-details-marker { display: none; }
.hnote[open] { grid-column: 1 / -1; display: flex; gap: .5rem; align-items: center; }
.hnote[open] form { flex: 1; }
.resting { margin-bottom: 1.2rem; } .resting summary { cursor: pointer; color: var(--muted); margin-bottom: .5rem; }
.resting .habit { opacity: .75; }
.daynote textarea { resize: vertical; }
.saved { color: var(--done); font-size: .85rem; }

/* Lists */
.list { list-style: none; padding: .3rem 1.2rem; }
.list li { display: flex; align-items: center; gap: .8rem; padding: .6rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.list .name { font-weight: 600; }
.list .actions { margin-left: auto; display: flex; gap: .3rem; }
.list .actions form { margin: 0; }
.archived { opacity: .8; }
.dot { width: .7rem; height: .7rem; border-radius: 50%; background: var(--c); display: inline-block; margin-right: .4rem; }
.badge { font-size: .7rem; padding: .1rem .4rem; border-radius: 4px; background: var(--line); vertical-align: middle; }

/* Detail */
.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: .8rem; margin: 1rem 0 1.2rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; box-shadow: var(--shadow); }
.tile .label { display: block; color: var(--muted); font-size: .78rem; }
.tile strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.tile .unit { color: var(--muted); font-size: .8rem; margin-left: .2rem; }
.cardhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.cardhead h2 { margin: 0; text-transform: capitalize; }
.month { width: 100%; border-collapse: separate; border-spacing: 4px; table-layout: fixed; }
.month th { font-size: .75rem; color: var(--muted); font-weight: 500; }
.month td { height: 2.4rem; text-align: center; border-radius: 6px; font-size: .85rem; }
.month td a { text-decoration: none; display: block; line-height: 2.4rem; }
.s-done { background: var(--c); color: #fff; } span.s-done { background: none; color: var(--c); }
.s-partial { background: color-mix(in srgb, var(--c) 35%, transparent); } span.s-partial { background: none; color: color-mix(in srgb, var(--c) 45%, var(--bg)); }
.s-missed { background: var(--missed); } span.s-missed { background: none; color: var(--missed); }
.s-slip { background: var(--slip); color: #fff; } span.s-slip { background: none; color: var(--slip); }
.s-open { outline: 2px dashed var(--c); outline-offset: -3px; }
.s-rest, .s-before { color: var(--muted); }
.s-future { color: var(--line); }
.legend { font-size: .8rem; color: var(--muted); margin: .5rem 0 0; }
.notes { list-style: none; padding: 0; margin: 0; } .notes li { padding: .3rem 0; } .notes a { color: var(--muted); margin-right: .5rem; }

/* Charts (inline SVG built from habits.views._bars) */
.bars { width: 100%; height: 110px; display: block; }
.bars .bar { fill: var(--c); } .bars .bar:hover { opacity: .75; }
.bars .axis { stroke: var(--line); stroke-width: .5; }
.bar-labels { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); margin-bottom: 1rem; }
.stats { width: 100%; border-collapse: collapse; }
.stats th, .stats td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.stats th { font-size: .8rem; color: var(--muted); font-weight: 500; }
.exports { list-style: none; padding: 0; } .exports li { margin: .7rem 0; } .exports .button { min-width: 4.5rem; text-align: center; margin-right: .6rem; }
.links { padding-left: 1.1rem; } .links li { margin: .4rem 0; }

/* allauth pages */
.allauth h1 { text-align: center; }
.allauth form p { margin: 0 0 .9rem; }
.allauth button { width: 100%; margin-top: .3rem; }
.allauth hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }
.allauth section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.allauth section ul { list-style: none; padding: 0; display: flex; gap: .5rem; flex-wrap: wrap; }
.allauth section ul button, .allauth section ul a { width: auto; }
.allauth input[type=checkbox] { width: auto; }
.allauth p label[for] { display: inline; }
.allauth code, .allauth pre { background: var(--bg); padding: .3rem .5rem; border-radius: 6px; display: inline-block; }
.allauth img { background: #fff; padding: .5rem; border-radius: 8px; }

/* Today: habits and tasks side by side */
.today-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; margin-bottom: 1.2rem; }
.col-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 .6rem; }
.col-sub { font-size: .9rem; color: var(--muted); margin: 1rem 0 .5rem; }
.today-grid .habit { grid-template-columns: 6.5rem 1fr auto auto; }
.backlog summary { cursor: pointer; color: var(--muted); margin: .4rem 0 .5rem; }

/* Tasks */
.quickadd { display: flex; gap: .5rem; }
.quickadd input { flex: 1; }
.hint { color: var(--muted); font-size: .75rem; margin: .35rem 0 .8rem; }
.tasks { list-style: none; padding: .2rem .4rem; margin: 0 0 1rem; }
.task { display: flex; align-items: center; gap: .7rem; padding: .5rem .5rem; border-bottom: 1px solid var(--line); border-radius: 6px; outline: none; }
.task:last-child { border-bottom: 0; }
.task.selected { background: color-mix(in srgb, var(--accent) 10%, transparent); box-shadow: inset 3px 0 0 var(--accent); }
.task form { margin: 0; }
.task .tinfo { flex: 1; min-width: 0; }
.task .ttitle { text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; }
.task .ttitle:hover { text-decoration: underline; }
.task.done .ttitle { text-decoration: line-through; color: var(--muted); }
.task.prio-1 .ttitle { font-weight: 600; }
.tmeta { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .15rem; }
.tmeta:empty { display: none; }
.pill { font-size: .72rem; padding: .05rem .4rem; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.pill.high { color: #fff; background: var(--danger); border-color: var(--danger); }
.pill.low { opacity: .7; }
.pill.due.late { color: var(--danger); border-color: var(--danger); }
.pill.carried { color: var(--partial); border-color: var(--partial); }
.check { width: 1.6rem; height: 1.6rem; border-radius: 6px; padding: 0; color: transparent; border: 2px solid var(--line); font-size: .9rem; }
.check:hover { border-color: var(--done); color: var(--done); }
.check.on { background: var(--done); border-color: var(--done); color: #fff; }
.prio-1 .check { border-color: var(--danger); }
.task button.on { border-color: var(--accent); color: var(--accent); }
.empty-row { padding: .8rem .5rem; }
.done-list .task { opacity: .75; }
.tasks-layout { display: grid; grid-template-columns: 14rem 1fr; gap: 1.2rem; align-items: start; }
.listnav { display: flex; flex-direction: column; gap: .15rem; padding: .7rem; }
.listnav a { text-decoration: none; padding: .35rem .6rem; border-radius: 6px; color: var(--muted); display: flex; justify-content: space-between; }
.listnav a:hover, .listnav a.active { background: var(--bg); color: var(--text); }
.listnav hr { border: 0; border-top: 1px solid var(--line); margin: .5rem 0; width: 100%; }
.search input { width: 16rem; }
.checklist { list-style: none; padding: 0; margin: 0 0 .6rem; }
.checklist li form { display: flex; align-items: center; gap: .5rem; padding: .25rem 0; }
.checklist li span { flex: 1; }
.checklist li.done span { text-decoration: line-through; color: var(--muted); }
button.ghost { border-color: transparent; background: none; color: var(--muted); }
.inline-check { display: flex; align-items: center; gap: .5rem; }
.inline-check label { margin: 0; }
.inline-check input { width: auto; }
.row.grow { flex: 1; margin: 0; }
.row.grow input { max-width: 18rem; }
dialog.card { max-width: 30rem; border: 1px solid var(--line); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.35); }
.keys td { padding: .3rem .6rem .3rem 0; }
kbd { font: .8rem ui-monospace, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: .05rem .35rem; background: var(--bg); }

@media (max-width: 900px) {
  .today-grid, .tasks-layout { grid-template-columns: 1fr; }
  .listnav { flex-direction: row; flex-wrap: wrap; }
  .listnav hr { display: none; }
  .search input { width: 100%; }
  .hint { display: none; }
}

@media (max-width: 760px) {
  main { padding: 1rem; }
  .topbar { padding: .6rem 1rem; gap: .6rem; }
  .grid2, .field-row { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .habit { grid-template-columns: auto 1fr auto; gap: .6rem; }
  .habit .hnote:not([open]) { grid-column: auto; }
  .habit .control { grid-row: span 1; }
}

/* ---------------------------------------------------------------------------------------------------------------
   Touch and iPhone (home-screen app). Phones get an iPhone-style layout: an orange top bar under the status bar,
   a bottom tab bar, safe-area padding for the notch and the home indicator, 16px inputs (no zoom on focus) and
   44px tap targets. Hover effects only where a real pointer can hover.
   --------------------------------------------------------------------------------------------------------------- */
html { -webkit-text-size-adjust: 100%; }
a, button, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
input[type=search] { font: inherit; width: 100%; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); -webkit-appearance: none; appearance: none; }
.backbtn { display: inline-flex; align-items: center; gap: .1rem; text-decoration: none; color: var(--muted); font-size: .9rem; }
.backbtn svg { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.tabbar { display: none; }
@media (hover: none) {
  .tick:hover { border-color: var(--line); color: transparent; }
  .tick.on:hover { border-color: var(--c); color: #fff; }
  .check:hover { border-color: var(--line); color: transparent; }
  .check.on:hover { border-color: var(--done); color: #fff; }
  .prio-1 .check:hover { border-color: var(--danger); }
  button:hover, .button:hover { border-color: var(--line); }
  .topbar nav a:hover, .listnav a:hover { background: none; }
}

@media (max-width: 760px) {
  body { font-size: 16px; }
  input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=search],
  select, textarea { font-size: 16px; }

  /* Top bar under the status bar */
  .topbar { background: var(--accent); color: #fff; border-bottom: 0; gap: .4rem; flex-wrap: nowrap; min-height: 3rem;
    padding: calc(env(safe-area-inset-top) + .55rem) max(1rem, env(safe-area-inset-right)) .6rem max(1rem, env(safe-area-inset-left)); }
  .topbar .brand { color: #fff; font-size: 1.05rem; }
  .topbar .brand span { color: #ffd8bf; }
  .backbtn { color: #fff; font-size: 1rem; min-height: 44px; margin-left: -.4rem; padding-right: .4rem; }
  .backbtn + .brand { display: none; }
  .signed-in .mainnav, .signed-in .tools { display: none; }
  .tools .lang button { border-color: rgba(255,255,255,.5); background: transparent; color: #fff; }
  .tools .lang button.on { background: #fff; color: var(--accent); }

  /* Bottom tab bar above the home indicator */
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    background: color-mix(in srgb, var(--surface) 96%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    border-top: 1px solid var(--line); padding: .3rem max(.3rem, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + .3rem) max(.3rem, env(safe-area-inset-left)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: .1rem; text-decoration: none; color: var(--muted);
    font-size: .68rem; min-height: 44px; justify-content: center; }
  .tabbar svg { width: 1.55rem; height: 1.55rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar a.active { color: var(--accent); }
  .tabbar a.active svg { stroke-width: 2.2; }
  .signed-in main { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
  .signed-in footer { display: none; }
  main { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }

  /* Headings and page heads */
  h1 { font-size: 1.45rem; }
  .pagehead { flex-wrap: wrap; }
  .pagehead .search, .pagehead .search input { width: 100%; }
  .pagehead .search { margin-bottom: .8rem; }
  .dayhead { gap: .7rem; }
  .dayhead .button.small { display: none; }
  .navbtn { width: 2.75rem; height: 2.75rem; flex: none; }

  /* Habits on Today: control | name | streak | note, with a compact counter */
  .habit, .today-grid .habit { grid-template-columns: auto minmax(0, 1fr) auto auto; gap: .6rem; padding: .55rem .7rem; }
  .tick { width: 2.75rem; height: 2.75rem; }
  .counter button[value=dec] { display: none; }
  .counter input { width: 3rem; padding: .45rem .2rem; }
  .counter button { min-width: 2.75rem; min-height: 2.75rem; font-size: 1.1rem; }
  .slip { min-height: 2.75rem; }
  .streak strong { font-size: 1rem; }
  .streak small { font-size: .7rem; }
  .hnote summary { min-width: 2rem; min-height: 2.75rem; display: grid; place-items: center; }

  /* Tasks: 44px checkboxes, list chips scroll sideways */
  .task { gap: .55rem; padding: .45rem .3rem; }
  .check { width: 1.9rem; height: 1.9rem; margin: .45rem; }
  .task .js-today button { min-height: 2.5rem; }
  .listnav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: .5rem; }
  .listnav::-webkit-scrollbar { display: none; }
  .listnav a { white-space: nowrap; flex: none; }
  .quickadd button { min-height: 44px; }
  .quickadd input { min-height: 44px; }

  /* Habit page: two tiles per row */
  .tiles { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
  .tile strong { font-size: 1.35rem; }
  .month td { height: 2.6rem; }

  /* Forms and buttons */
  button, .button { min-height: 44px; }
  button.small, .button.small, .lang button { min-height: 36px; }
  .field ul label, .field > div > div label { min-height: 36px; }
  input[type=radio], input[type=checkbox] { width: 1.25rem; height: 1.25rem; }
  dialog.card { width: calc(100% - 2rem); }
}
