:root {
  --bg: #f4f1ea;
  --card: #fffdf8;
  --ink: #1c1915;
  --muted: #6d675e;
  --line: #e4ddd2;
  --green: #1f3d36;
  --green-2: #2f6f5e;
  --danger: #9c3b2e;
  --shadow: 0 10px 30px rgba(40, 32, 20, 0.08);
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(900px 420px at 10% -10%, #efe4cf 0%, transparent 55%),
    var(--bg);
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.app {
  width: min(480px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 8px;
}
.top h1 { margin: 0; font-size: 1.55rem; letter-spacing: -0.03em; }
.top p { margin: 2px 0 0; color: var(--muted); font-size: 0.92rem; }

.icon-btn, .primary, .ghost, .danger {
  border: 0;
  border-radius: 999px;
}
.icon-btn {
  width: 42px;
  height: 42px;
  background: var(--green);
  color: white;
  font-size: 1.4rem;
  line-height: 1;
}
.primary, .ghost, .danger {
  padding: 12px 16px;
  font-weight: 600;
}
.primary { background: var(--green); color: white; }
.ghost { background: transparent; border: 1px solid var(--line); }
.danger { background: transparent; color: var(--danger); }

.main { padding: 8px 16px 24px; flex: 1; }
.card, .row, .sheet {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.empty {
  margin-top: 28px;
  padding: 28px 22px;
  text-align: center;
}
.empty h2 { margin: 0 0 8px; font-size: 1.35rem; }
.empty p { margin: 0 0 18px; color: var(--muted); line-height: 1.45; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; }
.chip {
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 8px 12px;
  white-space: nowrap;
}
.chip.is-on { background: var(--green); color: white; border-color: var(--green); }

.msg {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 14px 2px;
}
.msg strong { display: block; }
.msg span, .meta { color: var(--muted); font-size: 0.92rem; }
.msg em { font-style: normal; font-weight: 600; }
.msg.is-read em { font-weight: 500; color: var(--muted); }

.reader h2 { margin: 8px 0; font-size: 1.3rem; }
.frame {
  width: 100%;
  min-height: 240px;
  border: 0;
  background: white;
  border-radius: 12px;
}
.plain { white-space: pre-wrap; line-height: 1.5; }

.tabs {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(480px, 100%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(244, 241, 234, 0.94);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.tabs button {
  border: 0;
  background: transparent;
  border-radius: 12px;
  padding: 8px 4px;
  color: var(--muted);
  font-weight: 600;
}
.tabs button.is-on { background: white; color: var(--green); }

.sheet-wrap {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 21, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 5;
}
.sheet {
  width: min(480px, 100%);
  border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 92dvh;
  overflow: auto;
}
.providers { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }
label { display: block; font-size: 0.86rem; color: var(--muted); margin: 10px 0 4px; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 12px;
  padding: 12px;
}
textarea { min-height: 120px; resize: vertical; }
.hint { color: var(--muted); font-size: 0.9rem; line-height: 1.4; }
.error { color: var(--danger); font-size: 0.92rem; }
.actions { display: flex; gap: 8px; margin-top: 14px; }
.actions > * { flex: 1; }
.hidden { display: none !important; }
.person, .event {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 8px; }
.cal-grid span, .cal-grid button {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
}
.cal-grid button.has { background: #e7f2ee; color: var(--green); font-weight: 700; }
.cal-grid button.is-on { background: var(--green); color: white; }
.dow { color: var(--muted); font-size: 0.75rem; }
