/* Hábitos · estilos propios */
.top-mid { margin: 0 auto; display: flex; align-items: center; gap: 4px; }
.top-mid kbd { margin: 0 1px; }
.topbar .top-actions { margin-left: 0; }
.wrap { max-width: 1100px; margin: 0 auto; display: grid; gap: 16px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 8px 2px 4px; }
.head h1 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -.025em; }
.head p { margin: 2px 0 0; }
.add { display: flex; gap: 6px; flex: 0 1 520px; }
.add .emoji { width: 62px; font-size: 16px; }
.add #name { flex: 1; }
.habits { display: grid; gap: 10px; }
.habit { display: grid; gap: 12px; padding: 14px 16px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; }
.h-top { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 14px; }
.big-check { display: grid; place-items: center; width: 48px; height: 48px; padding: 0; border: 2px dashed var(--border-2); border-radius: 14px; background: var(--panel); font-size: 22px; transition: transform .12s, background-color .15s, border-color .15s; }
.big-check:hover { border-color: var(--accent); }
.big-check:active { transform: scale(.92); }
.big-check span { filter: grayscale(1); opacity: .55; transition: filter .15s, opacity .15s; }
.big-check.on { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.big-check.on span { filter: none; opacity: 1; }
.h-name { display: flex; flex-direction: column; min-width: 0; }
.name-in { border: 0; padding: 2px 4px; margin-left: -4px; border-radius: 6px; background: none; font-size: 15px; font-weight: 600; letter-spacing: -.01em; outline: none; width: 100%; }
.name-in:hover, .name-in:focus { background: var(--sunken); }
.h-name small { color: var(--text-3); font-size: 11.5px; }
.h-stats { display: flex; gap: 6px; }
.h-stats div { display: flex; flex-direction: column; align-items: center; min-width: 58px; padding: 6px 8px; border-radius: 9px; background: var(--sunken); }
.h-stats b { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.h-stats span { font-size: 10.5px; color: var(--text-3); }
.h-act { display: flex; flex-direction: column; gap: 0; }
.h-act .up { transform: rotate(90deg); }
.h-act { flex-direction: row; }
.h-body { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: center; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.wd { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 0; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); }
.wd span { font-size: 10.5px; color: var(--text-3); text-transform: capitalize; }
.wd b { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.wd:hover:not(:disabled) { border-color: var(--accent-line); }
.wd.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.wd.on span { color: inherit; opacity: .8; }
.wd.today:not(.on) { border-color: var(--accent); }
.wd:disabled { opacity: .35; cursor: default; }
.grid12 { display: grid; grid-template-rows: repeat(7, 11px); grid-auto-flow: column; grid-auto-columns: 11px; gap: 3px; }
.cell { width: 11px; height: 11px; padding: 0; border: 0; border-radius: 3px; background: var(--sunken); box-shadow: inset 0 0 0 1px var(--border); }
.cell.on { background: var(--accent); box-shadow: none; }
.cell.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.cell.fut { opacity: .25; cursor: default; }
.cell:hover:not(:disabled) { box-shadow: 0 0 0 1.5px var(--accent); }

@media (max-width: 860px) {
  .top-mid { display: none; } .topbar .top-actions { margin-left: auto; }
  .h-top { grid-template-columns: auto minmax(0, 1fr) auto; }
  .h-stats { grid-column: 1 / -1; order: 3; }
  .h-body { grid-template-columns: minmax(0, 1fr); }
  .grid12 { overflow-x: auto; }
}

/* Pantallas táctiles: el historial de 12 semanas ocupa todo el ancho, con casillas que se pueden tocar */
:root[data-input="touch"] .grid12 { grid-template-rows: repeat(7, auto); grid-auto-columns: minmax(0, 1fr); gap: 4px; overflow: visible; }
:root[data-input="touch"] .cell { width: 100%; height: auto; aspect-ratio: 1; border-radius: 5px; }
:root[data-input="touch"] .h-act .icon-btn { width: 40px; height: 40px; }

/* Pantallas táctiles: renombrar sin que el móvil amplíe la página */
:root[data-input="touch"] .name-in { font-size: 16px; }

/* Móvil: estadísticas e historial plegables */
.h-more { margin-top: 12px; border-top: 1px solid var(--border); }
.h-more summary { display: flex; align-items: center; gap: 8px; min-height: 44px; list-style: none; cursor: pointer; font-size: 14px; font-weight: 500; -webkit-tap-highlight-color: transparent; }
.h-more summary::-webkit-details-marker { display: none; }
.h-more summary small { margin-left: auto; color: var(--text-3); font-size: 12.5px; font-weight: 400; }
.h-more summary::after { content: ""; width: 8px; height: 8px; margin: 0 4px 0 2px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(45deg) translateY(-2px); transition: transform .15s var(--ease); }
.h-more[open] summary::after { transform: rotate(-135deg) translate(-2px, 0); }
.h-more .h-stats { margin-bottom: 12px; }
.h-more .h-stats div { flex: 1; }
.h-more .grid12 { margin-bottom: 4px; }
