/* Noam School — Focus & Plan
   Executive-function planner. Calm, low-distraction, fully offline (system fonts only). */

:root {
  --navy: #16324a;
  --navy-deep: #0f1f2e;
  --teal: #147c78;
  --teal-bright: #1aa39d;
  --amber: #d99028;
  --red: #c0473a;
  --green: #2a8f5c;
  --bg: #eef3f1;
  --bg-2: #f8fbf8;
  --paper: #fffdf8;
  --line: #d8e2dc;
  --ink: #142033;
  --muted: #5c6b7a;
  --shadow-sm: 0 6px 18px rgba(21, 35, 52, 0.07);
  --shadow: 0 16px 40px rgba(21, 35, 52, 0.12);
  --radius: 18px;
  --radius-lg: 26px;
  --focus-ring: 0 0 0 3px #fff, 0 0 0 6px var(--teal-bright);
  --font-scale: 1;
  --base-font: 16px;
  --motion: 0.2s;
  --maxw: 1120px;
  color-scheme: light;
}

/* ---- Themes ---- */
html[data-theme="dark"] {
  --navy: #9cc6e6;
  --navy-deep: #06101a;
  --teal: #36c2bb;
  --teal-bright: #45d6ce;
  --amber: #f0b454;
  --red: #f08379;
  --green: #5dcb8f;
  --bg: #0c1722;
  --bg-2: #0f1d2a;
  --paper: #152433;
  --line: #2a3d4f;
  --ink: #e8eef4;
  --muted: #9fb2c2;
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.35);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  --focus-ring: 0 0 0 3px var(--navy-deep), 0 0 0 6px var(--teal-bright);
  color-scheme: dark;
}
html[data-theme="contrast"] {
  --navy: #000;
  --navy-deep: #000;
  --teal: #006a64;
  --teal-bright: #00867e;
  --amber: #8a5500;
  --red: #b3000f;
  --green: #00622f;
  --bg: #fff;
  --bg-2: #fff;
  --paper: #fff;
  --line: #000;
  --ink: #000;
  --muted: #222;
  --shadow-sm: none;
  --shadow: none;
  --focus-ring: 0 0 0 3px #fff, 0 0 0 6px #000;
}
html[data-theme="contrast"] .card,
html[data-theme="contrast"] .item,
html[data-theme="contrast"] .btn {
  border-width: 2px;
}

html[data-readable="on"] {
  --base-font: 17px;
  letter-spacing: 0.012em;
  word-spacing: 0.06em;
}
html[data-readable="on"] body {
  font-family:
    "Atkinson Hyperlegible", "Comic Sans MS", "Verdana", system-ui, sans-serif;
  line-height: 1.7;
}

* {
  box-sizing: border-box;
}

html {
  font-size: calc(var(--base-font) * var(--font-scale));
}

body {
  margin: 0;
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  background-attachment: fixed;
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--teal);
}

/* Accessibility: visible focus everywhere */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 10px;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --motion: 0.001s;
  }
  html {
    scroll-behavior: auto;
  }
  .timer-ring .prog {
    transition: none;
  }
}
html[data-motion="off"] * {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -48px;
  z-index: 200;
  background: var(--navy);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 800;
  transition: top var(--motion);
}
.skip-link:focus {
  top: 8px;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px 16px 110px;
}

/* ---- Top bar ---- */
.top {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}
.logo {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  flex: none;
  background: linear-gradient(135deg, var(--teal-bright), var(--navy));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 1.3rem;
  box-shadow: var(--shadow-sm);
}
.brand h1 {
  margin: 0;
  color: var(--navy);
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}
.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}
.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* connection + sync chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 0.74rem;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
}
.chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.chip.online .dot {
  background: var(--green);
}
.chip.offline {
  color: var(--amber);
}
.chip.offline .dot {
  background: var(--amber);
}

