:root {
  color-scheme: light;
  --bg: #f3f0fb;
  --bg-strong: #e6e0f4;
  --surface: rgba(250, 248, 255, 0.84);
  --surface-strong: rgba(255, 254, 255, 0.97);
  --panel: rgba(252, 250, 255, 0.92);
  --panel-soft: linear-gradient(180deg, rgba(250, 248, 255, 0.97), rgba(242, 237, 250, 0.92));
  --panel-soft-strong: linear-gradient(180deg, rgba(248, 244, 253, 0.99), rgba(239, 233, 248, 0.94));
  --panel-border: rgba(127, 108, 177, 0.14);
  --text: #251c40;
  --muted: #74688f;
  --accent: #6f35c8;
  --accent-deep: #4f2495;
  --accent-soft: rgba(111, 53, 200, 0.1);
  --accent-line: rgba(111, 53, 200, 0.22);
  --shadow: 0 20px 48px rgba(80, 51, 132, 0.13);
  --success: #327069;
  --danger: #aa3b2f;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans TC", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(149, 117, 223, 0.22), transparent 28%),
    radial-gradient(circle at top right, rgba(120, 94, 196, 0.16), transparent 30%),
    linear-gradient(160deg, var(--bg) 0%, #faf8fe 44%, var(--bg-strong) 100%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.background-glow {
  position: fixed;
  width: 18rem;
  height: 18rem;
  border-radius: 999px;
  filter: blur(30px);
  opacity: 0.45;
  pointer-events: none;
}

.background-glow-left {
  background: rgba(130, 93, 210, 0.34);
  top: 3rem;
  left: -4rem;
}

.background-glow-right {
  background: rgba(171, 132, 239, 0.28);
  top: 8rem;
  right: -5rem;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100vw - 1.5rem));
  margin: 0 auto;
  padding: 1rem 0 1.2rem;
}

.hero {
  display: grid;
  gap: 1.85rem;
  padding: 1.3rem 0.55rem 1.05rem;
}

.hero-copy {
  display: grid;
  gap: 0.15rem;
  padding: 0 0 0 1rem;
  margin-left: 0.1rem;
  max-width: 42rem;
  position: relative;
}

.section-tag {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  color: var(--accent-deep);
  font-weight: 800;
}

.hero-copy::before {
  content: "";
  position: absolute;
  inset: 0.18rem auto 0.18rem 0;
  width: 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(111, 53, 200, 0.92), rgba(161, 115, 229, 0.42));
}

.hero h1,
.section-heading h2 {
  margin: 0;
}

.hero h1 {
  font-size: clamp(2.15rem, 5vw, 3.45rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.sync-status {
  margin: 0;
  padding: 0.75rem 1rem;
  width: fit-content;
  max-width: 100%;
  border-radius: 999px;
  background: rgba(248, 244, 253, 0.92);
  border: 1px solid rgba(127, 108, 177, 0.14);
  color: var(--muted);
  font-size: 0.92rem;
}

.auth-panel {
  display: grid;
  grid-template-columns: minmax(12rem, 0.58fr) minmax(0, 1.42fr);
  gap: 0.7rem;
  align-items: start;
  padding: 1.15rem;
  background:
    linear-gradient(180deg, rgba(252, 250, 255, 0.98), rgba(244, 239, 251, 0.95)),
    linear-gradient(135deg, rgba(111, 53, 200, 0.05), transparent 58%);
  border-color: rgba(111, 53, 200, 0.16);
  box-shadow:
    0 20px 48px rgba(80, 51, 132, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.auth-copy h2 {
  margin: 0;
  font-size: 1.2rem;
}

.auth-help {
  margin: 0.45rem 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.auth-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(15rem, 0.74fr);
  grid-template-areas:
    "email actions"
    "password actions";
  gap: 0.8rem;
  align-items: start;
  justify-self: stretch;
  width: 100%;
}

.auth-field {
  min-width: 0;
}

#auth-email-field {
  grid-area: email;
}

#auth-password-field {
  grid-area: password;
}

.auth-actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  align-self: stretch;
}

.secondary-auth-button {
  background: linear-gradient(180deg, rgba(250, 246, 255, 0.98), rgba(241, 235, 250, 0.94));
}

.auth-button {
  min-width: 0;
  width: 100%;
  min-height: 5.1rem;
}

.auth-session-panel {
  display: grid;
  gap: 0.95rem;
  justify-items: center;
  margin-top: 0.75rem;
}

.auth-user {
  margin: 0;
  font-weight: 700;
  text-align: center;
  width: 100%;
}

#sign-out-button {
  width: min(28rem, 100%);
  min-height: 3.6rem;
  justify-self: center;
}

