:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #1f2330;
  --text: #e7e9ee;
  --muted: #98a0b3;
  --accent: #5b8cff;
  --accent-2: #3ad6a0;
  --err: #ff6b6b;
  --border: #2a2f3c;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

nav {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(15, 17, 21, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 1.2rem;
}
nav:empty { display: none; }

.brand { font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.05rem; }
.links { display: flex; gap: 0.4rem; align-items: center; }
.links a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  font-size: 0.92rem;
}
.links a:hover { color: var(--text); background: var(--panel-2); }
.links a.active { color: var(--text); background: var(--panel-2); }
.link-btn {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 0.92rem; padding: 0.35rem 0.7rem;
}
.link-btn:hover { color: var(--err); }

main {
  max-width: 1240px;
  margin: 1.6rem auto;
  padding: 0 1rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
}
/* Day grid spans the full width; reading views stay comfortably narrow. */
.card:not(.day) { max-width: 760px; margin: 0 auto; }

h1 { font-size: 1.4rem; margin: 0 0 0.3rem; }
h3 { margin: 1.2rem 0 0.4rem; font-size: 1rem; color: var(--accent-2); }
.muted { color: var(--muted); font-size: 0.92rem; margin-top: 0; }
.err-text { color: var(--err); }

input, select, textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  font-size: 0.95rem;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; }
label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.6; cursor: default; }

/* Auth */
.auth { max-width: 380px; margin: 3rem auto 0; }
.tabs { display: flex; gap: 0.5rem; margin: 1rem 0; }
.tab {
  flex: 1; background: var(--panel-2); color: var(--muted);
  font-weight: 500;
}
.tab.active { background: var(--accent); color: #fff; }
.pane { display: flex; flex-direction: column; gap: 0.7rem; }
.hidden { display: none; }

/* Day grid */
.day-head {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 0.8rem;
}
.day-nav { display: flex; align-items: center; gap: 0.4rem; }
.nav-btn {
  background: var(--panel-2); color: var(--text);
  padding: 0.3rem 0.6rem; font-weight: 600; line-height: 1;
}
.nav-btn.today { font-size: 0.8rem; }
.day-nav input[type="date"] { width: auto; }
.day-summary { display: flex; gap: 0.9rem; color: var(--muted); font-size: 0.85rem; }
.day-summary b { color: var(--text); }
.day h1 { margin: 0.8rem 0 0.2rem; font-size: 1.25rem; }

.grid-wrap { overflow-x: auto; margin-top: 1rem; border: 1px solid var(--border); border-radius: 10px; }
.day-grid { width: 100%; border-collapse: collapse; font-size: 0.85rem; min-width: 980px; }
.day-grid th {
  text-align: left; font-weight: 600; color: var(--muted);
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 0.5rem 0.5rem; background: var(--panel-2);
  border-bottom: 1px solid var(--border); position: sticky; top: 0;
}
.day-grid td { padding: 0; border-bottom: 1px solid var(--border); }
.day-grid tr.has-data { background: rgba(91, 140, 255, 0.06); }
.day-grid td.c-time {
  padding: 0 0.6rem; color: var(--muted); font-variant-numeric: tabular-nums;
  white-space: nowrap; font-weight: 600;
}
.day-grid input, .day-grid select {
  border: none; background: transparent; border-radius: 0;
  padding: 0.5rem 0.5rem; font-size: 0.85rem; width: 100%;
}
.day-grid input:focus, .day-grid select:focus {
  outline: 2px solid var(--accent); outline-offset: -2px; background: var(--panel-2);
}
.day-grid select option { background: var(--panel-2); }

/* Column widths */
.c-time   { width: 56px; }
.c-title  { min-width: 130px; }
.c-cat    { width: 150px; }
.c-did    { min-width: 240px; }
.c-obj    { min-width: 150px; }
.c-impact { min-width: 150px; }
.c-cost   { width: 110px; }
.c-skills { min-width: 140px; }
.c-status { width: 92px; white-space: nowrap; padding: 0 0.4rem; text-align: center; }
.c-status > * { vertical-align: middle; }

/* Per-row save status dot */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--border); vertical-align: middle; }
.dot.dirty  { background: #d9a441; }
.dot.saving { background: var(--accent); animation: pulse 1s infinite; }
.dot.saved  { background: var(--accent-2); }
.dot.error  { background: var(--err); }
@keyframes pulse { 50% { opacity: 0.35; } }

.row-del {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 0.8rem; padding: 0 0 0 0.4rem;
}
.row-del:hover { color: var(--err); }

.row-coach {
  background: none; border: none; cursor: pointer;
  font-size: 0.95rem; padding: 0 0.3rem 0 0; line-height: 1;
  filter: grayscale(0.5); opacity: 0.75;
}
.row-coach:hover { filter: none; opacity: 1; transform: scale(1.15); }

/* Per-entry coaching modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); width: 100%; max-width: 560px;
  max-height: 85vh; overflow-y: auto; padding: 1.2rem 1.4rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.modal header { display: flex; justify-content: space-between; align-items: center; }
.modal header h3 { margin: 0; }
.modal-close {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 1rem; padding: 0.2rem 0.4rem;
}
.modal-close:hover { color: var(--text); }
.modal-subject {
  color: var(--muted); font-size: 0.85rem; font-style: italic;
  margin: 0.2rem 0 0.8rem; border-left: 2px solid var(--accent); padding-left: 0.6rem;
}
.modal-body h4 { margin: 1rem 0 0.3rem; font-size: 0.85rem; color: var(--accent-2); }
.modal-body ul { margin: 0.3rem 0; padding-left: 1.2rem; }
.modal-body li { margin: 0.3rem 0; }
.modal-body p { margin: 0.3rem 0; font-size: 0.92rem; }

/* Coach */
#coach-out ul { margin: 0.3rem 0; padding-left: 1.2rem; }
#coach-out li { margin: 0.3rem 0; }
#coach-out { margin-top: 1rem; }

/* Toast */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(2rem);
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); padding: 0.7rem 1.1rem; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: all 0.25s; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: var(--accent-2); }
.toast.err { border-color: var(--err); }
