/* 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-block; 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; }

@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; }
}
