:root {
  color-scheme: light dark;
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "SF Pro Text",
    "SF Pro Display",
    "Helvetica Neue",
    Arial,
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f5f5f7;
  color: #1d1d1f;
}

main {
  width: min(720px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 60px;
}

.back {
  display: inline-block;
  margin-bottom: 30px;
  color: #5f5f63;
  font-size: 16px;
  text-decoration: none;
}

.title-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 10px;
}

h1 {
  margin: 0;
  font-size: 36px;
  line-height: 1.1;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.build-number {
  color: #8e8e93;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.subtitle {
  margin: 0 0 24px;
  color: #5f5f63;
  font-size: 17px;
  line-height: 1.5;
}

.import-area {
  margin-bottom: 34px;
}

.import-button {
  width: 100%;
  height: 48px;
  border: 1px solid #cfcfd4;
  border-radius: 12px;
  background: #ffffff;
  color: #1d1d1f;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.import-button:active {
  opacity: 0.7;
}

.import-hint {
  margin: 8px 4px 0;
  color: #77777c;
  font-size: 13px;
  line-height: 1.45;
}

.section-title {
  margin: 26px 4px 9px;
  color: #5f5f63;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.subsection-title {
  margin: 18px 4px 8px;
  color: #77777c;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.group {
  background: #ffffff;
  border: 1px solid #d8d8dc;
  border-radius: 14px;
  overflow: hidden;
}

.field,
.switch-row {
  display: flex;
  align-items: center;
  height: 48px;
  padding: 4px 16px;
  border-bottom: 1px solid #e5e5e7;
}

.rule-row {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 4px 16px;
  border-bottom: 1px solid #e5e5e7;
}

.field:last-child,
.switch-row:last-child {
  border-bottom: 0;
}

.field label {
  width: 260px;
  flex: 0 0 260px;
  font-size: 17px;
  font-weight: 500;
}

.field input,
.field select,
.rule-row input,
.rule-row select {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 17px;
}

.field input,
.field select {
  text-align: right;
}

.field input::placeholder,
.rule-row input::placeholder {
  color: #a1a1a6;
}

details {
  margin-top: 26px;
}

summary {
  cursor: pointer;
  font-size: 17px;
  font-weight: 600;
  list-style-position: inside;
}

.advanced {
  margin-top: 12px;
}

.switch-row {
  justify-content: space-between;
  gap: 18px;
  font-size: 17px;
  font-weight: 500;
}

.switch-label {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
}

.platform-note {
  color: #8e8e93;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.ios-switch {
  position: relative;
  flex: 0 0 auto;
  width: 51px;
  height: 31px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-radius: 999px;
  background: #e9e9eb;
  outline: none;
  cursor: pointer;
  transition:
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.ios-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.18),
    0 2px 5px rgba(0, 0, 0, 0.08);
  transition: transform 0.18s ease;
}

.ios-switch:checked {
  background: #34c759;
}

.ios-switch:checked::after {
  transform: translateX(20px);
}

.ios-switch:focus-visible {
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.18);
}

.ios-switch:disabled {
  opacity: 0.45;
  cursor: default;
}

.on-demand-options {
  display: none;
  margin-top: 12px;
}

.on-demand-options.visible {
  display: block;
}

.manual-rules {
  display: none;
}

.manual-rules.visible {
  display: block;
}

.always-on-hint {
  display: none;
  margin: 10px 4px 0;
  color: #77777c;
  font-size: 13px;
  line-height: 1.45;
}

.always-on-hint.visible {
  display: block;
}

.rule-row {
  gap: 12px;
}

.rule-type {
  flex: 0 0 160px;
}

.rule-value {
  flex: 1 1 auto;
}

.rule-action {
  flex: 0 0 130px;
  text-align: right;
}

.remove-rule {
  flex: 0 0 auto;
  width: auto;
  min-height: 0;
  padding: 3px 5px;
  border: 0;
  background: transparent;
  color: #77777c;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.add-rule {
  width: 100%;
  height: 48px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}

.hint {
  margin: 8px 4px 0;
  color: #77777c;
  font-size: 13px;
  line-height: 1.45;
}

.action {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 30px;
}

.action-button {
  width: 100%;
  min-width: 0;
  height: 48px;
  border-radius: 12px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.install-button {
  border: 0;
  background: #1d1d1f;
  color: #ffffff;
}

.save-button {
  border: 1px solid #cfcfd4;
  background: #ffffff;
  color: #1d1d1f;
}

.action-button:active:not(:disabled) {
  opacity: 0.7;
}

.action-button:disabled {
  opacity: 1;
  cursor: default;
}

.install-button:disabled {
  border: 1px solid #d8d8dc;
  background: #e9e9eb;
  color: #9a9aa0;
}

.note {
  margin: 16px 4px 0;
  color: #77777c;
  font-size: 14px;
  line-height: 1.5;
}

.disclaimer {
  margin: 10px 4px 0;
  color: #8e8e93;
  font-size: 12px;
  line-height: 1.5;
}

.error {
  display: none;
  margin: 14px 4px 0;
  color: #b42318;
  font-size: 14px;
  line-height: 1.45;
}

@media (max-width: 680px) {
  .rule-row {
    flex-wrap: wrap;
    padding: 8px 16px;
  }

  .rule-type {
    flex: 1 1 42%;
  }

  .rule-value {
    flex: 1 1 42%;
  }

  .rule-action {
    flex: 1 1 calc(100% - 40px);
    text-align: right;
  }
}

@media (max-width: 560px) {
  main {
    padding-top: 28px;
  }

  h1 {
    font-size: 32px;
  }

  .field {
    display: block;
    height: auto;
    min-height: 48px;
    padding: 8px 16px;
  }

  .field label {
    display: block;
    width: auto;
    margin-bottom: 3px;
  }

  .field input,
  .field select {
    text-align: left;
  }

  .rule-type,
  .rule-value,
  .rule-action {
    flex: 1 1 100%;
  }

  .action {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .action-button {
    font-size: 16px;
  }
}

@media (prefers-color-scheme: dark) {
  body {
    background: #000000;
    color: #f5f5f7;
  }

  .back,
  .subtitle,
  .section-title,
  .build-number {
    color: #b8b8bd;
  }

  .group,
  .import-button,
  .save-button {
    background: #1c1c1e;
    border-color: #38383a;
  }

  .import-button,
  .save-button {
    color: #f5f5f7;
  }

  .field,
  .switch-row,
  .rule-row {
    border-color: #38383a;
  }

  .install-button {
    background: #f5f5f7;
    color: #1d1d1f;
  }

  .install-button:disabled {
    border: 1px solid #38383a;
    background: #2c2c2e;
    color: #6e6e73;
  }

  .ios-switch {
    background: #39393d;
  }

  .ios-switch:checked {
    background: #30d158;
  }

  .note,
  .hint,
  .subsection-title,
  .always-on-hint,
  .remove-rule,
  .import-hint,
  .platform-note,
  .disclaimer {
    color: #9a9aa0;
  }

  .error {
    color: #ffb4ab;
  }
}
