:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #f8fafc;
  --surface-strong: #eef4f6;
  --border: #d9e2e7;
  --border-strong: #b8c8cf;
  --text: #121826;
  --muted: #5b667a;
  --quiet: #8490a2;
  --teal: #075f69;
  --teal-dark: #054a52;
  --teal-soft: #e3f3f2;
  --gold: #c58a05;
  --gold-soft: #fff2cc;
  --green: #138a3d;
  --green-soft: #dff4e6;
  --red: #d73b36;
  --red-soft: #ffe1df;
  --shadow: 0 16px 40px rgba(31, 45, 61, 0.08);
  --radius: 8px;
  --radius-sm: 6px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  background: var(--bg);
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(7, 95, 105, 0.22);
  outline-offset: 2px;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
  flex: 0 0 auto;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 74px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

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

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius);
  background: linear-gradient(145deg, var(--teal), var(--teal-dark));
  box-shadow: 0 10px 24px rgba(7, 95, 105, 0.22);
}

.brand-mark svg {
  width: 27px;
  height: 27px;
  stroke-width: 2.2;
}

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

h1 {
  color: #0d1320;
  font-size: 31px;
  font-weight: 760;
  line-height: 1.1;
  letter-spacing: 0;
}

.mobile-subtitle {
  display: none;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.updated-text {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.ghost-button,
.outline-button,
.primary-button,
.mini-button,
.link-button,
.segment,
.time-option {
  border-radius: var(--radius-sm);
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.ghost-button,
.outline-button,
.primary-button,
.mini-button,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 680;
  text-decoration: none;
}

.ghost-button {
  color: var(--text);
  border: 1px solid var(--border-strong);
  background: #fff;
}

.ghost-button:hover,
.outline-button:hover,
.mini-button:hover {
  border-color: var(--teal);
  box-shadow: 0 8px 24px rgba(7, 95, 105, 0.08);
}

.primary-button {
  width: 100%;
  min-height: 52px;
  color: #fff;
  border: 1px solid var(--teal);
  background: linear-gradient(145deg, var(--teal), var(--teal-dark));
  box-shadow: 0 12px 26px rgba(7, 95, 105, 0.18);
}

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

.outline-button {
  width: 100%;
  min-height: 50px;
  color: var(--teal);
  border: 1px solid #78a9b0;
  background: #fff;
}

.compact {
  min-height: 42px;
}

.mini-button {
  min-height: 32px;
  padding: 0 10px;
  color: var(--teal);
  border: 1px solid var(--border);
  background: #fff;
  font-size: 12px;
}

.link-button {
  justify-content: flex-start;
  width: fit-content;
  min-height: 38px;
  padding: 0;
  color: var(--teal);
  border: 0;
  background: transparent;
}

.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 360px;
  min-height: calc(100vh - 74px);
}

.filter-rail,
.source-panel {
  background: #fbfcfd;
}

.filter-rail {
  position: sticky;
  top: 74px;
  align-self: start;
  height: calc(100vh - 74px);
  overflow: auto;
  padding: 22px 22px 28px;
  border-right: 1px solid var(--border);
}

.source-panel {
  position: sticky;
  top: 74px;
  align-self: start;
  height: calc(100vh - 74px);
  overflow: auto;
  padding: 18px 20px 28px;
  border-left: 1px solid var(--border);
}

.control-group + .control-group,
.side-section {
  margin-top: 26px;
}

.control-group h2,
.side-section h2 {
  margin-bottom: 12px;
  font-size: 16px;
  font-weight: 760;
  letter-spacing: 0;
}

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

.section-heading h2 {
  margin-bottom: 0;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.segment {
  min-height: 42px;
  color: var(--text);
  border: 1px solid var(--border-strong);
  background: #fff;
  font-size: 14px;
  font-weight: 720;
}

.segment.active {
  color: #fff;
  border-color: var(--teal);
  background: var(--teal);
}

.day-list,
.time-options {
  display: grid;
  gap: 6px;
}

.day-button {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  text-align: left;
}

.day-button strong {
  font-size: 14px;
  font-weight: 720;
}

.day-button span {
  color: var(--muted);
  font-size: 13px;
}

.day-button.active {
  border-color: var(--teal);
  background: var(--teal-soft);
  box-shadow: inset 0 0 0 1px rgba(7, 95, 105, 0.18);
}

.time-option {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 12px;
  color: var(--text);
  border: 1px solid var(--border);
  background: #fff;
  text-align: left;
}

.time-option span {
  font-size: 14px;
  font-weight: 720;
}

.time-option small {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.time-option.active {
  border-color: var(--teal);
  background: #f2fbfa;
  box-shadow: inset 0 0 0 1px rgba(7, 95, 105, 0.14);
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--quiet);
}

.search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 14px;
}

select,
.schedule-form input,
.schedule-form textarea,
#pasteImport {
  width: 100%;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}

select {
  min-height: 44px;
  margin-top: 10px;
  padding: 0 12px;
  font-size: 14px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
}

.check-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--teal);
}

.results-pane {
  min-width: 0;
  padding: 18px 26px 28px;
  background: #fff;
}

.next-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.74fr);
  gap: 28px;
  align-items: center;
  min-height: 158px;
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.next-main {
  display: flex;
  align-items: center;
  gap: 22px;
  min-width: 0;
}

.clock-badge {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  color: var(--green);
  border: 5px solid var(--green);
  border-radius: 50%;
}

.clock-badge svg {
  width: 34px;
  height: 34px;
  stroke-width: 2.3;
}

.next-copy small,
.upcoming-list small,
.church-meta,
.source-name,
.checked-date,
.result-count,
.note-copy,
.import-item small {
  color: var(--muted);
}

