:root {
  --bg: #0e1016;
  --bg-2: #131722;
  --card: #171b27;
  --card-2: #1d2231;
  --line: #262c3d;
  --text: #e8ecf7;
  --muted: #98a2ba;
  --accent: #818cf8;
  --accent-2: #a855f7;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f43f5e;
  --radius: 14px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* .days and .form-grid label set display:flex, which would beat the HTML
   hidden attribute. This rule keeps hidden actually hiding. */
[hidden] {
  display: none !important;
}

/* The same screens serve the desktop app and the web/Android build. Anything
   that only makes sense on one side carries `data-desktop` or `data-web`; the
   web adapter (`src/web/owlbert-web.js`) puts the `web` class on the body and
   the rest is CSS. */
body:not(.web) [data-web],
body.web [data-desktop] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

::-webkit-scrollbar {
  width: 10px;
}
::-webkit-scrollbar-thumb {
  background: #2c3348;
  border-radius: 10px;
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover {
  background: #3a4360;
}

/* ------------------------------------------------------------ titlebar --- */

.titlebar {
  height: 40px;
  flex: 0 0 40px;
  -webkit-app-region: drag;
  display: flex;
  align-items: center;
  padding-left: 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.titlebar-name {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.6px;
  color: var(--muted);
  text-transform: uppercase;
}

.app {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* -------------------------------------------------------------- sidebar -- */

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 12px 12px;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 6px;
}

/* The app icon's owl, in SVG, so the sidebar logo is exactly the same
   drawing as the shortcut and the tray icon. */
.brand-mark {
  width: 36px;
  height: 36px;
  flex: none;
  filter: drop-shadow(0 4px 12px rgba(129, 140, 248, 0.35));
}

.brand-mark .mark-face {
  fill: #f2f0e4;
}

.brand-mark .mark-ink {
  fill: #312e81;
  stroke: #312e81;
}

.brand strong {
  display: block;
  font-size: 15px;
  line-height: 1.1;
}

.brand small {
  color: var(--muted);
  font-size: 11px;
}

nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}

.nav-item svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
  flex: none;
}

.nav-item:hover {
  background: #1c2130;
  color: var(--text);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.2), rgba(168, 85, 247, 0.14));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(129, 140, 248, 0.28);
}

.side-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mini-timer {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.mini-timer span {
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.mini-timer small {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* -------------------------------------------------------------- content -- */

.content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 26px 30px 40px;
}

.view {
  display: none;
  max-width: 1080px;
  margin: 0 auto;
}

.view.active {
  display: block;
  animation: fade 0.18s ease;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.view-head {
  margin-bottom: 20px;
}

.view-head h1 {
  font-size: 23px;
  font-weight: 650;
  letter-spacing: -0.3px;
}

.view-head p {
  color: var(--muted);
  margin-top: 3px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.card h2 {
  font-size: 13px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--muted);
  margin-bottom: 14px;
}

/* -------------------------------------------------------------- buttons -- */

button {
  font: inherit;
  cursor: pointer;
}

.primary,
.ghost,
.danger {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 600;
  transition: filter 0.14s, background 0.14s, border-color 0.14s;
}

.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 6px 18px rgba(129, 140, 248, 0.25);
}

.primary:hover {
  filter: brightness(1.1);
}

.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.ghost:hover {
  background: var(--card-2);
  color: var(--text);
}

.ghost.small {
  padding: 8px 12px;
  font-size: 12.5px;
}

.danger {
  background: rgba(244, 63, 94, 0.12);
  border-color: rgba(244, 63, 94, 0.35);
  color: #fda4af;
}

.danger:hover {
  background: rgba(244, 63, 94, 0.2);
}

/* ---------------------------------------------------------------- timer -- */

.grid-focus {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.85fr);
  gap: 16px;
  align-items: start;
}

@media (max-width: 1020px) {
  .grid-focus {
    grid-template-columns: 1fr;
  }
}

.timer-card {
  --ring: var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 24px 22px 22px;
}

.timer-card.break {
  --ring: var(--green);
}

.mode-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}

.mode-tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 7px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
  transition: background 0.14s, color 0.14s;
}

.mode-tabs button:hover {
  color: var(--text);
}

.mode-tabs button.active {
  background: var(--ring);
  color: #10131c;
}

.dial-big {
  position: relative;
  width: 320px;
  height: 320px;
  display: grid;
  place-items: center;
}

.dial-big svg {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}

