:root {
  color-scheme: light;
  --background: #f5f8fa;
  --surface: #ffffff;
  --card: #56b8e7;
  --card-dark: #1995cf;
  --accent: #52c878;
  --ink: #10202b;
  --muted: #627480;
  --line: #d8e2e8;
  --danger: #b42318;
  --shadow: 0 10px 26px rgb(24 65 88 / 12%);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 1px 1px, rgb(72 102 119 / 12%) 1.2px, transparent 1.4px) 0 0 / 28px 28px,
    var(--background);
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

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

.app-header {
  margin-bottom: 22px;
  text-align: center;
}

.brand {
  margin: 0 0 4px;
  color: var(--card-dark);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .14em;
}

h1 {
  margin: 0;
  font-size: clamp(1.6rem, 6vw, 2.1rem);
  line-height: 1.25;
}

.lead {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: .92rem;
}

.clock-panel {
  width: 100%;
}

.live-control {
  display: flex;
  width: fit-content;
  min-height: 44px;
  margin: 0 0 8px 2px;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 1.06rem;
  font-weight: 750;
  user-select: none;
}

.live-control input {
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--card-dark);
}

.reference-label {
  margin: 0 0 6px 14px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 700;
}

.cards {
  display: grid;
  gap: 14px;
}

.time-card {
  position: relative;
  display: grid;
  min-height: 154px;
  padding: 18px 16px 15px 42px;
  overflow: hidden;
  border: 1px solid rgb(12 100 143 / 12%);
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}

.time-card + .time-card {
  min-height: 142px;
}

.time-card.is-dragging {
  z-index: 20;
  transform: scale(1.025);
  box-shadow: 0 18px 38px rgb(24 65 88 / 25%);
  opacity: .94;
}

.drag-handle {
  position: absolute;
  inset: 0 auto 0 0;
  width: 28px;
  border: 0;
  border-radius: 23px 0 0 23px;
  background: var(--accent);
  cursor: grab;
  touch-action: none;
}

.drag-handle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 34px;
  border-radius: 99px;
  background: repeating-linear-gradient(to bottom, rgb(255 255 255 / 90%) 0 4px, transparent 4px 8px);
  transform: translate(-50%, -50%);
}

.drag-handle:active {
  cursor: grabbing;
}

.card-top {
  display: flex;
  min-width: 0;
  align-items: start;
  gap: 8px;
}

.zone-button {
  min-width: 0;
  min-height: 44px;
  padding: 4px 4px;
  overflow: hidden;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: clamp(1.13rem, 5vw, 1.42rem);
  font-weight: 700;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.zone-button:active,
.zone-button:focus-visible {
  background: rgb(255 255 255 / 25%);
}

.remove-button {
  width: 44px;
  height: 44px;
  margin: -4px -7px 0 auto;
  flex: 0 0 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 2rem;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
}

.remove-button:active,
.remove-button:focus-visible {
  background: rgb(255 255 255 / 28%);
}

.time-row {
  display: flex;
  min-width: 0;
  margin-top: 5px;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-variant-numeric: tabular-nums;
}

.date-text,
.time-text {
  white-space: nowrap;
  line-height: 1.12;
}

.date-text {
  font-size: clamp(1.48rem, 7.2vw, 2.2rem);
}

.time-text {
  font-size: clamp(1.7rem, 8.2vw, 2.6rem);
  font-weight: 650;
}

.date-input,
.time-input {
  min-width: 0;
  height: 52px;
  padding: 0 2px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-variant-numeric: tabular-nums;
}

.date-input {
  width: 58%;
  font-size: clamp(1.1rem, 5.4vw, 1.85rem);
}

.time-input {
  width: 40%;
  font-size: clamp(1.25rem, 6.5vw, 2.12rem);
  font-weight: 650;
}

.date-input:focus,
.time-input:focus {
  border-bottom-color: rgb(4 70 103 / 60%);
}

.date-input::-webkit-calendar-picker-indicator,
.time-input::-webkit-calendar-picker-indicator {
  opacity: .55;
}

.card-bottom {
  display: flex;
  min-height: 28px;
  margin-top: 5px;
  align-items: end;
  justify-content: flex-end;
}

.dst-button {
  min-height: 32px;
  padding: 4px 8px;
  border: 0;
  border-radius: 10px;
  background: rgb(255 255 255 / 25%);
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
}

.dst-button[data-mode="ignored"] {
  background: rgb(255 246 204 / 88%);
}

.dst-placeholder {
  min-height: 32px;
}

.add-button {
  display: flex;
  width: min(70%, 310px);
  min-height: 52px;
  margin: 20px auto 0;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 6px 14px rgb(24 65 88 / 13%);
  font-size: 1rem;
  font-weight: 750;
  cursor: pointer;
}

.add-button span:first-child {
  font-size: 1.45rem;
  line-height: 1;
}

.add-button:active {
  transform: translateY(1px);
  background: #4aaddd;
}

.drag-help {
  margin: 14px auto 0;
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.55;
  text-align: center;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  align-items: end;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(13 30 40 / 46%);
  backdrop-filter: blur(2px);
}

.modal-sheet {
  position: relative;
  display: flex;
  width: min(100%, 680px);
  max-height: min(86dvh, 760px);
  margin: 0 auto;
  padding: 12px 16px max(18px, env(safe-area-inset-bottom));
  flex-direction: column;
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  box-shadow: 0 -18px 44px rgb(13 30 40 / 22%);
  animation: sheet-in .2s ease-out;
}

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

.modal-header {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.18rem;
  text-align: center;
}

.icon-button {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 1.9rem;
  line-height: 1;
  cursor: pointer;
}

.icon-button:active {
  background: #eef3f5;
}

.modal-back {
  font-size: 2.35rem;
}

.search-wrap {
  position: relative;
  margin-top: 8px;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 14px;
  color: var(--muted);
  font-size: 1.4rem;
  transform: translateY(-52%);
  pointer-events: none;
}

#zone-search {
  width: 100%;
  min-height: 48px;
  padding: 9px 14px 9px 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: 0;
  background: #f7fafb;
  font-size: 16px;
}

#zone-search:focus {
  border-color: var(--card-dark);
  box-shadow: 0 0 0 3px rgb(25 149 207 / 13%);
}

.modal-guide {
  margin: 12px 4px 6px;
  color: var(--muted);
  font-size: .82rem;
}

.zone-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-top: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
}

.zone-option {
  display: flex;
  width: 100%;
  min-height: 54px;
  padding: 10px 8px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.zone-option:active {
  background: #eef8fc;
}

.option-main {
  font-weight: 700;
}

.option-sub {
  color: var(--muted);
  font-size: .76rem;
  text-align: right;
}

.chevron {
  color: var(--muted);
  font-size: 1.4rem;
}

.empty-message {
  margin: 28px 0;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 200;
  right: 18px;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 18px;
  width: fit-content;
  max-width: min(540px, calc(100% - 36px));
  margin: auto;
  padding: 11px 16px;
  border-radius: 12px;
  color: white;
  background: rgb(17 32 43 / 94%);
  box-shadow: var(--shadow);
  font-size: .88rem;
  text-align: center;
}

body.modal-open {
  overflow: hidden;
}

body.dragging {
  overflow: hidden;
  user-select: none;
}

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

  .time-card {
    padding-right: 24px;
    padding-left: 48px;
  }
}

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