:root {
  color-scheme: light;
  --ink: #f3eadc;
  --surface: #fffaf2;
  --surface-raised: #fffdf9;
  --surface-soft: #eee4d5;
  --line: #d9c9bb;
  --line-strong: #b7a497;
  --text: #2f2444;
  --text-soft: #5a4d6b;
  --muted: #756a82;
  --accent: #6b3f73;
  --accent-soft: #4d2b58;
  --accent-ink: #fff9f1;
  --day: #6d4778;
  --night: #4f5a7c;
  --danger: #9b3f54;
  --radius-panel: 14px;
  --radius-control: 10px;
  --radius-pill: 999px;
  --shadow: 0 18px 45px rgb(48 35 67 / 14%);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--ink);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  background:
    linear-gradient(90deg, rgb(76 60 83 / 4%) 1px, transparent 1px) 0 0 / 72px 100%,
    var(--ink);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgb(107 63 115 / 5%), transparent 360px);
  content: "";
  pointer-events: none;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="date"] {
  touch-action: manipulation;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

:focus-visible {
  outline: 3px solid var(--accent-soft);
  outline-offset: 3px;
}

button:focus:not(:focus-visible),
select:focus:not(:focus-visible),
input:focus:not(:focus-visible) {
  outline: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1000;
  padding: 10px 14px;
  border-radius: var(--radius-control);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  width: min(1120px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  text-decoration: none;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1rem;
  letter-spacing: 0.01em;
}

.brand small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.brand-orbit {
  position: relative;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}

.brand-orbit::after {
  width: 26px;
  height: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  content: "";
  transform: rotate(-28deg);
}

.brand-sun,
.brand-moon {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.brand-sun {
  top: 7px;
  right: 9px;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgb(107 63 115 / 12%);
}

.brand-moon {
  bottom: 8px;
  left: 8px;
  background: var(--night);
}

.now-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.now-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgb(107 63 115 / 12%);
}

main {
  display: grid;
  gap: 16px;
}

.control-panel,
.week-panel,
.day-hero,
.hours-panel,
.week-table-panel,
.method-panel,
.current-panel,
.finder-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
}

.current-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.65fr) auto;
  align-items: center;
  gap: 20px;
  padding: 18px;
  border-color: rgb(107 63 115 / 34%);
  background: linear-gradient(135deg, var(--surface-raised), var(--surface));
}

.current-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.current-symbol {
  width: 52px;
  height: 52px;
  border-color: rgb(107 63 115 / 45%);
  background: rgb(107 63 115 / 7%);
  font-size: 1.7rem;
}

.current-kicker {
  margin: 0 0 4px;
  color: var(--accent-soft);
  font-size: 0.7rem;
  font-weight: 780;
  letter-spacing: 0.08em;
}

.current-title {
  margin: 0;
  font-size: 1.22rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.current-meta {
  margin: 5px 0 0;
  color: var(--text-soft);
  font-size: 0.76rem;
  line-height: 1.4;
}

.current-times {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  overflow: hidden;
}

.current-times > div {
  min-width: 0;
  padding: 9px 10px;
  border-right: 1px solid var(--line);
  background: rgb(238 228 213 / 45%);
}

.current-times > div:last-child {
  border-right: 0;
}

.current-times dt {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
}

.current-times dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-size: 0.78rem;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}

.current-jump {
  min-width: 126px;
}

.control-panel,
.week-panel,
.hours-panel,
.week-table-panel,
.finder-panel {
  padding: 18px;
}

.finder-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.finder-result {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: rgb(238 228 213 / 50%);
}

.finder-result[hidden] {
  display: none;
}

.finder-symbol {
  width: 40px;
  height: 40px;
  font-size: 1.16rem;
}

.finder-copy {
  min-width: 0;
}

.finder-copy strong,
.finder-copy span {
  display: block;
}

.finder-copy strong {
  font-size: 0.9rem;
}

.finder-copy span {
  margin-top: 3px;
  color: var(--text-soft);
  font-size: 0.76rem;
  line-height: 1.45;
}

.finder-result .button {
  min-width: 128px;
}

.hour-item.is-found {
  border-radius: var(--radius-control);
  background: rgb(107 63 115 / 11%);
}

.hour-item.is-found .hour-index {
  border-color: var(--accent);
  color: var(--accent-soft);
}

.day-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.5fr);
  gap: 20px;
  padding: 23px 20px;
  background: var(--surface-raised);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 15px;
}

.section-heading > div {
  min-width: 0;
}

.section-heading.compact {
  align-items: center;
}

.section-heading h1,
.section-heading h2,
.day-identity h2,
.method-content h3,
.ruler-table-wrap h3,
.notes h3 {
  margin: 0;
  letter-spacing: -0.02em;
}

