:root {
  color-scheme: light;
  --paper: #f7f9ff;
  --surface: #ffffff;
  --ink: #1d2740;
  --muted: #69738b;
  --line: #dbe2f4;
  --accent: #7d63f1;
  --accent-strong: #4a3fd6;
  --teal: #236ed8;
  --amber: #59a5ff;
  --shadow: 0 18px 50px rgba(31, 44, 108, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 12%, rgba(89, 165, 255, 0.48), transparent 24rem),
    radial-gradient(circle at 82% 6%, rgba(125, 99, 241, 0.44), transparent 28rem),
    linear-gradient(145deg, #2d6fd6 0%, #4735d4 48%, #3128a6 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 20px clamp(14px, 3vw, 28px) 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 20;
  max-width: min(92vw, 420px);
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 16px 36px rgba(38, 50, 56, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -16px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  color: #ffffff;
  font-size: clamp(1.9rem, 7vw, 3.25rem);
  letter-spacing: 0;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 800;
  box-shadow: 0 8px 22px rgba(69, 53, 35, 0.08);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.summary-strip article {
  min-width: 0;
  padding: 16px 12px;
  border: 1px solid rgba(255, 255, 255, 0.66);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 34px rgba(31, 44, 108, 0.16);
}

.summary-strip span {
  display: block;
  color: var(--accent-strong);
  font-size: clamp(1.5rem, 7vw, 2.3rem);
  font-weight: 900;
  line-height: 1;
}

.summary-strip small {
  color: var(--muted);
  font-weight: 700;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
}

.tab {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tab.active {
  background: linear-gradient(135deg, #236ed8 0%, #4a3fd6 100%);
  color: #fff;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hidden {
  display: none !important;
}

.record-form,
#calendarView,
#historyView {
  padding: clamp(16px, 4vw, 26px);
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading h2 {
  margin-bottom: 5px;
  font-size: 1.35rem;
}

.section-heading p,
.hint {
  margin-bottom: 0;
  color: var(--muted);
}

label,
fieldset {
  display: block;
  margin: 0 0 16px;
}

fieldset {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

legend,
label > span,
.range-field span {
  color: #33405f;
  font-size: 0.92rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 8px;
  border: 1px solid #dbe2f4;
  border-radius: 8px;
  background: #fbfcff;
  color: var(--ink);
  outline: 0;
}

input {
  min-height: 46px;
  padding: 0 12px;
}

select {
  min-height: 46px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 92px;
  padding: 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(35, 110, 216, 0.16);
}

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

.time-selects,
.date-selects,
.weather-selects {
  display: block;
}

.time-picker-trigger,
.date-picker-trigger,
.weather-picker-trigger {
  width: 100%;
  min-height: 46px;
  margin-top: 8px;
  border: 1px solid #dbe2f4;
  border-radius: 8px;
  background: #fbfcff;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 900;
}

.time-picker-layer,
.date-picker-layer,
.weather-picker-layer {
  position: absolute;
  z-index: 35;
}

.time-picker-dialog,
.date-picker-dialog,
.weather-picker-dialog {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcff;
  box-shadow: 0 18px 44px rgba(31, 44, 108, 0.2);
}

.time-picker-wheels,
.date-picker-wheels,
.weather-picker-wheels {
  position: relative;
  display: grid;
  gap: 10px;
  height: 190px;
  overflow: hidden;
}

.time-picker-wheels {
  grid-template-columns: 1fr 1fr;
}

.date-picker-wheels {
  grid-template-columns: 1.3fr 1fr 1fr;
}

.weather-picker-wheels {
  grid-template-columns: 1fr;
}

.time-picker-wheels::before,
.time-picker-wheels::after,
.date-picker-wheels::before,
.date-picker-wheels::after,
.weather-picker-wheels::before,
.weather-picker-wheels::after {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 1;
  height: 1px;
  background: #d9e1f6;
  content: "";
}

.time-picker-wheels::before,
.date-picker-wheels::before,
.weather-picker-wheels::before {
  top: 74px;
}

.time-picker-wheels::after,
.date-picker-wheels::after,
.weather-picker-wheels::after {
  top: 116px;
}

.time-wheel,
.date-wheel,
.weather-wheel {
  display: grid;
  gap: 4px;
  align-content: start;
  overflow-y: auto;
  padding: 74px 0;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}

.time-wheel::-webkit-scrollbar,
.date-wheel::-webkit-scrollbar,
.weather-wheel::-webkit-scrollbar {
  display: none;
}

.time-option,
.date-option,
.weather-option {
  min-height: 38px;
  border: 0;
  background: transparent;
  color: rgba(29, 39, 64, 0.3);
  font-size: 1.22rem;
  font-weight: 800;
  scroll-snap-align: center;
}

.time-option.near,
.date-option.near,
.weather-option.near {
  color: rgba(29, 39, 64, 0.46);
}

.time-option.selected,
.date-option.selected,
.weather-option.selected {
  color: var(--accent-strong);
  font-size: 1.48rem;
}

.time-picker-actions,
.date-picker-actions,
.weather-picker-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.time-cancel,
.time-confirm,
.date-cancel,
.date-confirm,
.weather-cancel,
.weather-confirm {
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 900;
}

.time-cancel,
.date-cancel,
.weather-cancel {
  background: #e5e5e5;
  color: #222;
}

.time-confirm,
.date-confirm,
.weather-confirm {
  background: linear-gradient(135deg, #236ed8 0%, #4a3fd6 100%);
  color: #fff;
}

.range-field input {
  accent-color: var(--accent);
  padding: 0;
}

.body-map-layout {
  display: grid;
  grid-template-columns: minmax(190px, 280px) 1fr;
  align-items: center;
  gap: 20px;
}

.head-map {
  width: 100%;
  max-width: 280px;
}

.head-base {
  fill: url(#skinGradient);
  stroke: #866b58;
  stroke-width: 3;
}

.neck-base {
  fill: #e9b38f;
  stroke: rgba(134, 107, 88, 0.55);
  stroke-width: 2;
}

.ear-base {
  fill: #eab894;
  stroke: rgba(134, 107, 88, 0.72);
  stroke-linejoin: round;
  stroke-width: 2.5;
  pointer-events: none;
}

.head-region {
  fill: rgba(255, 255, 255, 0.16);
  stroke: rgba(114, 84, 65, 0.6);
  stroke-width: 1.5;
  cursor: pointer;
  transition: fill 0.16s ease, opacity 0.16s ease;
}

.head-region:hover {
  fill: rgba(125, 99, 241, 0.24);
}

.head-region.selected {
  fill: rgba(125, 99, 241, 0.52);
}

.face-line {
  fill: none;
  stroke: #674f42;
  stroke-linecap: round;
  stroke-width: 4;
  pointer-events: none;
}


.selected-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.selected-tags span {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: #eef3ff;
  color: var(--teal);
  font-size: 0.88rem;
  font-weight: 800;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.switch-row input {
  width: 22px;
  min-height: 22px;
  margin: 0;
  accent-color: var(--teal);
}

.medicine-options.hidden,
.medicine-name.hidden {
  display: none;
}

.medicine-note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.medicine-grid,
.option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.medicine-grid label,
.option-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  color: #33405f;
  font-size: 0.9rem;
  font-weight: 800;
}

.medicine-grid label:has(input:checked),
.option-grid label:has(input:checked) {
  border-color: rgba(74, 63, 214, 0.42);
  background: #eef3ff;
  color: var(--teal);
}

.medicine-grid input,
.option-grid input {
  width: 18px;
  min-height: 18px;
  margin: 0;
  accent-color: var(--teal);
}

.primary-action {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #236ed8 0%, #4a3fd6 100%);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 12px 24px rgba(74, 63, 214, 0.22);
}

.confirm-layer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(29, 39, 64, 0.34);
}

.confirm-dialog {
  width: min(100%, 360px);
  padding: 18px;
  border-radius: 8px;
  background: #fbfcff;
  box-shadow: 0 20px 54px rgba(31, 44, 108, 0.22);
}

.confirm-dialog h3 {
  margin-bottom: 6px;
  font-size: 1.12rem;
}

.confirm-dialog p {
  margin-bottom: 16px;
  color: var(--muted);
}

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

.secondary-action,
.danger-action {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 900;
}

.secondary-action {
  border: 1px solid var(--line);
  background: #fbfcff;
  color: var(--ink);
}

.danger-action {
  border: 0;
  background: #d84b63;
  color: #fff;
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.calendar-toolbar strong {
  font-size: 1.15rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
}

.weekday-row {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-align: center;
}

.day-cell {
  position: relative;
  display: block;
  min-height: 68px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  color: var(--ink);
}

.day-number {
  display: inline-block;
  min-width: 1.5em;
  font-weight: 700;
  line-height: 1;
}

.day-cell.muted {
  opacity: 0.35;
}

.day-cell.today {
  border-color: var(--teal);
}

.day-cell.selected-day {
  border-color: var(--accent-strong);
  box-shadow: inset 0 0 0 2px var(--accent-strong);
}

.day-cell.has-record {
  background: #eef3ff;
}

.day-cell.heat-2 {
  background: #dfe8ff;
}

.day-cell.heat-3 {
  background: #c9d8ff;
}

.day-cell .count-dot {
  position: absolute;
  right: 7px;
  bottom: 7px;
  min-width: 30px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, #236ed8 0%, #4a3fd6 100%);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 900;
  line-height: 22px;
  text-align: center;
}

.month-detail {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.month-detail article {
  padding: 12px;
  border-radius: 8px;
  background: #f1f5ff;
}

.month-detail strong {
  display: block;
  font-size: 1.4rem;
}

.month-detail span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.day-detail {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.day-detail-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.day-detail-heading h3 {
  margin: 0;
  font-size: 1.08rem;
}

.day-detail-heading span {
  color: var(--muted);
  font-weight: 800;
}

.day-record-list {
  display: grid;
  gap: 10px;
}

.day-record-list article {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.day-record-list time {
  color: var(--teal);
  font-size: 0.86rem;
  font-weight: 900;
}

.day-record-list strong {
  color: var(--ink);
}

.day-record-list span,
.day-record-list p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.search-field {
  margin-bottom: 14px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.history-item time {
  color: var(--teal);
  font-size: 0.86rem;
  font-weight: 900;
}

.history-item h3 {
  margin: 4px 0;
  font-size: 1rem;
}

.history-item p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.delete-button {
  flex: 0 0 auto;
  min-height: 36px;
  border: 1px solid #ffd1d8;
  border-radius: 8px;
  background: #fff3f6;
  color: #d84b63;
  font-weight: 800;
}

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

@media (max-width: 680px) {
  .summary-strip,
  .field-grid,
  .body-map-layout,
  .month-detail {
    grid-template-columns: 1fr;
  }

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

  .summary-strip article {
    padding: 12px 8px;
  }

  .summary-strip small {
    font-size: 0.72rem;
  }

  .day-cell {
    min-height: 54px;
    padding: 9px;
  }

  .day-cell .count-dot {
    right: 4px;
    bottom: 4px;
    min-width: 24px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.62rem;
    line-height: 18px;
  }

  .history-item {
    flex-direction: column;
  }

  .delete-button {
    width: 100%;
  }

  .medicine-grid,
  .option-grid {
    grid-template-columns: 1fr;
  }
}
