:root {
  --bg: #f4efe7;
  --panel: rgba(255, 252, 246, 0.92);
  --surface: #fffaf2;
  --text: #1d1a17;
  --muted: #6c6258;
  --border: #d8ccbc;
  --accent: #165d4a;
  --accent-strong: #0f4738;
  --study: #2a6fdb;
  --work: #165d4a;
  --waste: #b44f2f;
  --sleep: #5b4ab2;
  --other: #8a6c2f;
  --shadow: 0 18px 45px rgba(55, 39, 22, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(22, 93, 74, 0.18), transparent 32%),
    radial-gradient(circle at bottom right, rgba(180, 79, 47, 0.12), transparent 30%),
    linear-gradient(180deg, #f8f3eb 0%, var(--bg) 100%);
  min-height: 100vh;
}

.app-shell {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.hero {
  padding: 12px 4px 24px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
  margin-bottom: 12px;
}

.subtitle {
  max-width: 680px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.dashboard {
  display: grid;
  gap: 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(216, 204, 188, 0.85);
  border-radius: 22px;
  padding: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.log-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.log-form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.95rem;
  color: var(--muted);
}

.log-form input,
.log-form select,
.log-form button,
.secondary-button {
  border-radius: 14px;
  border: 1px solid var(--border);
  font: inherit;
}

.log-form input,
.log-form select {
  padding: 12px 14px;
  background: var(--surface);
  color: var(--text);
}

.log-form button,
.secondary-button {
  cursor: pointer;
  transition: transform 0.18s ease, background-color 0.18s ease;
}

.log-form button {
  align-self: end;
  padding: 13px 18px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.log-form button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

.secondary-button {
  padding: 10px 14px;
  background: transparent;
  color: var(--text);
}

.status {
  min-height: 24px;
  margin: 14px 2px 0;
  color: var(--muted);
}

.totals-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.total-card {
  padding: 16px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.total-card h3 {
  margin: 0 0 8px;
  font-size: 0.92rem;
  color: var(--muted);
}

.total-card strong {
  font-size: 1.4rem;
}

.tag-study {
  border-top: 4px solid var(--study);
}

.tag-work {
  border-top: 4px solid var(--work);
}

.tag-waste {
  border-top: 4px solid var(--waste);
}

.tag-sleep {
  border-top: 4px solid var(--sleep);
}

.tag-other {
  border-top: 4px solid var(--other);
}

.entries {
  display: grid;
  gap: 12px;
}

.entry-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
}

.entry-card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
  margin-bottom: 8px;
}

.entry-card h3 {
  margin: 0;
  font-size: 1rem;
}

.entry-meta,
.entry-time {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.entry-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
}

.entry-tag.study {
  background: var(--study);
}

.entry-tag.work {
  background: var(--work);
}

.entry-tag.waste {
  background: var(--waste);
}

.entry-tag.sleep {
  background: var(--sleep);
}

.entry-tag.other {
  background: var(--other);
}

@media (max-width: 900px) {
  .log-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .totals-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1100px);
    padding-top: 20px;
  }

  .panel {
    padding: 16px;
    border-radius: 18px;
  }

  .log-form,
  .totals-grid {
    grid-template-columns: 1fr;
  }

  .entry-card-header,
  .section-heading {
    flex-direction: column;
    align-items: flex-start;
  }

  .secondary-button,
  .log-form button {
    width: 100%;
  }
}

/* ---------- Home launcher ---------- */
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 8px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 180px;
  padding: 28px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid rgba(216, 204, 188, 0.85);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.tool-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.tool-card .tool-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.tool-card h2 {
  margin: 0;
  font-size: 1.35rem;
}

.tool-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ---------- Tool pages (shared) ---------- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.tool-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  text-align: center;
}