.hero > .sync-status {
  justify-self: start;
}

#app-content.is-locked {
  opacity: 0.42;
  pointer-events: none;
  user-select: none;
}

.browse-top-grid,
.trends-grid {
  display: grid;
  gap: 1rem;
}

.panel {
  backdrop-filter: blur(16px);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 1.1rem;
  background: var(--panel-soft);
}

.input-summary-panel {
  margin-top: 0.2rem;
  margin-bottom: 1.1rem;
  padding: 0.9rem;
  background: linear-gradient(180deg, rgba(251, 249, 255, 0.98), rgba(242, 237, 250, 0.94));
  border: 1px solid rgba(127, 108, 177, 0.12);
  box-shadow: 0 16px 36px rgba(80, 51, 132, 0.07);
}

.input-summary-heading {
  margin-bottom: 0.7rem;
}

.input-summary-heading .section-tag {
  margin-bottom: 0.12rem;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  background: var(--panel-soft-strong);
}

.page-actions {
  margin-top: 1.2rem;
  padding-left: 1rem;
  padding-right: 1rem;
}

.ghost-button,
.primary-button,
.record-button,
.tab {
  border: none;
  border-radius: 16px;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease, border-color 160ms ease;
}

.ghost-button {
  padding: 0.9rem 1rem;
  background: linear-gradient(180deg, rgba(250, 246, 255, 0.98), rgba(241, 235, 250, 0.94));
  border: 1px solid rgba(127, 108, 177, 0.18);
  color: var(--text);
  font-weight: 600;
}

.ghost-button:hover,
.primary-button:hover,
.record-button:hover {
  transform: translateY(-1px);
}

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

.file-button {
  display: inline-flex;
  align-items: center;
}

