/* MémoPro — dark, mobile-first stylesheet */
:root {
  --bg: #0b0f17;
  --surface: #141a25;
  --surface-2: #1c2433;
  --border: #283246;
  --text: #e6e9ef;
  --muted: #8b95a8;
  --accent: #5b9dff;
  --accent-ink: #06142b;
  --danger: #ff5c5c;
  --danger-bg: #3a1518;
  --warn: #f5b041;
  --ok: #3ccf8e;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* --- Header & navigation ------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(11, 15, 23, .94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 0;
}
.topbar-row { display: flex; align-items: center; gap: 10px; }
.brand { font-weight: 700; font-size: 1.15rem; flex: 1; letter-spacing: .2px; }
.brand span { color: var(--accent); }
.icon-btn {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  min-width: 40px; height: 40px; padding: 0 10px; cursor: pointer;
}
.tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 10px 0;
  scrollbar-width: none; margin: 0 -16px; padding-left: 16px; padding-right: 16px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 6px 12px; font-size: .9rem; cursor: pointer; white-space: nowrap;
}
.tab.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.tab.danger { border-color: var(--danger); color: var(--danger); }
.tab.danger.active { background: var(--danger); color: #fff; }
.tab .badge { margin-left: 6px; font-size: .75rem; opacity: .85; }

.filter-row { display: flex; gap: 8px; padding-bottom: 10px; }
.filter-row select { flex: 1; min-width: 0; }

/* --- Task list ----------------------------------------------------------- */
main { padding: 12px 16px calc(100px + var(--safe-b)); max-width: 720px; margin: 0 auto; }
.section-title {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 16px 2px 8px;
}
.section-title.danger { color: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 48px 12px; }

.card {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 5px solid var(--dom, var(--border));
  border-radius: var(--radius); padding: 12px; margin-bottom: 8px; cursor: pointer;
}
.card.overdue { background: var(--danger-bg); border-color: var(--danger); border-left-color: var(--danger); }
.card.done .card-title { text-decoration: line-through; color: var(--muted); }
.check {
  flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--muted); background: transparent; cursor: pointer; margin-top: 1px;
  display: grid; place-items: center; font-size: .85rem; padding: 0;
}
.check.on { background: var(--ok); border-color: var(--ok); color: #04210f; }
.card-body { flex: 1; min-width: 0; }
.card-title { font-weight: 600; overflow-wrap: anywhere; }
.card-next { color: var(--muted); font-size: .9rem; margin-top: 2px; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; font-size: .78rem; }
.pill {
  border-radius: 999px; padding: 2px 8px; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--muted); white-space: nowrap;
}
.pill.late { color: #fff; background: var(--danger); border-color: var(--danger); }
.pill.high { color: var(--warn); border-color: var(--warn); }
.pill.dom { color: var(--text); }
.pill.dom::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--dom); margin-right: 5px; vertical-align: 0;
}

/* --- Floating "+" button ------------------------------------------------- */
.fab {
  position: fixed; right: 18px; bottom: calc(18px + var(--safe-b)); z-index: 20;
  width: 64px; height: 64px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-size: 2.2rem; line-height: 1;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}

/* --- Sheets / panels ----------------------------------------------------- */
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 30; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  background: var(--surface); border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + var(--safe-b));
  max-width: 720px; margin: 0 auto;
}
.sheet h2 { margin: 0 0 10px; font-size: 1.05rem; }
.quick-row { display: flex; gap: 8px; }
.quick-row input { flex: 1; min-width: 0; font-size: 1.05rem; }

.panel {
  position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow-y: auto;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px calc(24px + var(--safe-b));
}
.panel-inner { max-width: 720px; margin: 0 auto; }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.panel-head h2 { flex: 1; margin: 0; font-size: 1.1rem; }

/* --- Forms --------------------------------------------------------------- */
label { display: block; font-size: .82rem; color: var(--muted); margin: 12px 0 4px; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=url],
select, textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
textarea { min-height: 90px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid2 > div { min-width: 0; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1 1 auto; border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 10px; padding: 9px 8px; cursor: pointer; font-size: .9rem;
}
.seg button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.seg button.on.st-fait { background: var(--ok); border-color: var(--ok); color: #04210f; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px;
  padding: 10px 14px; min-height: 44px; cursor: pointer; text-decoration: none; color: var(--text);
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.block { width: 100%; }
.actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.actions .btn { flex: 1 1 auto; }

.list-edit { display: flex; gap: 6px; margin-bottom: 6px; }
.list-edit input { flex: 1; min-width: 0; }
.link-row a { overflow-wrap: anywhere; }

.box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; margin-top: 16px;
}
.box h3 { margin: 0 0 8px; font-size: .95rem; }
.att { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); }
.att:first-of-type { border-top: 0; }
.att a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att small { color: var(--muted); }
.hist { font-size: .85rem; color: var(--muted); padding: 4px 0; }
.hist b { color: var(--text); font-weight: 600; }

.dom-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.dom-row input[type=text] { flex: 1; min-width: 0; }
input[type=color] {
  width: 44px; height: 44px; padding: 2px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-2); flex: 0 0 44px;
}

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(96px + var(--safe-b)); background: var(--surface-2); border: 1px solid var(--border);
  padding: 10px 16px; border-radius: 999px; max-width: calc(100% - 32px); text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
}
.offline { background: var(--warn); color: #241600; text-align: center; font-size: .85rem; padding: 4px; }

/* --- Login --------------------------------------------------------------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
}
.login form {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 24px;
}
.login h1 { margin: 0 0 4px; }
.login p { color: var(--muted); margin: 0 0 12px; }
.err { color: var(--danger); min-height: 1.4em; margin-top: 8px; }