.section-heading h1 {
  font-size: 1.42rem;
  line-height: 1.1;
}

.section-heading h2 {
  font-size: 1.08rem;
  line-height: 1.2;
}

.section-heading p {
  max-width: 60ch;
  margin: 5px 0 0;
  color: var(--text-soft);
  font-size: 0.82rem;
  line-height: 1.5;
}

.calculation-stamp {
  flex: 0 0 auto;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 0.85fr) minmax(260px, 1.35fr) minmax(180px, 0.9fr);
  gap: 13px;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field > span:first-child {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.field-help {
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.4;
}

select,
input[type="date"],
input[type="number"] {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface-raised);
  color: var(--text);
  font-size: 1rem;
}

select {
  appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 20px,
    calc(100% - 12px) 20px;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.72;
}

button {
  min-height: 44px;
  border: 0;
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 13px;
  border-radius: var(--radius-control);
  font-size: 0.82rem;
  font-weight: 760;
  line-height: 1.1;
  transition: background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out, transform 150ms ease-out;
}

.button:active {
  transform: scale(0.98);
}

.button.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.button.primary:hover {
  background: var(--accent-soft);
}

.button.secondary {
  border: 1px solid var(--line-strong);
  background: var(--surface-raised);
  color: var(--text);
}

.button.secondary:hover,
.button.quiet:hover {
  border-color: var(--accent);
  color: var(--accent-soft);
}

.button.quiet {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-soft);
}

.button[disabled] {
  cursor: not-allowed;
  opacity: 0.45;
}

.button-cluster > div {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.advanced-settings {
  margin-top: 15px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.advanced-settings summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  list-style: none;
}

.advanced-settings summary::-webkit-details-marker,
.method-panel summary::-webkit-details-marker {
  display: none;
}

.advanced-settings summary::after {
  content: "＋";
  color: var(--accent);
  font-size: 1.1rem;
}

.advanced-settings[open] summary::after {
  content: "−";
}

.advanced-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr 1fr;
  gap: 12px;
  padding-top: 6px;
}

.apply-location {
  grid-column: 4;
  align-self: end;
}

.switch {
  display: flex;
  align-items: center;
  min-height: 46px;
  gap: 9px;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 0.82rem;
}

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

.switch-track {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  transition: background-color 180ms ease-out, border-color 180ms ease-out;
}

.switch-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  content: "";
  transition: transform 180ms ease-out, background-color 180ms ease-out;
}

.switch input:checked + .switch-track {
  border-color: var(--accent);
  background: rgb(107 63 115 / 12%);
}

.switch input:checked + .switch-track::after {
  background: var(--accent);
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
  outline: 3px solid var(--accent-soft);
  outline-offset: 3px;
}

.week-panel {
  overflow: hidden;
}

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

.day-tab {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 78px;
  padding: 9px 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface-soft);
  color: var(--text-soft);
  text-align: center;
}

.day-tab:hover {
  border-color: var(--line-strong);
}

.day-tab[aria-current="date"] {
  border-color: var(--accent);
  background: var(--surface-soft);
  color: var(--text);
}

.day-tab.is-today::after {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.day-tab .weekday {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.day-tab .date-number {
  align-self: center;
  font-size: 1.12rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.day-tab .ruler {
  color: var(--accent-soft);
  font-size: 0.78rem;
}

.day-identity {
  align-self: center;
}

.day-kicker {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 780;
  letter-spacing: 0.08em;
}

.day-identity h2 {
  font-size: clamp(1.45rem, 5vw, 2.3rem);
  line-height: 1.02;
}

.ruler-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.planet-symbol {
  display: inline-grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--accent-soft);
  font-family: "Apple Symbols", "Segoe UI Symbol", "Noto Sans Symbols 2", serif;
  font-size: 1.55rem;
}

.ruler-line small,
.ruler-line strong {
  display: block;
}

.ruler-line small {
  color: var(--muted);
  font-size: 0.72rem;
}

.ruler-line strong {
  margin-top: 2px;
  font-size: 1rem;
}

.astro-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  overflow: hidden;
}

.astro-facts > div {
  min-width: 0;
  padding: 14px 13px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgb(238 228 213 / 70%);
}

.astro-facts > div:nth-child(3n) {
  border-right: 0;
}

.astro-facts > div:nth-last-child(-n + 3) {
  border-bottom: 0;
}

.astro-facts dt {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.astro-facts dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  font-size: 0.92rem;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.pre-dawn-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid rgb(79 90 124 / 36%);
  border-radius: var(--radius-panel);
  background: rgb(79 90 124 / 7%);
}

.pre-dawn-note strong {
  font-size: 0.88rem;
}

.pre-dawn-note p {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 0.78rem;
  line-height: 1.45;
}

.active-summary {
  flex: 0 0 auto;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--text-soft);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.active-summary.is-active {
  border-color: rgb(107 63 115 / 38%);
  background: rgb(107 63 115 / 7%);
  color: var(--accent-soft);
}

.hours-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}