.workspace {
  margin-top: 1.2rem;
  padding: 1rem;
  border-radius: 30px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.input-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.summary-chip {
  padding: 0.92rem 1rem 0.88rem;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(252, 250, 255, 0.98), rgba(243, 238, 251, 0.94));
  border: 1px solid rgba(127, 108, 177, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.summary-chip-label {
  margin: 0 0 0.32rem;
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 700;
}

.summary-chip-value {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.35;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.015em;
}

.workspace-input {
  background: linear-gradient(180deg, rgba(249, 246, 255, 0.92), rgba(241, 235, 250, 0.8));
  border: 1px solid rgba(111, 53, 200, 0.12);
}

.workspace-browse {
  background: linear-gradient(180deg, rgba(249, 246, 255, 0.97), rgba(240, 234, 249, 0.84));
  border: 1px solid rgba(127, 108, 177, 0.1);
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.3rem 0.2rem 0;
}

.workspace-header .section-tag {
  margin-bottom: 0.16rem;
}

.workspace-header h2 {
  margin: 0;
  line-height: 1.08;
}

.form-panel {
  margin-top: 1rem;
}

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

.section-heading.compact {
  margin-bottom: 0.8rem;
}

.tab-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tab {
  border: 1px solid rgba(149, 130, 194, 0.18);
  background: rgba(244, 239, 251, 0.96);
  color: #74688f;
  padding: 0.75rem 1rem;
  font-weight: 700;
}

.tab.active {
  background: linear-gradient(180deg, rgba(232, 219, 250, 0.97), rgba(244, 236, 252, 0.99));
  color: var(--accent-deep);
  border-color: rgba(132, 95, 207, 0.28);
  font-weight: 700;
}

.field-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.field-grid > *,
.field-grid-nested > * {
  min-width: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 0.92rem;
}

.field input,
.field select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  border: 1px solid rgba(149, 130, 194, 0.18);
  border-radius: 16px;
  padding: 0.95rem 1rem;
  background: linear-gradient(180deg, rgba(250, 247, 255, 0.98), rgba(242, 237, 250, 0.94));
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.field input[type="date"],
.field input[type="time"] {
  display: block;
  min-inline-size: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-appearance: none;
  appearance: none;
}

.field input[type="date"]::-webkit-date-and-time-value,
.field input[type="time"]::-webkit-date-and-time-value {
  text-align: left;
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(132, 95, 207, 0.22);
  border-color: rgba(132, 95, 207, 0.34);
}

.field input::placeholder {
  color: rgba(123, 111, 154, 0.88);
}

.dose-fieldset {
  gap: 0.7rem;
  margin-bottom: 0.35rem;
}

.dose-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.dose-option {
  position: relative;
  display: block;
  cursor: pointer;
}

.dose-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.dose-option span {
  display: grid;
  place-items: center;
  min-height: 3.35rem;
  padding: 0.9rem 0.5rem;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  background: var(--surface-strong);
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.dose-option input:checked + span {
  background: linear-gradient(135deg, rgba(235, 224, 251, 0.95), rgba(246, 239, 253, 0.98));
  border-color: rgba(132, 95, 207, 0.36);
  color: var(--accent-deep);
}

.dose-option span:hover {
  transform: translateY(-1px);
}

.field-wide {
  grid-column: 1 / -1;
}

.primary-button {
  margin-top: 1rem;
  padding: 0.95rem 1.2rem;
  background: linear-gradient(135deg, #6f35c8 0%, #8b55de 100%);
  color: white;
  font-weight: 700;
  box-shadow: 0 14px 28px rgba(111, 53, 200, 0.22);
}

.primary-button-wide {
  display: block;
  width: min(100%, 28rem);
  margin-left: auto;
  margin-right: auto;
  padding-top: 1.05rem;
  padding-bottom: 1.05rem;
  font-size: 1rem;
}

#medication-form .primary-button-wide {
  margin-top: 1.45rem;
}

.browse-top-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 1rem;
}

.browse-top-grid > .panel,
.trends-grid > .panel {
  position: relative;
  overflow: hidden;
  padding: 1.18rem 1.24rem 1.2rem;
}

.browse-top-grid > .panel::before,
.trends-grid > .panel::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  border-radius: 999px;
  opacity: 0.45;
}

.browse-top-grid > .panel:nth-child(1) {
  background: linear-gradient(180deg, rgba(253, 251, 255, 0.99), rgba(246, 240, 251, 0.96));
  border-color: rgba(149, 130, 194, 0.14);
  box-shadow: 0 10px 26px rgba(80, 51, 132, 0.06);
}

.browse-top-grid > .panel:nth-child(1)::before {
  background: linear-gradient(180deg, rgba(111, 53, 200, 0.88), rgba(171, 132, 239, 0.52));
}

.browse-top-grid > .panel:nth-child(2) {
  background: linear-gradient(180deg, rgba(253, 251, 255, 0.99), rgba(246, 240, 251, 0.96));
  border-color: rgba(149, 130, 194, 0.14);
  box-shadow: 0 10px 26px rgba(80, 51, 132, 0.06);
}

.browse-top-grid > .panel:nth-child(2)::before {
  background: linear-gradient(180deg, rgba(111, 53, 200, 0.88), rgba(171, 132, 239, 0.52));
}

.browse-top-grid > .panel:nth-child(3) {
  background: linear-gradient(180deg, rgba(253, 251, 255, 0.99), rgba(246, 240, 251, 0.96));
  border-color: rgba(149, 130, 194, 0.14);
  box-shadow: 0 10px 26px rgba(80, 51, 132, 0.06);
}

.browse-top-grid > .panel:nth-child(3)::before {
  background: linear-gradient(180deg, rgba(111, 53, 200, 0.88), rgba(171, 132, 239, 0.52));
}

.trends-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1rem;
}

.chart-panel {
  min-height: 22rem;
  background: var(--panel-soft-strong);
}

.trends-grid > .panel:nth-child(1) {
  background: linear-gradient(180deg, rgba(253, 251, 255, 0.99), rgba(246, 240, 251, 0.96));
  border-color: rgba(149, 130, 194, 0.14);
  box-shadow: 0 10px 26px rgba(80, 51, 132, 0.06);
}

.trends-grid > .panel:nth-child(1)::before {
  background: linear-gradient(180deg, rgba(111, 53, 200, 0.88), rgba(171, 132, 239, 0.52));
}