.timer-display {
  font-size: clamp(3rem, 12vw, 5.5rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.btn {
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 12px 22px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: transform 0.18s ease, background-color 0.18s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Laps (stopwatch) */
.laps {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 420px;
  display: grid;
  gap: 8px;
}

.laps li {
  display: flex;
  justify-content: space-between;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  font-variant-numeric: tabular-nums;
}

.laps li span:first-child {
  color: var(--muted);
}

/* ---------- Calendar ---------- */
.calendar {
  width: 100%;
  max-width: 520px;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.calendar-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.icon-btn {
  cursor: pointer;
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.icon-btn:hover {
  border-color: var(--accent);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.calendar-days {
  margin-top: 8px;
}

.calendar-weekday {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 4px;
}

.calendar-day {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  font: inherit;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  cursor: pointer;
}

.calendar-day.empty {
  border: none;
  background: transparent;
  cursor: default;
}

.calendar-day.today {
  border-color: var(--accent);
  font-weight: 700;
}

.calendar-day.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

.calendar-selection {
  margin-top: 18px;
  color: var(--muted);
}

/* ---------- Shared tool components ---------- */
.tool-panel.left {
  align-items: stretch;
  text-align: left;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
}

.add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.add-form input[type="text"],
.add-form input[type="url"],
.add-form input[type="date"],
.add-form input[type="datetime-local"],
.add-form input[type="number"],
.add-form select,
.add-form textarea {
  flex: 1 1 180px;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.add-form textarea {
  flex-basis: 100%;
  min-height: 84px;
  resize: vertical;
  line-height: 1.5;
}

.item-list {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}

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

.item-title {
  font-weight: 600;
  word-break: break-word;
}

.item-title a {
  color: var(--accent);
  text-decoration: none;
}

.item-title a:hover {
  text-decoration: underline;
}

.item-meta {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 3px;
  word-break: break-word;
}

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

.check {
  width: 22px;
  height: 22px;
  flex: none;
  cursor: pointer;
  accent-color: var(--accent);
}

.icon-action {
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  padding: 2px 8px;
  border-radius: 8px;
}

.icon-action:hover {
  color: var(--waste);
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 20px;
  border: 1px dashed var(--border);
  border-radius: 16px;
}

.subsection {
  font-size: 1.05rem;
  margin: 20px 0 6px;
}

/* Goals progress */
.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  margin-top: 8px;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
}

/* Focus mode */
.focus-input {
  width: 100%;
  max-width: 520px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1.1rem;
  text-align: center;
}

.minutes-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.minutes-label input {
  width: 80px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

/* Journal */
.journal-text {
  width: 100%;
  min-height: 200px;
  resize: vertical;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  line-height: 1.6;
}

/* Habit tracker */
.habit-days {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.habit-day {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.7rem;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.habit-day.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.habit-day.today {
  box-shadow: 0 0 0 2px rgba(22, 93, 74, 0.3);
}

/* Clocks & countdowns */
.clock-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.2rem;
  white-space: nowrap;
}

/* Statistics */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  width: 100%;
}

.stat-card {
  padding: 18px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
}

.stat-label {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* ---------- Home "Today" dashboard ---------- */
.today-header {
  padding: 12px 4px 8px;
}

.today-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.sync-pill {
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
}

.sync-pill.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.today-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.today-card .section-heading h2 {
  font-size: 1.1rem;
}

.today-card .section-heading .back-link {
  margin: 0;
  font-size: 0.85rem;
}

.add-form.compact {
  margin-bottom: 12px;
}

.stat-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 34px;
}

.stat-chip {
  flex: 1 1 140px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid rgba(216, 204, 188, 0.85);
  box-shadow: var(--shadow);
}

.stat-chip-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
}

.stat-chip-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 2px;
}

.tools-section {
  margin-top: 8px;
}

.tools-section .subsection {
  margin: 24px 4px 12px;
}

.home-grid.tight {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.tool-card.compact {
  flex-direction: row;
  align-items: center;
  gap: 14px;
  min-height: 0;
  padding: 16px 18px;
}

.tool-card.compact .tool-icon {
  font-size: 1.6rem;
}

.tool-card.compact h2 {
  font-size: 1.02rem;
}