/* ---- Buttons ---- */
.btn {
  border: 1.5px solid var(--line);
  background: var(--paper);
  border-radius: 13px;
  padding: 11px 14px;
  font-weight: 800;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    transform var(--motion),
    background var(--motion),
    border-color var(--motion);
  min-height: 44px;
  min-width: 44px;
  line-height: 1.1;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0);
}
.btn.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}
.btn.navy {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
html[data-theme="dark"] .btn.navy,
html[data-theme="dark"] .btn.primary {
  color: #06101a;
}
.btn.ghost {
  background: transparent;
}
.btn.danger {
  background: transparent;
  border-color: var(--red);
  color: var(--red);
}
.btn.sm {
  padding: 7px 10px;
  min-height: 38px;
  font-size: 0.82rem;
}
.btn.block {
  width: 100%;
}
.btn.big {
  padding: 16px 22px;
  font-size: 1.05rem;
  border-radius: 16px;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.spacer {
  flex: 1;
}
.muted {
  color: var(--muted);
}
.center {
  text-align: center;
}
.hidden {
  display: none !important;
}

/* ---- Right Now hero ---- */
.hero {
  border-radius: var(--radius-lg);
  background: linear-gradient(
    135deg,
    var(--navy-deep),
    var(--navy) 55%,
    #0e4b59
  );
  color: #fff;
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
html[data-theme="dark"] .hero {
  background: linear-gradient(135deg, #08131f, #102438 55%, #0c3a44);
}
html[data-theme="contrast"] .hero {
  background: #000;
  border: 2px solid #fff;
}
.hero .eyebrow {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #ffd790;
}
.hero h2 {
  margin: 8px 0 4px;
  font-size: clamp(1.4rem, 3.4vw, 2.1rem);
  line-height: 1.1;
}
.hero .now-task {
  margin: 10px 0;
}
.hero .now-task .now-title {
  font-size: clamp(1.5rem, 4.4vw, 2.6rem);
  font-weight: 900;
  line-height: 1.05;
}
.hero .now-meta {
  color: rgba(255, 255, 255, 0.82);
  margin-top: 6px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-weight: 700;
}
.hero .now-meta .tag {
  background: rgba(255, 255, 255, 0.14);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
}
.hero .now-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.hero .now-actions .btn {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}
.hero .now-actions .btn.go {
  background: #fff;
  color: var(--navy);
  border-color: #fff;
  font-size: 1.1rem;
}
html[data-theme="contrast"] .hero .now-actions .btn {
  border-color: #fff;
}
.hero .progress-strip {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}
.statbox {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 12px 14px;
}
.statbox b {
  font-size: 1.5rem;
  display: block;
}
.statbox small {
  color: rgba(255, 255, 255, 0.75);
  font-weight: 700;
}

/* ---- Cards ---- */
.grid {
  display: grid;
  gap: 14px;
}
.g2 {
  grid-template-columns: 1fr 1fr;
}
.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.card .head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 6px;
}
.card h3 {
  margin: 0;
  color: var(--navy);
  font-size: 1.05rem;
}
.card .sub {
  margin: 2px 0 12px;
  color: var(--muted);
  font-size: 0.84rem;
}

/* task items */
.item {
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: 14px;
  padding: 12px;
  margin: 9px 0;
}
html[data-theme="dark"] .item {
  background: rgba(255, 255, 255, 0.03);
}
.item .head {
  margin-bottom: 4px;
}
.item h4 {
  margin: 0;
  color: var(--ink);
  font-size: 0.98rem;
}
.item .meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}
.item.done h4 {
  text-decoration: line-through;
  opacity: 0.6;
}
.item.overdue {
  border-left: 4px solid var(--red);
}
.item.today-due {
  border-left: 4px solid var(--amber);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 4px 9px;
  background: #e2f4f2;
  color: #0d6863;
  font-weight: 800;
  font-size: 0.72rem;
}
html[data-theme="dark"] .pill {
  background: rgba(54, 194, 187, 0.18);
  color: var(--teal-bright);
}
.pill.red {
  background: #fbe4e0;
  color: var(--red);
}
.pill.amber {
  background: #fbeccb;
  color: #8a5b0d;
}
.pill.green {
  background: #d9f1e3;
  color: #1f7a4d;
}
.pill.blue {
  background: #e6edfb;
  color: #2f5bc4;
}
html[data-theme="dark"] .pill.red {
  background: rgba(240, 131, 121, 0.18);
  color: var(--red);
}
html[data-theme="dark"] .pill.amber {
  background: rgba(240, 180, 84, 0.18);
  color: var(--amber);
}
html[data-theme="dark"] .pill.green {
  background: rgba(93, 203, 143, 0.18);
  color: var(--green);
}
html[data-theme="dark"] .pill.blue {
  background: rgba(120, 160, 240, 0.2);
  color: #9bb6f0;
}

/* progress bar */
.bar {
  height: 9px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  margin: 8px 0;
}
.bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--teal-bright));
  border-radius: 999px;
  transition: width var(--motion);
}

/* steps / checklist */
.steps {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}
.steps li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
}
.steps li:last-child {
  border-bottom: none;
}
.check {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 24px;
  height: 24px;
  margin-top: 1px;
  border: 2px solid var(--teal);
  border-radius: 7px;
  cursor: pointer;
  display: grid;
  place-items: center;
  background: var(--paper);
}
.check:checked {
  background: var(--teal);
}
.check:checked::after {
  content: "✓";
  color: #fff;
  font-weight: 900;
  font-size: 0.9rem;
}
html[data-theme="dark"] .check:checked::after {
  color: #06101a;
}
.steptext {
  flex: 1;
}
.steptext.done {
  text-decoration: line-through;
  color: var(--muted);
}