.trends-grid > .panel:nth-child(2) {
  background: linear-gradient(180deg, rgba(253, 251, 255, 0.99), rgba(246, 240, 251, 0.96));
  border-color: rgba(149, 130, 194, 0.14);
  box-shadow: 0 10px 26px rgba(80, 51, 132, 0.06);
}

.trends-grid > .panel:nth-child(2)::before {
  background: linear-gradient(180deg, rgba(111, 53, 200, 0.88), rgba(171, 132, 239, 0.52));
}

.browse-top-grid .section-heading.compact,
.trends-grid .section-heading.compact {
  margin-bottom: 1.02rem;
}

.browse-top-grid .section-tag,
.trends-grid .section-tag {
  margin-bottom: 0.2rem;
  font-size: 0.64rem;
  letter-spacing: 0.2em;
  color: #6f5e8e;
}

.browse-top-grid .section-heading h2,
.trends-grid .section-heading h2 {
  font-size: 1.34rem;
  line-height: 1.08;
  letter-spacing: -0.03em;
  font-weight: 800;
}

.record-list {
  display: grid;
  gap: 0.88rem;
  padding-inline: 0.45rem;
}

.record-card {
  border-radius: 20px;
  padding: 0.96rem 1rem 0.82rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(245, 240, 251, 0.96));
  border: 1px solid rgba(149, 130, 194, 0.13);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.88), 0 6px 14px rgba(80, 51, 132, 0.04);
}

#medication-list .record-card,
#weight-list .record-card,
#labs-list .record-card {
  background: linear-gradient(180deg, rgba(247, 243, 254, 0.99), rgba(237, 230, 248, 0.96));
  border-color: rgba(149, 130, 194, 0.15);
}

#labs-list .record-card-header h3 {
  font-size: 1rem;
  font-weight: 750;
  color: #000;
  letter-spacing: -0.015em;
}

.record-card-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.78rem;
}

.record-card-header-inline-action {
  align-items: flex-start;
}

.record-card-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.62rem;
  flex-shrink: 0;
}

.record-card-header h3 {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.36;
  letter-spacing: -0.01em;
}

.record-card-header strong {
  font-size: 1rem;
  line-height: 1;
  font-weight: 720;
  color: var(--text);
  letter-spacing: -0.015em;
}

#medication-list .record-card-header strong,
#weight-list .record-card-header strong {
  margin-top: 0.16rem;
}

#labs-list .record-card .record-button {
  padding: 0.34rem 0.74rem;
  margin-top: -0.08rem;
}

.lab-metrics {
  display: grid;
  gap: 0.58rem;
  margin-top: 0.1rem;
}

.lab-metric-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.05rem;
}

.lab-metric {
  display: inline-flex;
  align-items: baseline;
  gap: 0.38rem;
  padding: 0.18rem 0;
}

.lab-metric-label {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #7b6e97;
}

.lab-metric-value {
  font-size: 0.98rem;
  font-weight: 680;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: #251c40;
}

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

.record-card p:last-of-type {
  margin-bottom: 0;
}

.record-button {
  padding: 0.32rem 0.68rem;
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

#medication-list .record-button,
#weight-list .record-button,
#labs-list .record-button {
  background: linear-gradient(180deg, rgba(245, 240, 252, 0.98), rgba(235, 227, 248, 0.96));
  border: 1px solid rgba(149, 130, 194, 0.16);
  color: #6f5e8e;
}

.empty-state {
  color: var(--muted);
  min-height: 6rem;
  display: grid;
  place-items: center;
}

canvas {
  width: 100% !important;
  height: auto !important;
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100vw - 1.2rem, 100%);
  }

  .hero {
    gap: 1.35rem;
  }

  .auth-panel {
    grid-template-columns: 1fr;
    padding: 1rem;
  }

  .hero h1 {
    font-size: clamp(2rem, 7.4vw, 2.85rem);
  }

  .workspace-browse {
    display: grid;
    gap: 0.9rem;
  }

  .workspace-browse > .browse-top-grid,
  .workspace-browse > .trends-grid {
    display: contents;
  }

  #medication-records-panel {
    order: 1;
  }

  #weight-records-panel {
    order: 2;
  }

  #weight-trend-panel {
    order: 3;
  }

  #labs-records-panel {
    order: 4;
  }

  #labs-trend-panel {
    order: 5;
  }

  .field-grid,
  .field-grid-nested {
    grid-template-columns: 1fr;
  }

  .browse-top-grid,
  .trends-grid {
    grid-template-columns: 1fr;
    gap: 0.9rem;
  }
}

