:root {
  color-scheme: light;
  --bg: #eef2f3;
  --paper: #fbfbf8;
  --ink: #17201c;
  --muted: #67736f;
  --line: #dce2df;
  --green: #24745a;
  --green-soft: #dff0e8;
  --yellow: #f4c95d;
  --red: #c96b5c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: .65;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.phone {
  width: min(100%, 430px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--paper);
  box-shadow: 0 0 30px rgba(30, 40, 36, .12);
}

.view {
  min-height: 100vh;
  padding: 20px;
}

.hidden {
  display: none !important;
}

.brand {
  display: grid;
  gap: 4px;
  padding: 42px 0 26px;
}

.brand span {
  font-size: 34px;
  font-weight: 800;
}

.brand small,
.topbar small {
  color: var(--muted);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.tabs button.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.panel,
.content-section,
.date-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.panel {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.primary {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
  font-weight: 700;
}

.danger {
  border-color: #efd6d1;
  background: #fff4f2;
  color: var(--red);
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.ghost {
  padding: 0 14px;
  background: transparent;
}

.message {
  min-height: 21px;
  margin: 12px 0;
  color: var(--red);
  font-size: 13px;
}

.message.ok {
  color: var(--green);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 16px;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: 22px;
}

.date-panel {
  padding: 12px;
}

.date-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  position: relative;
}

.date-actions button {
  font-size: 13px;
}

.date-rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 58px;
  gap: 8px;
  overflow-x: auto;
  padding-top: 12px;
}

.date-item {
  display: grid;
  gap: 4px;
  grid-template-rows: auto auto auto 8px;
  min-height: 72px;
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: center;
}

.date-item.active {
  border-color: var(--green);
  background: var(--green-soft);
}

.date-item strong {
  font-size: 20px;
}

.date-item span {
  color: var(--muted);
  font-size: 12px;
}

.date-markers {
  display: flex;
  justify-content: center;
  gap: 4px;
  min-height: 8px;
}

.marker {
  width: 7px;
  height: 7px;
  border-radius: 999px;
}

.marker.outstanding {
  background: var(--red);
}

.marker.journal {
  border: 1px solid var(--green);
  background: var(--green-soft);
}

.calendar-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.calendar-head {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.calendar-head strong {
  text-align: center;
  text-transform: capitalize;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-weekdays {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.calendar-day {
  display: grid;
  gap: 2px;
  grid-template-rows: 22px 8px;
  min-height: 42px;
  padding: 5px 2px;
  border-radius: 8px;
  text-align: center;
}

.calendar-day.muted {
  color: var(--muted);
  opacity: .55;
}

.calendar-day.active {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--ink);
  font-weight: 800;
}

.content-section {
  margin-top: 14px;
  padding: 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-head h2 {
  margin: 0;
  font-size: 17px;
}

.section-head span {
  color: var(--muted);
  font-size: 13px;
}

.list {
  display: grid;
  gap: 8px;
}

.item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--green);
}

.item-body {
  flex: 1;
  min-width: 0;
}

.item-title {
  font-weight: 700;
}

.item-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.group-title {
  margin: 8px 0 0;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
}

.empty {
  padding: 12px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
}

.journal-form {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.quick-form {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.quick-form:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.quick-form summary {
  cursor: pointer;
  font-weight: 700;
}

.quick-form form {
  display: grid;
  gap: 8px;
  padding-top: 10px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
}

.form-row button {
  padding: 0 14px;
}

@media (max-width: 360px) {
  .view {
    padding: 14px;
  }

  .date-actions {
    grid-template-columns: 1fr 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}
