:root{
  --night:#0F1522;
  --panel:#1A2333;
  --panel-2:#212D42;
  --ink:#EAF0F8;
  --dim:#8A97AB;
  --amber:#FFB224;
  --mint:#59D9A4;
  --line:#2A3750;
  --radius:14px;
}
*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{
  background:var(--night);
  color:var(--ink);
  font-family:"Bricolage Grotesque",system-ui,sans-serif;
  font-size:16px;
  -webkit-tap-highlight-color:transparent;
  display:flex;flex-direction:column;
  padding-bottom:env(safe-area-inset-bottom);
}
button{font-family:inherit;color:inherit;background:none;border:none;cursor:pointer}
input,textarea,select{
  font-family:inherit;font-size:1rem;color:var(--ink);
  background:var(--panel-2);border:1px solid var(--line);border-radius:10px;
  padding:.6rem .75rem;width:100%;
}
input:focus,textarea:focus,button:focus-visible{outline:2px solid var(--amber);outline-offset:2px}
textarea{resize:vertical;min-height:5.5rem}
label{display:block;font-size:.8rem;color:var(--dim);margin-bottom:.35rem}

/* header */
header{
  padding:calc(env(safe-area-inset-top) + 14px) 20px 10px;
  display:flex;align-items:baseline;justify-content:space-between;
}
.brand{font-weight:800;letter-spacing:.14em;font-size:.8rem;color:var(--amber);text-transform:uppercase}
.today-date{font-family:"Chivo Mono",monospace;font-size:.75rem;color:var(--dim)}

/* views */
main {
  flex: 1;
  overflow: hidden; /* De main zelf scrollt NIET, de view doet het */
  padding: 8px 20px 0px; /* Minder padding onderaan, de view regelt dat */
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* 2. Pas de views aan: de coach view moet een flex-container zijn 
   die de volledige beschikbare hoogte inneemt */
.view {
  display: none;
  flex-direction: column;
  gap: 18px;
  height: 100%;
  overflow-y: auto; /* Hiermee kunnen we door de hele tab scrollen */
  overflow-x: hidden;
  padding-bottom: 30px; /* Extra ruimte onderaan zodat je niet tegen de nav-bar aan scrolt */
}

.view.active {
  display: flex;
}
/* 3. Specifieke fix voor de COACH view */
#view-coach {
  /* Zorgt dat de chat-tools bovenaan staan, de log in het midden, 
     en de input onderaan */
  justify-content: stretch; 
}

/* rep counter */
.counter{
  background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);
  min-height: 160px; /* Pas dit getal aan tot het de ruimte inneemt die je wilt */
  padding:22px 20px 18px;text-align:center;position:relative;overflow:hidden;
}
.counter::after{ /* lamplight sweep */
  content:"";position:absolute;inset:-40% -20% auto;height:120%;
  background:radial-gradient(ellipse at 50% 0%,rgba(255,178,36,.10),transparent 65%);
  pointer-events:none;
}
.count-num {
  font-family: "Chivo Mono", monospace;
  font-weight: 700;
  /* Verlaag de maximale grootte van 5.4rem naar 4rem voor meer veiligheid */
  font-size: clamp(3rem, 18vw, 4rem); 
  line-height: 1;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}
.count-num.tick{animation:tick .25s ease-out}
@keyframes tick{from{transform:translateY(6px);opacity:.4}to{transform:none;opacity:1}}
.count-label{font-size:.85rem;color:var(--dim);margin-top:6px}
.count-week{font-family:"Chivo Mono",monospace;font-size:.8rem;color:var(--dim);margin-top:2px}
.count-week b{color:var(--ink);font-weight:700}

/* quick add */
.chips{display:flex;gap:10px;flex-wrap:wrap;justify-content:center;flex-wrap: nowrap; }
.chip{
  background:var(--panel-2);border:1px solid var(--line);border-radius:999px;
  padding:.6rem 1rem;font-weight:600;font-size:1rem;white-space: nowrap;
}
/* De '...' knop mag iets kleiner zijn */
#chip-custom {
  padding: .6rem .8rem;
  font-size: 1.2rem;
}
.chip.primary{background:var(--amber);color:#161006;border-color:var(--amber)}
.chip:active{transform:scale(.96)}
.undo-row{display:flex;justify-content:center}
.undo{font-size:.8rem;color:var(--dim);text-decoration:underline;padding:.4rem .8rem}

/* chart */
.card{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);padding:16px}
.card h2{font-size:.8rem;font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:var(--dim);margin-bottom:12px}
.chart{display:flex;align-items:flex-end;gap:8px;height:130px}
.day{flex:1;display:flex;flex-direction:column;align-items:center;gap:6px;height:100%;justify-content:flex-end}
.bar{width:100%;display:flex;flex-direction:column-reverse;gap:2px;justify-content:flex-start}
.seg{background:#3D4E70;border-radius:3px;min-height:3px}
.day.today .seg{background:var(--amber)}
.day-label{font-family:"Chivo Mono",monospace;font-size:.65rem;color:var(--dim)}
.day.today .day-label{color:var(--amber)}
.day-total{font-family:"Chivo Mono",monospace;font-size:.65rem;color:var(--ink)}
.sets-list{list-style:none;display:flex;flex-direction:column;gap:8px}
.sets-list li{
  display:flex;justify-content:space-between;align-items:center;
  background:var(--panel-2);border-radius:10px;padding:.55rem .8rem;
  font-family:"Chivo Mono",monospace;font-size:.85rem;
}
.sets-list .del{color:var(--dim);font-size:1rem;padding:.2rem .5rem}
.empty{color:var(--dim);font-size:.85rem}

/* chat */
#chat-log {
  flex: 1; 
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0; 
}