.dial-big circle {
  fill: none;
  stroke-width: 11;
  stroke-linecap: round;
}

.dial-big .track {
  stroke: rgba(255, 255, 255, 0.06);
}

.dial-big .progress {
  stroke: var(--ring);
  stroke-dasharray: 728.85;
  stroke-dashoffset: 728.85;
  transition: stroke-dashoffset 0.3s linear, stroke 0.3s ease;
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--ring) 45%, transparent));
}

.timer-card.paused .progress {
  stroke: #59617d;
  filter: none;
}

.dial-face {
  text-align: center;
  z-index: 1;
}

.dial-face span {
  display: block;
  font-size: 54px;
  font-weight: 300;
  letter-spacing: -2px;
  font-variant-numeric: tabular-nums;
}

.dial-face small {
  color: var(--muted);
  font-size: 12px;
}

/* ------------------------------------------------------------ edit mode -- */

/* The dial's tick marks, clock style. They only show up while editing. */
.ticks {
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}

.timer-card.editing .ticks {
  opacity: 1;
}

.ticks line {
  stroke: #5b6480;
  stroke-width: 2;
  stroke-linecap: round;
}

.ticks line.major {
  stroke: var(--ring);
  stroke-width: 3.5;
}

/* The dial is a control, never selectable text: without this the time went
   selection-blue while dragging to turn it. */
.dial-big {
  user-select: none;
  -webkit-user-select: none;
}

.timer-card.editing .dial-big {
  cursor: grab;
  touch-action: none;
}

/* Instruction arrows drawn in the SVG itself, concentric with the ring, so
   they follow the dial's outline. */
.hints {
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}

.timer-card.editing .hints {
  opacity: 1;
}

.hints .hint-arc {
  fill: none;
  stroke: #7b849e;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.hints .hint-head {
  fill: #7b849e;
}

.hints .hint-sign {
  fill: #8d97b2;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 17px;
  font-weight: 700;
}

/* Unit picker: only appears while editing */
.unit-tabs {
  display: none;
  gap: 4px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}

.timer-card.editing .unit-tabs {
  display: flex;
}

.unit-tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 5px 15px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
  transition: background 0.14s, color 0.14s;
}

.unit-tabs button:hover {
  color: var(--text);
}

.unit-tabs button.active {
  background: var(--ring);
  color: #10131c;
}

.cycle-dots {
  display: flex;
  gap: 7px;
}

.cycle-dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
}

.cycle-dots i.on {
  background: var(--ring);
  box-shadow: 0 0 8px color-mix(in srgb, var(--ring) 60%, transparent);
}

.timer-actions {
  display: flex;
  gap: 8px;
}

.timer-actions .primary {
  min-width: 128px;
}

.task-pick {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 380px;
  color: var(--muted);
  font-size: 13px;
}

.task-pick select {
  flex: 1;
}

/* ------------------------------------------------------------ side cards -- */

.stack .card:last-child {
  margin-bottom: 0;
}

.goal-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.goal-row strong {
  font-size: 22px;
  font-weight: 600;
}

.goal-row span {
  color: var(--muted);
  font-size: 12px;
}

.bar {
  height: 8px;
  background: var(--bg-2);
  border-radius: 999px;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.4s ease;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
  text-align: center;
}

.mini-grid strong {
  display: block;
  font-size: 19px;
  font-weight: 600;
}

.mini-grid span {
  color: var(--muted);
  font-size: 11px;
}

.mini-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.mini-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}

.mini-list li b {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-list li time,
.mini-list li em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
  flex: none;
}

.empty {
  color: #6d7690;
  font-size: 13px;
}

/* ------------------------------------------------------------------ forms */

input,
select {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  padding: 9px 11px;
  outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
  min-width: 0;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.16);
}

input::placeholder {
  color: #66708a;
}

input[type='date'],
input[type='time'] {
  color-scheme: dark;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) 150px 78px auto;
  gap: 10px;
  align-items: center;
}

@media (max-width: 900px) {
  .form-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* The due-date and session-count fields sit inside a label purely so the
   phone layout can name them. Up here the columns already do that. */
.form-row label {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.form-row label span {
  display: none;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.form-grid .wide {
  grid-column: span 3;
}

.form-grid label,
.settings-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-grid label span,
.settings-grid label span {
  color: var(--muted);
  font-size: 12px;
}

.form-grid button {
  grid-column: 3;
  justify-self: end;
}

.days {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.days button {
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--muted);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 600;
}

.days button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #10131c;
}

.filters {
  display: flex;
  gap: 7px;
  margin-bottom: 12px;
}

.chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
}

.chip.active {
  background: var(--card-2);
  color: var(--text);
  border-color: #3a4260;
}

/* ----------------------------------------------------------------- lists -- */

.list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 13px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 15px;
}

