:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  --ink: #24231f;
  --muted: #706e66;
  --surface: #fffdf8;
  --line: #dedbd2;
  --background: #f4f1ea;
  --green: #2f6f57;
  --green-soft: #e4efe9;
  --blue: #395f82;
  --blue-dark: #294763;
  --amber: #d18835;
  --amber-dark: #9a5c1c;
  --danger: #a33b36;
  -webkit-tap-highlight-color: transparent;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--background);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 100% 0%, rgb(255 255 255 / 72%) 0, transparent 28rem),
    var(--background);
  overscroll-behavior-y: none;
}

button,
textarea {
  font: inherit;
}

button {
  touch-action: manipulation;
}

button:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgb(47 111 87 / 38%);
  outline-offset: 3px;
}

.app-shell {
  width: min(100%, 680px);
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(22px + env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom));
}

.app-header,
.section-heading,
.history-actions,
.note-meta,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.app-header > div {
  display: contents;
}

.app-header .eyebrow {
  grid-row: 1;
  grid-column: 1;
  align-self: center;
}

.app-header h1 {
  grid-row: 2;
  grid-column: 1 / -1;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 760;
  letter-spacing: 0.095em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.75rem, 8vw, 2.35rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
}

.privacy-chip {
  grid-row: 1;
  grid-column: 2;
  flex: none;
  padding: 8px 11px;
  border: 1px solid #b9d1c5;
  border-radius: 999px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 0.78rem;
  font-weight: 700;
}

.privacy-chip span {
  margin-right: 4px;
  font-size: 0.55rem;
  vertical-align: 1px;
}

.privacy-note {
  margin: 13px 0 0;
  padding: 12px 14px;
  border: 1px solid #c8d9d0;
  border-radius: 14px;
  color: #3f5b4e;
  background: #edf5f1;
  font-size: 0.83rem;
  line-height: 1.4;
}

.last-taken {
  display: grid;
  grid-template-columns: 1fr 1px 1fr 1px 1fr;
  gap: 14px;
  margin: 22px 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgb(255 253 248 / 74%);
  box-shadow: 0 8px 24px rgb(68 61 43 / 4%);
}

.last-item {
  min-width: 0;
}

.last-item strong,
.last-label {
  display: block;
}

.last-item strong {
  overflow: hidden;
  margin-top: 4px;
  font-size: 0.96rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.last-label {
  color: var(--muted);
  font-size: 0.72rem;
}

.last-divider {
  width: 1px;
  background: var(--line);
}

.composer {
  margin-bottom: 14px;
}

.composer label {
  display: block;
  margin: 0 0 8px 2px;
  font-size: 0.86rem;
  font-weight: 700;
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 68px;
  resize: vertical;
  padding: 13px 14px;
  border: 1px solid #cbc8be;
  border-radius: 15px;
  color: var(--ink);
  background: var(--surface);
  font-size: 1rem;
  line-height: 1.35;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 75%);
}

.composer textarea::placeholder {
  color: #9a978f;
}

.note-meta {
  margin: 6px 2px 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.medicine-actions {
  display: grid;
  gap: 12px;
}

.medicine-button {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  width: 100%;
  min-height: 104px;
  overflow: hidden;
  padding: 18px 20px;
  border: 0;
  border-radius: 20px;
  color: white;
  text-align: left;
  box-shadow: 0 9px 21px rgb(39 44 41 / 15%), inset 0 1px 0 rgb(255 255 255 / 18%);
  transition: transform 90ms ease, filter 90ms ease, box-shadow 90ms ease;
}

.medicine-button::after {
  position: absolute;
  top: -54px;
  right: -22px;
  width: 160px;
  height: 160px;
  border: 1px solid rgb(255 255 255 / 11%);
  border-radius: 50%;
  background: rgb(255 255 255 / 5%);
  content: "";
}

.medicine-button:active {
  transform: scale(0.985);
  filter: brightness(0.96);
  box-shadow: 0 4px 12px rgb(39 44 41 / 18%), inset 0 1px 0 rgb(255 255 255 / 16%);
}

.medicine-button:disabled {
  opacity: 0.72;
}

.medicine-button.ibuprofen {
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
}

.medicine-button.doliprane {
  background: linear-gradient(135deg, var(--amber), var(--amber-dark));
}

.medicine-button.aspirine {
  background: linear-gradient(135deg, #8f5964, #653c46);
}

.medicine-name,
.medicine-dose,
.tap-hint {
  position: relative;
  z-index: 1;
}

.medicine-name {
  font-size: 1.43rem;
  font-weight: 780;
  letter-spacing: -0.025em;
}

.medicine-dose {
  grid-row: 1 / span 2;
  grid-column: 2;
  padding: 8px 11px;
  border: 1px solid rgb(255 255 255 / 23%);
  border-radius: 999px;
  background: rgb(255 255 255 / 12%);
  font-size: 0.92rem;
  font-weight: 720;
}

.tap-hint {
  align-self: start;
  margin-top: 4px;
  color: rgb(255 255 255 / 72%);
  font-size: 0.73rem;
}

.location-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 13px 0 27px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
  text-align: center;
}

.location-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7a9e89;
  box-shadow: 0 0 0 3px #dfe9e3;
}