/* forms */
.field {
  display: grid;
  gap: 5px;
  margin-bottom: 12px;
}
.field label {
  font-size: 0.74rem;
  font-weight: 900;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
input,
select,
textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--paper);
  border-radius: 12px;
  padding: 11px;
  color: var(--ink);
  min-height: 44px;
}
textarea {
  min-height: 120px;
  resize: vertical;
}
.field.inline {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
}
.field.inline input[type="checkbox"],
.field.inline input[type="range"] {
  width: auto;
  min-height: 0;
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.toggle-row:last-child {
  border-bottom: none;
}
.toggle-row .label b {
  display: block;
  color: var(--ink);
}
.toggle-row .label small {
  color: var(--muted);
}

.note {
  background: #fff7df;
  border: 1px solid #f0d68a;
  border-radius: 14px;
  padding: 12px;
  color: #6f4c0a;
  line-height: 1.45;
  font-size: 0.86rem;
}
html[data-theme="dark"] .note {
  background: rgba(240, 180, 84, 0.1);
  border-color: rgba(240, 180, 84, 0.35);
  color: var(--amber);
}
.preview {
  white-space: pre-wrap;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  min-height: 120px;
}

/* segmented control */
.seg {
  display: inline-flex;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
  flex-wrap: wrap;
}
.seg button {
  border: none;
  background: transparent;
  padding: 8px 12px;
  border-radius: 9px;
  font-weight: 800;
  color: var(--muted);
  cursor: pointer;
  min-height: 38px;
}
.seg button[aria-pressed="true"] {
  background: var(--paper);
  color: var(--navy);
  box-shadow: var(--shadow-sm);
}

/* ---- Bottom nav ---- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-around;
  padding: 6px max(8px, env(safe-area-inset-left))
    calc(6px + env(safe-area-inset-bottom));
}
.tabbar button {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.66rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  border-radius: 12px;
  min-width: 56px;
  min-height: 48px;
}
.tabbar button .ic {
  font-size: 1.25rem;
  line-height: 1;
}
.tabbar button[aria-current="page"] {
  color: var(--teal);
}
.tabbar button[aria-current="page"] .ic {
  transform: translateY(-1px);
}

/* ---- Modal ---- */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(8, 16, 26, 0.55);
  display: none;
  place-items: center;
  padding: 16px;
  z-index: 100;
}
.modal-back.open {
  display: grid;
  animation: fade var(--motion);
}
.modal {
  width: min(640px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--paper);
  border-radius: 22px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.modal .head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.modal h2 {
  margin: 0;
  color: var(--navy);
  font-size: 1.2rem;
}
@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ---- Focus session overlay ---- */
.focus-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: none;
  flex-direction: column;
  background: radial-gradient(ellipse at top, #11405a, var(--navy-deep) 70%);
  color: #fff;
  padding: max(20px, env(safe-area-inset-top)) 20px;
}
.focus-overlay.open {
  display: flex;
}
.focus-overlay .fhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.focus-overlay .ftitle {
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  font-weight: 900;
  margin: 18px 0 4px;
}
.focus-overlay .fclass {
  color: rgba(255, 255, 255, 0.7);
  font-weight: 700;
}
.timer-ring {
  display: grid;
  place-items: center;
  margin: 18px auto;
  position: relative;
  width: min(280px, 70vw);
  aspect-ratio: 1;
}
.timer-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.timer-ring .track {
  stroke: rgba(255, 255, 255, 0.14);
}
.timer-ring .prog {
  stroke: #ffd790;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear;
}
.timer-ring .time {
  position: absolute;
  font-size: clamp(2.2rem, 9vw, 4rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.timer-ring .phase {
  position: absolute;
  top: 62%;
  font-weight: 800;
  color: #ffd790;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.8rem;
}
.focus-overlay .fsteps {
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
  overflow: auto;
}
.focus-overlay .fsteps .steps li {
  border-color: rgba(255, 255, 255, 0.12);
}
.focus-overlay .fsteps .check {
  background: transparent;
  border-color: #ffd790;
}
.focus-overlay .fsteps .check:checked {
  background: #ffd790;
}
.focus-overlay .fsteps .check:checked::after {
  color: var(--navy-deep);
}
.focus-overlay .factions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 16px;
}
.focus-overlay .factions .btn {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}
.focus-overlay .factions .btn.go {
  background: #ffd790;
  color: var(--navy-deep);
  border-color: #ffd790;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translate(-50%, 80px);
  z-index: 180;
  background: var(--navy);
  color: #fff;
  border-radius: 14px;
  padding: 12px 18px;
  font-weight: 800;
  opacity: 0;
  transition:
    opacity var(--motion),
    transform var(--motion);
  box-shadow: var(--shadow);
  max-width: 90vw;
  text-align: center;
}
html[data-theme="dark"] .toast {
  color: #06101a;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* confetti-free celebration */
.celebrate {
  animation: pop var(--motion) ease;
}
@keyframes pop {
  0% {
    transform: scale(0.96);
  }
  60% {
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
  }
}

/* empty states */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 24px 12px;
}
.empty .big-emoji {
  font-size: 2.4rem;
}

/* timeline */
.timeline {
  position: relative;
  margin: 8px 0 0;
}
.tl-row {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  align-items: start;
  padding: 6px 0;
}
.tl-row .when {
  font-weight: 800;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
  padding-top: 12px;
}

.section-title {
  font-weight: 900;
  color: var(--navy);
  margin: 18px 4px 8px;
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

@media (max-width: 820px) {
  .home-grid,
  .g2 {
    grid-template-columns: 1fr;
  }
  .wrap {
    padding-bottom: 96px;
  }
}
@media print {
  .tabbar,
  .top-actions,
  .hero .now-actions {
    display: none;
  }
}
