:root {
  color-scheme: light;
  --paper: #f7f4ed;
  --surface: #fffdf8;
  --ink: #1f2523;
  --muted: #67706c;
  --line: #ded8cc;
  --green: #2f5d50;
  --green-2: #d8e8df;
  --gold: #f0c765;
  --coral: #df765f;
  --blue: #679fb2;
  --shadow: 0 16px 35px rgba(43, 49, 45, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
}

body {
  overflow-x: hidden;
}

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: env(safe-area-inset-top) 0 calc(78px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 18px 12px;
  background: rgba(247, 244, 237, 0.92);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(222, 216, 204, 0.62);
}

.brand {
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 27px;
  line-height: 1.05;
  font-weight: 760;
  letter-spacing: 0;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.icon-button,
.primary-action,
.secondary-action,
.tiny-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 8px;
  transition: transform 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.icon-button {
  width: 46px;
  color: white;
  background: var(--green);
  box-shadow: var(--shadow);
}

.icon-button svg,
.tab svg,
.tool-button svg,
.empty svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.icon-button:active,
.primary-action:active,
.secondary-action:active,
.tiny-action:active {
  transform: translateY(1px);
}

.main {
  width: min(100%, 820px);
  margin: 0 auto;
  padding: 14px 16px 28px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0 10px;
}

.section-head h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.section-head span {
  color: var(--muted);
  font-size: 13px;
}

.today-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 4px;
}

.metric {
  min-height: 78px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric strong {
  display: block;
  font-size: 24px;
  line-height: 1;
}

.metric span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.task-list,
.people-list,
.idea-list,
event-list,
.log-list {
  display: grid;
  gap: 10px;
}

.reminder-action {
  width: 100%;
  margin-bottom: 10px;
}

.task,
.person-card,
.idea,
.event-card,
.log-card,
.profile-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(43, 49, 45, 0.05);
}

.task,
.person-card,
.idea,
.event-card,
.log-card {
  padding: 14px;
}

.task {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
}

.task-date {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--green);
  background: var(--green-2);
  font-weight: 760;
  font-size: 13px;
  text-align: center;
  line-height: 1.05;
}

.task h3,
.person-card h3,
.idea h3,
.event-card h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.task p,
.person-card p,
.idea p,
.event-card p,
.log-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.task-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tool-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--ink);
  background: #f2eee5;
}

.tool-button.done {
  color: white;
  background: var(--green);
}

.person-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--green);
  font-weight: 780;
}

.avatar.coral {
  background: var(--coral);
}

.avatar.blue {
  background: var(--blue);
}

.avatar.gold {
  color: #332c12;
  background: var(--gold);
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.pill {
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--green);
  background: var(--green-2);
  font-size: 12px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.search-row {
  display: flex;
  gap: 8px;
  margin: 10px 0 14px;
}

.search-row input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.profile-panel {
  overflow: hidden;
}

.profile-hero {
  padding: 18px;
  color: white;
  background: var(--green);
}

.profile-hero .avatar {
  width: 58px;
  height: 58px;
  margin-bottom: 12px;
  color: var(--green);
  background: #fff7df;
}

.profile-hero h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.profile-hero p {
  margin: 6px 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
}

.profile-body {
  padding: 16px;
}

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.fact {
  padding: 12px;
  border-radius: 8px;
  background: #f3efe6;
}

.fact span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.fact strong {
  display: block;
  margin-top: 3px;
  font-size: 14px;
  overflow-wrap: anywhere;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 44px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefb;
  color: var(--ink);
}

.field textarea {
  min-height: 84px;
  resize: vertical;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.primary-action,
.secondary-action,
.tiny-action {
  gap: 8px;
  padding: 0 14px;
  font-weight: 700;
}

.primary-action {
  color: white;
  background: var(--green);
}

.secondary-action {
  color: var(--green);
  background: var(--green-2);
}

.tiny-action {
  min-height: 36px;
  color: var(--ink);
  background: #f2eee5;
  font-size: 13px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: end;
  background: rgba(31, 37, 35, 0.32);
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: 100%;
  max-height: min(86vh, 780px);
  overflow: auto;
  padding: 16px;
  background: var(--paper);
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -18px 40px rgba(31, 37, 35, 0.18);
}

.modal-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-title h2 {
  margin: 0;
  font-size: 20px;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 253, 248, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.tab {
  min-height: 54px;
  display: grid;
  place-items: center;
  gap: 2px;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
}

.tab.active {
  color: var(--green);
  background: var(--green-2);
}

.empty {
  min-height: 180px;
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.empty svg {
  width: 30px;
  height: 30px;
  color: var(--green);
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(86px + env(safe-area-inset-bottom));
  z-index: 50;
  display: none;
  padding: 12px 14px;
  color: white;
  background: var(--green);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 14px;
}

.toast.show {
  display: block;
}

@media (min-width: 760px) {
  .app-shell {
    padding-bottom: 28px;
  }

  .topbar {
    padding-left: max(22px, calc((100vw - 820px) / 2));
    padding-right: max(22px, calc((100vw - 820px) / 2));
  }

  .main {
    padding-top: 22px;
  }

  .tabbar {
    top: 96px;
    right: auto;
    bottom: auto;
    left: calc((100vw - 960px) / 2 + 18px);
    width: 94px;
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
  }

  .modal-backdrop {
    align-items: center;
    justify-content: center;
    padding: 20px;
  }

  .modal {
    max-width: 560px;
    border-radius: 10px;
  }
}

@media (max-width: 380px) {
  .topbar {
    padding-left: 14px;
    padding-right: 14px;
  }

  .main {
    padding-left: 12px;
    padding-right: 12px;
  }

  .today-strip {
    grid-template-columns: 1fr;
  }

  .split,
  .profile-grid {
    grid-template-columns: 1fr;
  }
}
