/* Buttons */
.m3-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 24px; border: 0; border-radius: var(--md-sys-shape-corner-full);
  font: 500 .875rem/1.25rem var(--md-ref-typeface-plain); letter-spacing: .1px;
  text-decoration: none; cursor: pointer;
  overflow: hidden;
  box-sizing: border-box;
}
.m3-btn:has(.m3-icon) { padding-inline: 16px 24px; }
.m3-btn--filled   { background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); }
.m3-btn--tonal    { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.m3-btn--outlined { background: transparent; color: var(--md-sys-color-primary); border: 1px solid var(--md-sys-color-outline); }
.m3-btn--text     { background: transparent; color: var(--md-sys-color-primary); padding-inline: 12px; }

.m3-state::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: currentColor; opacity: 0;
  transition: opacity var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}
.m3-state:hover::after        { opacity: var(--md-sys-state-hover); }
.m3-state:focus-visible::after{ opacity: var(--md-sys-state-focus); }
.m3-state:active::after       { opacity: var(--md-sys-state-pressed); }
.m3-state:focus-visible { outline: 3px solid var(--md-sys-color-secondary); outline-offset: 2px; }
.m3-btn[disabled] { opacity: .38; pointer-events: none; }

.m3-icon {
  font-family: 'Material Symbols Rounded', sans-serif;
  font-weight: normal; font-style: normal;
  font-size: 20px; line-height: 1; letter-spacing: normal;
  text-transform: none; display: inline-block; white-space: nowrap;
  word-wrap: normal; direction: ltr; font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
}

/* Card */
.m3-card {
  border-radius: var(--md-sys-shape-corner-medium);
  padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
  box-sizing: border-box;
}
.m3-card--filled { background: var(--md-sys-color-surface-container-highest); border: none; }
.m3-card--outlined { background: var(--md-sys-color-surface); border: 1px solid var(--md-sys-color-outline-variant); }
.m3-card--elevated { background: var(--md-sys-color-surface-container-low); box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px 1px rgba(0,0,0,0.15); }

/* Banner */
.m3-banner {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
  padding: 16px; border-radius: var(--md-sys-shape-corner-small);
}

/* Text fields & Form */
.m3-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.m3-field label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
}
.m3-input, .m3-select {
  height: 48px;
  padding: 0 16px;
  border-radius: var(--md-sys-shape-corner-extra-small);
  border: 1px solid var(--md-sys-color-outline);
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font: 400 1rem var(--md-ref-typeface-plain);
  box-sizing: border-box;
  outline: none;
  transition: border-color var(--md-sys-motion-duration-short4);
}
.m3-input:focus, .m3-select:focus {
  border-color: var(--md-sys-color-primary);
  border-width: 2px;
}

/* Segmented Button */
.m3-segmented {
  display: inline-flex;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-full);
  overflow: hidden;
}
.m3-segmented-btn {
  background: transparent;
  border: none;
  border-right: 1px solid var(--md-sys-color-outline);
  padding: 8px 16px;
  font: 500 0.875rem var(--md-ref-typeface-plain);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  transition: background var(--md-sys-motion-duration-short4);
}
.m3-segmented-btn:last-child {
  border-right: none;
}
.m3-segmented-btn.selected {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-weight: 600;
}

/* Chips */
.m3-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 16px;
  border-radius: var(--md-sys-shape-corner-small);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface);
  font: 500 0.875rem var(--md-ref-typeface-plain);
  text-decoration: none;
  cursor: pointer;
}
.m3-chip:hover {
  background: var(--md-sys-color-surface-container-highest);
}

/* Date Picker / Grid */
.m3-date-grid-container {
  background: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-sys-shape-corner-large);
  padding: 20px;
}
.m3-cal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.m3-cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 8px;
}
.m3-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.m3-date-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 6px;
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-surface);
  text-decoration: none;
  color: var(--md-sys-color-on-surface);
  box-sizing: border-box;
  transition: transform 0.1s, box-shadow 0.1s;
}
.m3-date-cell:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  background: var(--md-sys-color-surface-container-highest);
}
.m3-date-cell.today {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: -2px;
}
.m3-date-cell.other-month {
  background: transparent;
  pointer-events: none;
}
.cell-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.solar-num {
  font-size: 1rem;
  font-weight: 600;
}
.lunar-num {
  font-size: 0.6875rem;
  color: var(--md-sys-color-on-surface-variant);
}
.lunar-special {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--md-sys-color-tertiary);
}
.m3-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.dot-good {
  background: var(--kth-good);
}
.dot-bad {
  border: 1px solid var(--md-sys-color-error);
  box-sizing: border-box;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) { * { transition-duration: 0ms !important; animation: none !important; } }