@media (max-width: 720px) {
  body {
    background:
      radial-gradient(circle at top left, rgba(149, 117, 223, 0.2), transparent 34%),
      radial-gradient(circle at top right, rgba(120, 94, 196, 0.15), transparent 34%),
      linear-gradient(180deg, #f5f1fb 0%, #f0ebf8 42%, #e4ddf0 100%);
  }

  .background-glow {
    width: 12rem;
    height: 12rem;
    filter: blur(24px);
    opacity: 0.35;
  }

  .app-shell {
    width: min(100vw - 1rem, 100%);
    padding: 0.98rem 0 0.85rem;
  }

  .hero {
    gap: 1.05rem;
    padding: 1.38rem 0.2rem 1.14rem;
  }

  .section-tag {
    margin-bottom: 0.3rem;
    font-size: 0.68rem;
    letter-spacing: 0.16em;
  }

  .hero-copy {
    padding-left: 0.82rem;
    margin-left: 0;
    padding-top: 0.12rem;
    padding-bottom: 0.18rem;
  }

  .hero h1 {
    font-size: clamp(1.95rem, 9vw, 2.3rem);
    line-height: 1.1;
  }

  .sync-status {
    width: 100%;
    padding: 0.72rem 0.9rem;
    border-radius: 18px;
    font-size: 0.88rem;
    line-height: 1.45;
  }

  .auth-panel {
    gap: 0.9rem;
    padding: 1rem;
    position: relative;
    overflow: hidden;
  }

  .auth-panel::after {
    content: "";
    position: absolute;
    inset: auto -1.5rem -2.8rem auto;
    width: 7.5rem;
    height: 7.5rem;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(126, 96, 190, 0.13), transparent 68%);
    pointer-events: none;
  }

  .auth-copy h2 {
    font-size: 1.12rem;
  }

  .auth-help {
    font-size: 0.92rem;
    line-height: 1.55;
  }

  .auth-form,
  .auth-session-panel {
    gap: 0.7rem;
  }

  .auth-form {
    grid-template-columns: 1fr;
    grid-template-areas:
      "email"
      "password"
      "actions";
    align-items: stretch;
  }

  .auth-field {
    flex-basis: auto;
  }

  .auth-actions {
    width: 100%;
  }

  .auth-button,
  .auth-session-panel .ghost-button {
    width: 100%;
    min-width: 0;
  }

  .auth-session-panel {
    margin-top: 0.7rem;
    padding-top: 0.78rem;
    padding-bottom: 0.78rem;
  }

  .workspace {
    margin-top: 0.9rem;
    padding: 0.7rem;
    border-radius: 22px;
  }

  .input-summary-panel {
    margin-top: 0.1rem;
    margin-bottom: 0.9rem;
    padding: 0.72rem;
    border-radius: 20px;
  }

  .input-summary-heading {
    margin-bottom: 0.58rem;
  }

  .input-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.62rem;
  }

  .summary-chip {
    min-width: 0;
    padding: 0.82rem 0.78rem 0.8rem;
    border-radius: 18px;
  }

  .summary-chip-label {
    margin-bottom: 0.22rem;
    font-size: 0.72rem;
  }

  .summary-chip-value {
    font-size: 0.9rem;
    line-height: 1.3;
    word-break: break-word;
  }

  .workspace-input {
    background: linear-gradient(180deg, rgba(248, 244, 253, 0.94), rgba(240, 234, 249, 0.8));
  }

  .workspace-browse {
    background: linear-gradient(180deg, rgba(248, 244, 253, 0.96), rgba(239, 232, 248, 0.84));
  }

  .workspace-header {
    margin-bottom: 0.6rem;
    padding: 0.02rem 0.1rem 0.16rem;
  }

  .section-heading {
    flex-direction: column;
    align-items: stretch;
    gap: 0.8rem;
    margin-bottom: 0.85rem;
  }

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

  .panel {
    border-radius: 20px;
  }

  .panel {
    padding: 0.9rem;
  }

  .form-panel {
    margin-top: 0.75rem;
    overflow: hidden;
  }

  .tab-bar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
    padding: 0;
    border-radius: 0;
    background: transparent;
    border: 0;
  }

  .tab {
    padding: 0.72rem 0.55rem;
    border-radius: 14px;
    font-size: 0.9rem;
    text-align: center;
  }

  .data-form {
    padding-top: 0.1rem;
  }

  .field-grid,
  .field-grid-nested {
    grid-template-columns: 1fr;
    gap: 0.72rem;
  }

  .field {
    gap: 0.38rem;
  }

  .field span {
    font-size: 0.88rem;
  }

  .field input,
  .field select {
    min-height: 3.1rem;
    padding: 0.88rem 0.95rem;
    border-radius: 14px;
    font-size: 0.98rem;
  }

  .field input::placeholder {
    color: rgba(123, 111, 154, 0.84);
  }

  .dose-fieldset {
    gap: 0.55rem;
    padding: 0.1rem 0 0;
    margin-bottom: 0.45rem;
  }

  .dose-options {
    gap: 0.38rem;
  }

  .dose-option span {
    min-height: 3rem;
    padding: 0.78rem 0.2rem;
    border-radius: 14px;
    font-size: 0.84rem;
  }

  .primary-button {
    margin-top: 0.85rem;
    padding: 0.95rem 1rem;
    border-radius: 16px;
    font-size: 0.98rem;
  }

  .primary-button-wide {
    width: 100%;
    max-width: none;
    padding-top: 1rem;
    padding-bottom: 1rem;
    box-shadow: 0 12px 24px rgba(111, 53, 200, 0.18);
  }

  #medication-form .primary-button-wide {
    margin-top: 1.6rem;
  }

  .browse-top-grid,
  .trends-grid {
    gap: 0.75rem;
    margin-top: 0.75rem;
  }

  .browse-top-grid > .panel,
  .trends-grid > .panel {
    border-radius: 18px;
  }

  .chart-panel {
    min-height: 0;
  }

  .chart-panel canvas {
    max-height: 16.5rem;
  }

  .chart-panel .section-heading.compact {
    margin-bottom: 0.55rem;
  }

  .empty-state {
    min-height: 4.8rem;
    padding: 0.4rem;
    text-align: center;
    line-height: 1.5;
  }

  .record-list {
    gap: 0.6rem;
  }

  .record-card {
    padding: 0.74rem 0.82rem 0.52rem;
    border-radius: 16px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  }

  .record-card-header {
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.45rem;
  }

  .record-card-header h3 {
    font-size: 0.96rem;
    line-height: 1.4;
  }

  .record-card-header strong {
    font-size: 1.28rem;
    white-space: nowrap;
  }

  .record-card p {
    font-size: 0.9rem;
    line-height: 1.48;
  }

  .record-button {
    min-height: 2.28rem;
    padding: 0.34rem 0.74rem;
    border-radius: 12px;
    font-size: 0.88rem;
  }

  .page-actions {
    margin-top: 0.8rem;
    padding: 0.85rem;
    border-radius: 18px;
  }

  .quick-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .ghost-button,
  .file-button {
    justify-content: center;
    width: 100%;
    min-height: 2.9rem;
  }

  .quick-actions .ghost-button,
  .quick-actions .danger-button {
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(250, 246, 255, 0.98), rgba(241, 235, 250, 0.94));
    border-color: rgba(127, 108, 177, 0.18);
  }
}

@media (max-width: 420px) {
  .app-shell {
    width: min(100vw - 0.7rem, 100%);
  }

  .hero {
    padding-top: 1.08rem;
    padding-bottom: 0.9rem;
  }

  .auth-user {
    font-size: 0.96rem;
    line-height: 1.4;
  }

  .hero h1 {
    font-size: clamp(1.82rem, 9.6vw, 2.08rem);
  }

  .auth-panel {
    padding: 0.88rem;
  }

  .panel {
    border-radius: 18px;
  }

  .panel {
    padding: 0.82rem;
  }

  .tab {
    font-size: 0.86rem;
    padding-left: 0.45rem;
    padding-right: 0.45rem;
  }

  .dose-option span {
    font-size: 0.79rem;
  }

  .record-card-header {
    flex-direction: column;
  }

  .record-card-header strong {
    white-space: normal;
    font-size: 1.16rem;
  }
}