.row.done .row-title {
  text-decoration: line-through;
  color: var(--muted);
}

.row-main {
  flex: 1;
  min-width: 0;
}

.row-title {
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-meta {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 5px;
}

.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--card-2);
  color: var(--muted);
  border: 1px solid var(--line);
}

.tag.late {
  background: rgba(244, 63, 94, 0.14);
  border-color: rgba(244, 63, 94, 0.3);
  color: #fda4af;
}

.tag.soon {
  background: rgba(251, 191, 36, 0.13);
  border-color: rgba(251, 191, 36, 0.3);
  color: var(--amber);
}

.tag.accent {
  background: rgba(129, 140, 248, 0.15);
  border-color: rgba(129, 140, 248, 0.3);
  color: #c3c8fb;
}

.row-actions {
  display: flex;
  gap: 5px;
  flex: none;
}

.icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  transition: background 0.13s, color 0.13s, border-color 0.13s;
}

.icon-btn svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.icon-btn:hover {
  background: var(--card-2);
  color: var(--text);
}

.icon-btn.del:hover {
  background: rgba(244, 63, 94, 0.16);
  border-color: rgba(244, 63, 94, 0.35);
  color: #fda4af;
}

.check {
  width: 21px;
  height: 21px;
  border-radius: 7px;
  border: 2px solid #3d4560;
  background: transparent;
  flex: none;
  display: grid;
  place-items: center;
  color: transparent;
}

.check.on {
  background: var(--green);
  border-color: var(--green);
  color: #0e1016;
}

.check svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

/* ------------------------------------------------------------ switches --- */

.switches {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.switch {
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
}

.switch input {
  display: none;
}

.switch i {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #2b3247;
  position: relative;
  flex: none;
  transition: background 0.16s;
}

.switch i::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #8b93ab;
  transition: transform 0.16s, background 0.16s;
}

.switch input:checked + i {
  background: rgba(129, 140, 248, 0.4);
}

.switch input:checked + i::after {
  transform: translateX(16px);
  background: var(--accent);
}

.switch span {
  font-size: 13.5px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.range {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.range span {
  color: var(--muted);
  font-size: 12px;
  width: 70px;
  flex: none;
}

.range input {
  flex: 1;
  padding: 0;
  background: transparent;
  border: 0;
  accent-color: var(--accent);
}

.hint {
  color: #6d7690;
  font-size: 12.5px;
  margin-top: 12px;
  line-height: 1.5;
}

.hint code {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 12px;
}

.warn {
  color: var(--amber);
  font-size: 12.5px;
  margin-top: 8px;
}

.update-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.update-head strong {
  font-size: 15px;
}

.update-head .hint {
  margin-top: 3px;
}

.update-folder {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 14px;
}

.update-folder span {
  color: var(--muted);
  font-size: 12px;
}

.update-ready {
  color: var(--green);
}

.update-error {
  color: var(--amber);
}

.danger-card {
  border-color: rgba(244, 63, 94, 0.22);
}

/* ------------------------------------------------------------------ stats */

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.card.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card.stat span {
  color: var(--muted);
  font-size: 12px;
}

.card.stat strong {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 190px;
  padding-top: 10px;
}

.chart .col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  height: 100%;
  justify-content: flex-end;
}

.chart .col i {
  width: 100%;
  max-width: 42px;
  border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, var(--accent), rgba(168, 85, 247, 0.55));
  min-height: 3px;
  transition: height 0.35s ease;
}

.chart .col.zero i {
  background: #232a3d;
}

.chart .col.today i {
  background: linear-gradient(180deg, var(--green), rgba(52, 211, 153, 0.5));
}

.chart .col b {
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 500;
}

.subjects {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.subject-row {
  display: grid;
  grid-template-columns: 130px 1fr 62px;
  gap: 11px;
  align-items: center;
  font-size: 13px;
}

.subject-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subject-row em {
  color: var(--muted);
  font-style: normal;
  text-align: right;
  font-size: 12px;
}

/* ----------------------------------------------------------------- toast -- */

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translate(-50%, 14px);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 13px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