.hours-meta-item {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  color: var(--text-soft);
  font-size: 0.72rem;
  line-height: 1.2;
  white-space: nowrap;
}

.hours-meta-item > span {
  color: var(--muted);
  font-weight: 700;
}

.hours-meta-item strong {
  color: var(--text);
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.hours-meta-item.is-date {
  border-color: rgb(107 63 115 / 30%);
  background: rgb(238 228 213 / 68%);
}

.hours-meta-item.is-date strong {
  color: var(--accent-soft);
}

.period-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 3px 9px;
  border-bottom: 1px solid var(--line);
}

.period-heading span {
  color: var(--day);
  font-size: 0.78rem;
  font-weight: 820;
  letter-spacing: 0.08em;
}

.period-heading small {
  color: var(--muted);
  font-size: 0.68rem;
}

.period-heading.night {
  margin-top: 18px;
}

.period-heading.night span {
  color: var(--night);
}

.hours-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hour-item {
  display: grid;
  grid-template-columns: 38px 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 66px;
  padding: 9px 8px 9px 0;
  border-bottom: 1px solid var(--line);
}

.hour-item:last-child {
  border-bottom: 0;
}

.hour-index {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.hour-symbol {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--accent-soft);
  font-family: "Apple Symbols", "Segoe UI Symbol", "Noto Sans Symbols 2", serif;
  font-size: 1.18rem;
}

.hour-copy {
  min-width: 0;
}

.hour-copy strong,
.hour-copy span {
  display: block;
}

.hour-copy strong {
  font-size: 0.91rem;
  line-height: 1.25;
}

.hour-copy span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.68rem;
}

.hour-time {
  min-width: 112px;
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.hour-item.is-current {
  position: relative;
  padding-left: 18px;
  border-radius: var(--radius-control);
  background: rgb(107 63 115 / 7%);
}

.hour-item.is-current::before {
  position: absolute;
  top: 50%;
  left: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
  transform: translateY(-50%);
}

.hour-item.is-current .hour-index {
  border-color: var(--accent);
  color: var(--accent-soft);
}

.hour-item.is-current .hour-copy strong,
.hour-item.is-current .hour-copy span {
  color: var(--accent-soft);
}

.hour-item.is-current .hour-copy span {
  font-weight: 750;
}

.hour-item.is-past {
  opacity: 0.66;
}

.week-table-panel {
  overflow: hidden;
}

.planet-key {
  display: none;
  gap: 5px;
  color: var(--muted);
  font-size: 0.72rem;
}

@media (min-width: 900px) {
  .planet-key {
    display: flex;
  }
}

.planet-key span {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.table-wrap {
  max-height: 520px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  scrollbar-color: var(--line-strong) var(--ink);
  scrollbar-width: thin;
}

#week-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-variant-numeric: tabular-nums;
}

#week-table th,
#week-table td {
  height: 34px;
  padding: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
}

#week-table th:last-child,
#week-table td:last-child {
  border-right: 0;
}

#week-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-raised);
}

#week-table thead th:first-child,
#week-table tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  width: 48px;
  background: var(--surface);
}

#week-table thead th:first-child {
  z-index: 3;
}

#week-table tbody th {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 720;
}

#week-table tbody tr.night-start th,
#week-table tbody tr.night-start td {
  border-top: 2px solid var(--line-strong);
}

#week-table .week-th-day,
#week-table .week-th-date {
  display: block;
  line-height: 1.1;
}

#week-table .week-th-day {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

#week-table .week-th-date {
  margin-top: 2px;
  color: var(--text);
  font-size: 0.78rem;
}

#week-table th.is-selected,
#week-table td.is-selected {
  background: rgb(107 63 115 / 8%);
}

#week-table td {
  color: var(--accent-soft);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  font-size: 0.82rem;
  font-weight: 760;
}

#week-table td.is-live {
  position: relative;
  background: var(--accent);
  color: var(--accent-ink);
}

.method-panel {
  overflow: hidden;
}

.method-panel > details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 16px 18px;
  cursor: pointer;
  list-style: none;
}

.method-panel > details > summary strong,
.method-panel > details > summary small {
  display: block;
}

.method-panel > details > summary strong {
  font-size: 1rem;
}

.method-panel > details > summary small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.75rem;
}

.details-mark {
  color: var(--accent);
  font-size: 1.25rem;
}

.method-panel details[open] .details-mark {
  transform: rotate(45deg);
}

.method-content {
  padding: 0 18px 20px;
  border-top: 1px solid var(--line);
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
  padding: 20px 0;
}