.next-copy h2 {
  margin-bottom: 6px;
  color: var(--text);
  font-size: 18px;
  font-weight: 760;
}

.next-time {
  color: var(--teal);
  font-size: 23px;
  font-weight: 780;
}

.next-copy h3 {
  margin-top: 7px;
  font-size: 16px;
  font-weight: 720;
}

.upcoming-box {
  min-width: 0;
  padding-left: 28px;
  border-left: 1px solid var(--border);
}

.upcoming-title {
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 760;
}

.upcoming-list {
  display: grid;
  gap: 8px;
}

.upcoming-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: baseline;
  color: var(--text);
  font-size: 14px;
}

.table-header {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(220px, 1.36fr) minmax(150px, 0.84fr) minmax(120px, 0.82fr);
  gap: 18px;
  padding: 19px 14px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-weight: 760;
}

.church-list {
  display: grid;
}

.church-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(220px, 1.36fr) minmax(150px, 0.84fr) minmax(120px, 0.82fr);
  gap: 18px;
  min-width: 0;
  padding: 18px 14px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.church-row > div {
  min-width: 0;
}

.church-row:hover {
  background: #fbfefe;
}

.church-name {
  color: #064f9b;
  font-size: 16px;
  font-weight: 780;
}

.church-meta {
  margin-top: 4px;
  font-size: 13px;
}

.distance {
  display: inline-block;
  margin-top: 8px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 720;
}

.source-name {
  overflow-wrap: anywhere;
}

.times-list {
  display: grid;
  gap: 9px;
  min-width: 0;
}

.time-line {
  display: grid;
  grid-template-columns: 16px minmax(120px, auto) 1fr;
  gap: 6px;
  align-items: baseline;
  font-size: 14px;
}

.time-line .dot {
  width: 9px;
  height: 9px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--green);
}

.time-line strong {
  font-weight: 760;
}

.time-line span:last-child {
  color: #273247;
}

.tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 30px;
  margin-top: 8px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 760;
}

.tag.up-to-date {
  color: #067130;
  background: var(--green-soft);
}

.tag.check-needed {
  color: #a36c00;
  background: var(--gold-soft);
}

.tag.out-of-date {
  color: #b52725;
  background: var(--red-soft);
}

.checked-date {
  font-size: 14px;
}

.action-stack {
  display: grid;
  gap: 12px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--border);
}

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

.side-section:first-of-type {
  border-top: 0;
}

.schedule-form,
.schedule-form label {
  display: grid;
  gap: 7px;
}

.schedule-form {
  gap: 12px;
}

.schedule-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.schedule-form input,
.schedule-form textarea {
  min-height: 38px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}

.schedule-form textarea,
#pasteImport {
  resize: vertical;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 0.72fr 0.72fr;
  gap: 8px;
}

.import-list,
.status-list {
  display: grid;
  gap: 12px;
}

.import-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 20px;
  gap: 10px;
  align-items: center;
}

.file-icon {
  display: grid;
  width: 34px;
  height: 40px;
  place-items: center;
  color: #fff;
  border-radius: 5px;
  background: var(--teal);
  font-size: 10px;
  font-weight: 800;
}

.import-item strong {
  display: block;
  overflow: hidden;
  color: var(--teal);
  font-size: 14px;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-ok {
  color: var(--green);
}

.import-warning {
  color: var(--gold);
}

.status-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.status-dot.up-to-date {
  background: var(--green);
}

.status-dot.check-needed {
  background: var(--gold);
}

.status-dot.out-of-date {
  background: var(--red);
}

.note-copy {
  font-size: 14px;
}

#pasteImport {
  margin-top: 12px;
  padding: 10px;
  font-size: 13px;
  line-height: 1.4;
}

.empty-state {
  padding: 26px 14px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.result-count {
  padding: 14px;
  font-size: 13px;
}

@media (max-width: 1300px) {
  .layout {
    grid-template-columns: 286px minmax(0, 1fr);
  }

  .source-panel {
    position: static;
    grid-column: 2 / -1;
    height: auto;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

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

  .action-stack,
  .side-section {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }
}

@media (max-width: 840px) {
  .topbar {
    position: static;
    align-items: flex-start;
    padding: 16px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  h1 {
    font-size: 24px;
  }

  .mobile-subtitle {
    display: block;
    margin-top: 2px;
  }

  .updated-text {
    display: none;
  }

  .layout {
    display: flex;
    flex-direction: column;
  }

  .filter-rail,
  .source-panel {
    position: static;
    height: auto;
    border-right: 0;
  }

  .filter-rail {
    order: 2;
    padding: 18px 16px;
    border-bottom: 1px solid var(--border);
  }

  .source-panel {
    order: 3;
    display: block;
    padding: 18px 16px 28px;
  }

  .results-pane {
    order: 1;
    padding: 16px;
  }

  .next-panel {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .upcoming-box {
    padding-left: 0;
    border-left: 0;
    border-top: 1px solid var(--border);
    padding-top: 16px;
  }

  .table-header {
    display: none;
  }

  .church-row {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 18px 0;
  }

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

}

@media (max-width: 540px) {
  .topbar {
    display: grid;
  }

  .topbar-actions {
    width: 100%;
  }

  .ghost-button {
    width: 100%;
  }

  .time-option {
    grid-template-columns: 28px 1fr;
  }

  .time-option small {
    grid-column: 2;
  }

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

  .next-main {
    align-items: flex-start;
  }

  .clock-badge {
    width: 52px;
    height: 52px;
  }

  .next-time {
    font-size: 20px;
  }

  .upcoming-row {
    grid-template-columns: 68px minmax(0, 1fr);
  }

  .upcoming-row small {
    grid-column: 2;
  }

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