@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('../assets/fonts/inter-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('../assets/fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;
  --bg: #262624;
  --bar: #1f1e1d;
  --card: #30302e;
  --card-2: #3a3936;
  --line: #43423e;
  --ink: #f2f1ec;
  --muted: #bdbbb3;
  --accent: #cc4a41;
  --accent-text: #ee7d74;
  --accent-soft: rgba(204, 74, 65, .26);
  --accent-strong: #b23a32;
  --danger: #ee7d74;
}

* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  font: 16px/1.4 'Inter Variable', Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  padding-bottom: calc(168px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.app { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); font-size: .92rem; }

/* Barra superior */
.topbar {
  position: sticky; top: 0; z-index: 5;
  background: var(--bar);
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.35rem; font-weight: 700; padding: 14px 0 10px; }
.controls { display: flex; gap: 10px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.controls::-webkit-scrollbar { display: none; }
.ranges { display: flex; gap: 10px; }
body[data-view="add"] .controls { display: none; }
body[data-view="add"] .topbar h1 { padding-bottom: 14px; }
body:not([data-view="progress"]) .ranges { display: none; }

.pill {
  border: 2px solid var(--line); background: var(--card); border-radius: 14px;
  padding: 9px 16px; font-weight: 500; white-space: nowrap; cursor: pointer; color: var(--muted);
}
#filter-btn { color: var(--ink); }
.pill[aria-pressed="true"] { border-color: var(--accent); color: var(--accent-text); }

.view { padding-top: 16px; }

/* Progreso */
.period { font-size: 1.45rem; font-weight: 700; margin-bottom: 14px; }
.stats { display: flex; gap: 30px; margin-bottom: 14px; }
.stats dt { color: var(--muted); font-size: .9rem; }
.stats dd { font-size: 1.6rem; font-weight: 700; margin: 0; }
.chart { width: 100%; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart-svg { display: block; width: 100%; height: auto; }
.grid { stroke: #55534e; stroke-width: 1; }
.ylab, .xlab { fill: var(--muted); font-size: 13px; }
.xlab { text-anchor: middle; }
.xlab.first { text-anchor: start; }
.area { fill: var(--accent-soft); }
.line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.pt { fill: var(--bg); stroke: var(--accent); stroke-width: 2.5; }
.cursor { stroke: var(--accent); stroke-width: 2; }
.dot-sel { fill: var(--accent); stroke: var(--bg); stroke-width: 2; }

.section { font-size: 1.05rem; margin: 22px 0 8px; }
.list { list-style: none; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list .grow { flex: 1; min-width: 0; }
.list .sub { color: var(--muted); font-size: .85rem; }
.list .num { font-weight: 700; text-align: right; white-space: nowrap; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; display: inline-block; }

/* Actividades */
.day { color: var(--muted); font-size: .85rem; font-weight: 600; margin: 18px 0 8px; text-transform: capitalize; }
.act {
  display: flex; gap: 12px; padding: 14px; margin-bottom: 10px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 14px; background: var(--card);
}
.act:active { background: var(--card-2); }
.act .dot { margin-top: 6px; }
.act-main { flex: 1; min-width: 0; }
.act-title { font-weight: 600; }
.act-meta { color: var(--muted); font-size: .85rem; }
.act-sum { margin-top: 6px; font-size: .92rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.act-hours { font-weight: 700; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 48px 0; }

/* Añadir */
/* Bola del agente: flotante y común a todas las pantallas */
.orb {
  border: 0; cursor: pointer;
  background: radial-gradient(circle at 32% 28%, #ff7a6e 0%, #e5352b 50%, #8f1f19 100%);
  box-shadow: 0 8px 28px rgba(229, 53, 43, .38);
}
.orb-fab {
  position: fixed; z-index: 6; right: 18px; margin: 0; width: 64px; height: 64px; border-radius: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom) + 18px);
  box-shadow: 0 6px 20px rgba(229, 53, 43, .4), 0 0 0 4px rgba(38, 38, 36, .85);
}
.orb.thinking { animation: blob 3.8s linear infinite, glow 2.4s ease-in-out infinite; }
@keyframes blob {
  0%   { border-radius: 50% 50% 50% 50% / 50% 50% 50% 50%; transform: rotate(0deg) scale(1, 1); }
  20%  { border-radius: 58% 42% 52% 48% / 46% 58% 42% 54%; transform: rotate(72deg) scale(1.07, .95); }
  40%  { border-radius: 43% 57% 62% 38% / 57% 42% 58% 43%; transform: rotate(144deg) scale(.95, 1.08); }
  60%  { border-radius: 55% 45% 40% 60% / 40% 61% 46% 54%; transform: rotate(216deg) scale(1.08, .96); }
  80%  { border-radius: 40% 60% 55% 45% / 61% 44% 56% 39%; transform: rotate(288deg) scale(.96, 1.06); }
  100% { border-radius: 50% 50% 50% 50% / 50% 50% 50% 50%; transform: rotate(360deg) scale(1, 1); }
}
@keyframes glow {
  0%, 100% { box-shadow: 0 8px 28px rgba(229, 53, 43, .38), 0 0 0 0 rgba(229, 53, 43, .25); }
  50% { box-shadow: 0 8px 34px rgba(229, 53, 43, .6), 0 0 0 14px rgba(229, 53, 43, 0); }
}
@media (prefers-reduced-motion: reduce) { .orb.thinking { animation: glow 2.4s ease-in-out infinite; } }

.card { background: var(--card); border-radius: 16px; padding: 16px; margin-bottom: 16px; }
.card h3 { margin-bottom: 12px; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 12px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink);
}
input:focus-visible, select:focus-visible, textarea:focus-visible,
button:focus-visible, .act:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
textarea { resize: vertical; }
.row { display: flex; gap: 12px; }
.row > label { flex: 1; }
.quick { display: flex; gap: 8px; margin-bottom: 14px; }
.quick .pill { padding: 6px 14px; border-width: 1px; }
.actions { gap: 10px; flex-wrap: wrap; }

.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700; cursor: pointer; }
.btn.primary { background: var(--accent-strong); color: #fff; }
.btn.ghost { background: var(--card); border: 1px solid var(--line); }
.btn.danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
#more-btn { display: block; margin: 8px auto 0; }

.swatches {
  display: flex; gap: 12px; margin: 0 -16px 14px; padding: 6px 44px 6px 16px;
  overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
}
.swatches::-webkit-scrollbar { display: none; }
.swatch { margin: 0; flex: none; scroll-snap-align: start; }
.swatch input { position: absolute; opacity: 0; width: 0; height: 0; }
.swatch span { display: block; width: 32px; height: 32px; border-radius: 50%; background: var(--c); border: 3px solid var(--card); cursor: pointer; }
.swatch input:checked + span { outline: 2px solid var(--c); }
.swatch input:focus-visible + span { outline: 2px solid var(--ink); }

.reminder-form { display: grid; gap: 8px; margin-bottom: 8px; }
.reminder-form input { margin: 0; }
.rem label { flex: 1; display: flex; align-items: center; gap: 10px; margin: 0; color: var(--ink); font-size: 1rem; }
.rem input[type="checkbox"] { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.rem.done span { text-decoration: line-through; color: var(--muted); }
.rem time { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.rem .x { background: none; border: 0; font-size: 1.4rem; color: var(--muted); cursor: pointer; padding: 0 4px; }

/* Navegación inferior */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; background: var(--bar);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.nav button {
  flex: 1; background: none; border: 0; padding: 10px 0 8px; cursor: pointer; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .72rem;
}
.nav button[aria-current="page"] { color: var(--accent-text); }
.nav svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Selector de proyectos */
dialog {
  border: 0; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  width: 100%; max-width: 560px; margin: auto auto 0; background: var(--card); color: var(--ink);
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h3 { margin-bottom: 10px; }
.check { display: flex; align-items: center; gap: 12px; padding: 10px 0; margin: 0; font-size: 1rem; color: var(--ink); border-bottom: 1px solid var(--line); }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
dialog .btn { width: 100%; margin-top: 14px; }
#token-dialog p { margin-bottom: 14px; }
.token-error { color: var(--danger); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 10; max-width: 90%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  background: var(--card-2); color: var(--ink); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 12px; font-size: .92rem;
}