.method-content h3 {
  font-size: 0.9rem;
}

.method-content p,
.notes li,
.calculation-trace {
  color: var(--text-soft);
  font-size: 0.8rem;
  line-height: 1.6;
}

.method-content code {
  display: block;
  margin-top: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--accent-soft);
  font-family: "SFMono-Regular", "Cascadia Mono", "Roboto Mono", monospace;
  font-size: 0.74rem;
  line-height: 1.55;
  white-space: normal;
}

.calculation-trace {
  margin-top: 10px;
  padding: 9px 10px;
  border-left: 1px solid var(--line-strong);
  white-space: pre-line;
}

.ruler-table-wrap {
  padding: 17px 0 3px;
  border-top: 1px solid var(--line);
}

.ruler-table {
  width: 100%;
  margin-top: 11px;
  border-collapse: collapse;
  font-size: 0.78rem;
  text-align: center;
}

.ruler-table th,
.ruler-table td {
  padding: 9px 4px;
  border: 1px solid var(--line);
}

.ruler-table th {
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 700;
}

.ruler-table td {
  color: var(--accent-soft);
  font-weight: 780;
}

.notes {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.notes ul {
  margin: 10px 0 0;
  padding-left: 1.1rem;
}

.notes li + li {
  margin-top: 6px;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 2px 0;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.5;
}

footer p {
  margin: 0;
}

footer p:last-child {
  text-align: right;
  white-space: nowrap;
}

.toast {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  left: max(14px, env(safe-area-inset-left));
  z-index: 200;
  width: fit-content;
  max-width: min(440px, calc(100% - 28px));
  margin: 0 auto;
  padding: 12px 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface-raised);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.45;
}

@media (max-width: 900px) {
  .control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .button-cluster,
  .action-field {
    min-width: 0;
  }

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

  .apply-location {
    grid-column: 2;
  }

  .day-hero {
    grid-template-columns: 1fr;
  }

  .current-panel {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .current-jump {
    width: 100%;
  }

  .finder-form {
    grid-template-columns: 1fr;
  }

  .finder-form .button {
    width: 100%;
  }
}

@media (max-width: 640px) {
  body {
    background:
      linear-gradient(90deg, rgb(76 60 83 / 4%) 1px, transparent 1px) 0 0 / 48px 100%,
      var(--ink);
  }

  .app-shell {
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .topbar {
    align-items: flex-start;
    margin-bottom: 14px;
  }

  .brand small {
    display: none;
  }

  .now-chip {
    max-width: 190px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .control-panel,
  .week-panel,
  .hours-panel,
  .week-table-panel,
  .current-panel,
  .finder-panel {
    padding: 15px;
  }

  .finder-result {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .finder-result .button {
    grid-column: 1 / -1;
    width: 100%;
  }

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

  .current-times > div:nth-child(2) {
    border-right: 0;
  }

  .current-times > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .day-hero {
    padding: 19px 16px;
  }

  .section-heading {
    align-items: flex-start;
  }

  .hours-panel .section-heading {
    flex-wrap: wrap;
  }

  .hours-panel .section-heading > div {
    flex: 1 1 100%;
  }

  .hours-panel .active-summary {
    margin-top: 2px;
  }

  .control-grid,
  .advanced-grid {
    grid-template-columns: 1fr;
  }

  .apply-location {
    grid-column: 1;
  }

  .button-cluster > div {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .week-days {
    gap: 4px;
  }

  .day-tab {
    min-height: 71px;
    padding-inline: 2px;
  }

  .day-tab .date-number {
    font-size: 1rem;
  }

  .day-tab .ruler {
    font-size: 0.72rem;
  }

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

  .astro-facts > div:nth-child(3n) {
    border-right: 1px solid var(--line);
  }

  .astro-facts > div:nth-child(2n) {
    border-right: 0;
  }

  .astro-facts > div:nth-last-child(-n + 3) {
    border-bottom: 1px solid var(--line);
  }

  .astro-facts > div:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .hour-item {
    grid-template-columns: 34px 40px minmax(0, 1fr);
    min-height: 70px;
  }

  .hour-time {
    grid-column: 3;
    min-width: 0;
    margin-top: 3px;
    text-align: left;
    white-space: normal;
  }

  .hour-copy span {
    display: none;
  }

  .table-wrap {
    max-height: 440px;
  }

  .method-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  footer {
    display: block;
  }

  footer p:last-child {
    margin-top: 7px;
    text-align: left;
    white-space: normal;
  }
}

@media (max-width: 380px) {
  .now-chip {
    max-width: 108px;
  }

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

  .day-tab .weekday {
    font-size: 0.62rem;
  }

  .day-tab .ruler {
    font-size: 0.66rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
