* { box-sizing: border-box; }
:root { color-scheme: dark; }
html, body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  background: #000;
  color: #f2f2f7;
}
body {
  max-width: 560px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  min-height: 100vh;
}
.hidden { display: none !important; }

/* ---- Auth / setup ---- */
.auth-card {
  margin: 12vh auto 0;
  max-width: 340px;
  text-align: center;
}
.auth-logo { border-radius: 16px; margin-bottom: 12px; }
.auth-card h1 { font-size: 22px; margin: 0 0 8px; }
.auth-sub { font-size: 14px; color: #9a9aa0; margin: 0 0 20px; line-height: 1.4; }
#login-form { display: flex; flex-direction: column; gap: 10px; }
#login-form input {
  background: #1c1c1e; border: 1px solid #3a3a3c; border-radius: 10px;
  color: #f2f2f7; padding: 12px 14px; font-size: 16px;
}
#login-form button, #login-btn {
  background: #0a84ff; border: none; border-radius: 10px; color: #fff;
  padding: 12px 14px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.auth-switch { font-size: 13px; color: #9a9aa0; margin-top: 16px; }
.link-btn { background: none; border: none; color: #0a84ff; font-size: 13px; cursor: pointer; padding: 0 4px; }
.auth-msg { font-size: 13px; color: #ff9f0a; margin-top: 14px; min-height: 18px; }
#signup-code { border-color: #ff9f0a55; }

/* ---- Header app ---- */
.app-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.app-header h1 { font-size: 20px; margin: 0; }
.ghost {
  background: none; border: 1px solid #3a3a3c; border-radius: 8px;
  color: #9a9aa0; padding: 6px 10px; font-size: 12px; cursor: pointer;
}

/* ---- Formulaire d'ajout ---- */
#add-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
#add-form input, #add-form select {
  background: #1c1c1e; border: 1px solid #3a3a3c; border-radius: 8px;
  color: #f2f2f7; padding: 10px 12px; font-size: 15px;
}
#task-name { flex: 2 1 140px; min-width: 0; }
#task-minutes { flex: 1 1 90px; min-width: 0; }
#task-priority { flex: 1 1 100px; }
#add-form button {
  flex: 1 1 100%;
  background: #0a84ff; border: none; border-radius: 8px; color: #fff;
  padding: 11px; font-size: 15px; font-weight: 600; cursor: pointer;
}

/* ---- Onglets ---- */
#tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab {
  flex: 1; background: #1c1c1e; border: 1px solid transparent; border-radius: 8px;
  color: #d1d1d6; padding: 8px 4px; font-size: 12px; cursor: pointer; white-space: nowrap;
}
.tab:hover { background: #2c2c2e; }
.tab.active { border-color: #0a84ff; color: #fff; }
.tab.tab-high.active { border-color: #ff453a; }
.tab.tab-medium.active { border-color: #ff9f0a; }
.tab.tab-low.active { border-color: #30d158; }

/* ---- Liste ---- */
#task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.empty { color: #8e8e93; font-size: 13px; text-align: center; padding: 20px 0; }
.task {
  background: #1c1c1e; border-radius: 10px; border-left: 3px solid #48484a;
  padding: 12px; display: flex; align-items: center; gap: 10px;
}
.task.prio-high { border-left-color: #ff453a; }
.task.prio-medium { border-left-color: #ff9f0a; }
.task.prio-low { border-left-color: #30d158; }
.task.running { box-shadow: inset 0 0 0 1px #0a84ff; }

.task-main { flex: 1; min-width: 0; }
.task-name-row { display: flex; align-items: center; gap: 8px; }
.task-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.task-time { font-size: 12px; color: #8e8e93; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.task-time .over { color: #ff9f0a; font-weight: 600; }

.prio-badge { border: none; border-radius: 999px; padding: 2px 9px; font-size: 10px; font-weight: 600; cursor: pointer; flex-shrink: 0; }
.prio-badge.prio-high { background: rgba(255,69,58,0.2); color: #ff6961; }
.prio-badge.prio-medium { background: rgba(255,159,10,0.2); color: #ffb340; }
.prio-badge.prio-low { background: rgba(48,209,88,0.2); color: #4cd471; }

.task-planned { font-size: 11px; color: #64d2ff; background: none; border: none; padding: 2px 4px; border-radius: 4px; cursor: pointer; }
.task-planned:hover { background: rgba(100,210,255,0.15); }
.planned-input { width: 64px; background: #000; border: 1px solid #0a84ff; border-radius: 4px; color: #f2f2f7; padding: 3px 6px; font-size: 11px; }

.task-actions { display: flex; gap: 6px; flex-shrink: 0; }
.task-actions button {
  background: #3a3a3c; border: none; border-radius: 8px; color: #f2f2f7;
  padding: 9px 11px; font-size: 12px; cursor: pointer;
}
.task-actions button.primary { background: #0a84ff; }
.task-actions button.danger { background: #ff453a; }
.task-actions button.done-btn { background: #248a3d; }
.task-actions button.done-btn.active { background: #3a3a3c; color: #9a9aa0; }

/* Tache marquee comme faite */
.task.done { opacity: 0.55; }
.task.done .task-name { text-decoration: line-through; }
.task.done .prio-badge { opacity: 0.7; }

.sync-state { text-align: center; font-size: 11px; color: #636366; margin-top: 16px; }

/* Sur telephone : actions sur une ligne dediee -> le nom a toute la largeur */
@media (max-width: 480px) {
  .task { flex-direction: column; align-items: stretch; gap: 10px; }
  .task-actions { justify-content: flex-end; }
  .task-actions button { flex: 1; }
}