.location-status.is-loading .location-dot {
  animation: pulse 1s infinite alternate;
}

.location-status.is-error .location-dot {
  background: #bc625c;
  box-shadow: 0 0 0 3px #f1dcda;
}

@keyframes pulse {
  to {
    opacity: 0.35;
  }
}

.history-section {
  padding: 19px 17px 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgb(66 59 41 / 6%);
}

.entry-count {
  flex: none;
  color: var(--muted);
  font-size: 0.75rem;
}

.empty-state {
  padding: 25px 0 14px;
  color: var(--muted);
  text-align: center;
}

.empty-state p {
  margin: 10px 0 0;
  font-size: 0.86rem;
}

.empty-icon {
  display: grid;
  width: 34px;
  height: 34px;
  margin: 0 auto;
  place-items: center;
  border-radius: 50%;
  color: var(--green);
  background: var(--green-soft);
  font-weight: 800;
}

.history-list {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.history-entry {
  display: grid;
  grid-template-columns: 11px 1fr auto;
  gap: 10px;
  padding: 13px 0;
  border-top: 1px solid #ebe8df;
}

.history-entry:first-child {
  border-top: 0;
}

.entry-color {
  width: 9px;
  height: 9px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--blue);
}

.history-entry[data-medicine="Doliprane"] .entry-color {
  background: var(--amber);
}

.history-entry[data-medicine="Aspirine"] .entry-color {
  background: #8f5964;
}

.entry-main {
  min-width: 0;
}

.entry-title {
  margin: 0;
  font-size: 0.93rem;
  line-height: 1.3;
}

.entry-title strong {
  font-weight: 760;
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 9px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.71rem;
}

.entry-meta a {
  color: var(--green);
  font-weight: 650;
  text-decoration: none;
}

.entry-note {
  margin: 7px 0 0;
  color: #4f4d47;
  font-size: 0.81rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.delete-entry {
  align-self: start;
  padding: 3px 4px;
  border: 0;
  color: #9a978f;
  background: transparent;
  font-size: 1.15rem;
  line-height: 1;
}

.history-actions {
  margin-top: 10px;
  padding-top: 14px;
  border-top: 1px solid #ebe8df;
}

.secondary-button,
.danger-button,
.text-button {
  min-height: 42px;
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 0.82rem;
  font-weight: 700;
}

.secondary-button {
  border: 1px solid #c7c3b8;
  color: var(--ink);
  background: #f8f6f0;
}

.text-button {
  border: 0;
  background: transparent;
}

.danger {
  color: var(--danger);
}

.danger-button {
  border: 0;
  color: white;
  background: var(--danger);
}

.medical-note {
  max-width: 480px;
  margin: 16px auto 0;
  color: #85827a;
  font-size: 0.67rem;
  line-height: 1.4;
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 10;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(calc(100% - 32px), 500px);
  margin: 0 auto;
  padding: 13px 14px 13px 16px;
  border-radius: 16px;
  color: white;
  background: #272822;
  box-shadow: 0 14px 38px rgb(0 0 0 / 24%);
  animation: toast-in 180ms ease-out;
}

.toast[hidden] {
  display: none;
}

.toast div,
.toast strong,
.toast span {
  display: block;
}

.toast strong {
  font-size: 0.9rem;
}

.toast span {
  margin-top: 2px;
  color: rgb(255 255 255 / 66%);
  font-size: 0.72rem;
}

.toast button {
  padding: 9px 10px;
  border: 0;
  color: #bce8cf;
  background: transparent;
  font-weight: 800;
}

@keyframes toast-in {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
}

dialog {
  width: min(calc(100% - 38px), 390px);
  padding: 0;
  border: 0;
  border-radius: 20px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 22px 70px rgb(0 0 0 / 30%);
}

dialog::backdrop {
  background: rgb(35 34 30 / 48%);
  backdrop-filter: blur(2px);
}

dialog form {
  padding: 22px;
}

dialog h2 {
  margin: 0 0 8px;
}

dialog p {
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

noscript {
  display: block;
  padding: 20px;
  color: var(--danger);
  text-align: center;
}

@media (min-width: 560px) {
  .app-shell {
    padding-right: 26px;
    padding-left: 26px;
  }

  .medicine-actions {
    grid-template-columns: repeat(3, 1fr);
  }

  .medicine-button {
    min-height: 122px;
    grid-template-columns: 1fr;
  }

  .medicine-dose {
    grid-row: auto;
    grid-column: auto;
    justify-self: start;
    margin-top: 7px;
  }

  .tap-hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