.msg {
  max-width: 88%;
  padding: .7rem .9rem;
  border-radius: 14px;
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: .95rem;
}

.msg.user {
  align-self: flex-end;
  background: var(--amber);
  color: #161006;
  border-bottom-right-radius: 4px;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.msg.assistant.pending::after {
  content: "▋";
  animation: blink 1s steps(1) infinite;
  color: var(--amber);
}

.msg-time {
  font-size: 0.7rem;
  opacity: 0.6;
  margin-top: 4px;
  font-family: "Chivo Mono", monospace;
  text-align: right;
}

/* Speciaal voor de 'user' berichten: tijd links uitlijnen als je dat mooier vindt */
.msg.user .msg-time {
  text-align: left;
}

@keyframes blink { 50% { opacity: 0 } }

.chat-input-row {
  display: flex;
  gap: 8px;
  background: var(--night);
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.chat-input-row textarea {
  min-height: 2.9rem;
  max-height: 8rem;
  flex: 1;
  margin: 0;
}

.send {
  background: var(--amber);
  color: #161006;
  border-radius: 10px;
  padding: 0 1.1rem;
  font-weight: 700;
}

.send:disabled { opacity: .4; }

.chat-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-tools button {
  font-size: .8rem;
  color: var(--dim);
  text-decoration: underline;
  padding: .3rem 0;
}

.chat-status {
  font-size: .75rem;
  color: var(--dim);
  font-family: "Chivo Mono", monospace;
}
/* settings */
.field{display:flex;flex-direction:column}
.row{display:flex;gap:10px;align-items:center}
.row input[type=time]{width:auto}
.toggle{display:flex;align-items:center;justify-content:space-between;gap:12px}
.toggle span{font-size:.95rem}
.switch{position:relative;width:46px;height:26px;flex:none}
.switch input{position:absolute;opacity:0;width:100%;height:100%;margin:0;cursor:pointer}
.slider{position:absolute;inset:0;background:var(--panel-2);border:1px solid var(--line);border-radius:999px;transition:.15s}
.slider::before{content:"";position:absolute;width:20px;height:20px;left:2px;top:2px;background:var(--dim);border-radius:50%;transition:.15s}
.switch input:checked + .slider{background:var(--amber);border-color:var(--amber)}
.switch input:checked + .slider::before{transform:translateX(20px);background:#161006}
.btn{
  background:var(--panel-2);border:1px solid var(--line);border-radius:10px;
  padding:.65rem 1rem;font-weight:600;font-size:.9rem;
}
.btn.accent{background:var(--amber);color:#161006;border-color:var(--amber)}
.hint{font-size:.75rem;color:var(--dim);margin-top:.35rem;line-height:1.4}
.ok{color:var(--mint)}
.warn{color:var(--amber)}
/* De verborgen status */
.hidden {
  display: none !important;
}

/* Optioneel: een visuele hint dat het een knop is */
#toggle-api-key-section:active {
  transform: scale(0.98);
  color: var(--amber);
}
/* tab bar */
nav{
  display:flex;border-top:1px solid var(--line);background:var(--panel);
  padding-bottom:env(safe-area-inset-bottom);
}
nav button{
  flex:1;display:flex;flex-direction:column;align-items:center;gap:3px;
  padding:.6rem 0 .5rem;color:var(--dim);font-size:.7rem;font-weight:600;
}
nav button.active{color:var(--amber)}
nav svg{width:22px;height:22px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}

dialog{
  background:var(--panel);color:var(--ink);border:1px solid var(--line);
  border-radius:var(--radius);padding:20px;width:min(90vw,320px);margin:auto;
}
dialog::backdrop{background:rgba(5,8,14,.7)}
dialog h3{font-size:1rem;margin-bottom:12px}
dialog .row{margin-top:12px;justify-content:flex-end}

@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation:none!important;transition:none!important}
}
