/* ── Settings page ─────────────────────────────────────────────────────── */

.settingsWrap {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  font-size: 15px;
}

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

.settingsCard { padding: 16px; border-radius: 14px; }

.settingsTitle {
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.2px;
}

.settingsSectionTitle {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.2px;
  margin: 0 0 10px;
}

.hrClean {
  height: 1px;
  border: 0;
  background: var(--border);
  margin: 12px 0;
}

.switchRow {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
}

@media (min-width: 641px) {
  .switchRow { grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr); }
}

.fieldTitle { color: var(--muted); font-size: 12px; margin: 0 0 6px; }

.nameBlock .input { height: 50px; }
.switchWrap { display: flex; flex-direction: column; padding-top: 2px; }

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  height: 50px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0f1318;
  user-select: none;
}
.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switchLabel {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 100%;
}
.switchStatus {
  font-size: 14px;
  line-height: 1.2;
  color: var(--text);
  opacity: 0.92;
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.switchStatus.muted {
  color: var(--muted);
  opacity: 1;
  font-weight: 750;
}

.switchPill {
  width: 46px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(125, 211, 252, 0.22);
  background: rgba(125, 211, 252, 0.10);
  box-shadow: 0 0 0 1px rgba(125, 211, 252, 0.07) inset;
  position: relative;
  flex: 0 0 auto;
}
.switchKnob {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(154, 166, 178, 0.95);
  position: absolute;
  top: 50%;
  left: 3px;
  transform: translateY(-50%);
  transition: left 160ms ease, background 160ms ease, box-shadow 160ms ease;
  box-shadow: 0 1px 0 rgba(0,0,0,0.35);
}
.switch.isOn .switchPill {
  border-color: rgba(125, 211, 252, 0.55);
  background: rgba(125, 211, 252, 0.22);
  box-shadow:
    0 0 0 1px rgba(125, 211, 252, 0.12) inset,
    0 0 0 4px rgba(125, 211, 252, 0.07);
}
.switch.isOn .switchKnob {
  left: 21px;
  background: rgba(125, 211, 252, 0.98);
  box-shadow:
    0 0 0 3px rgba(125, 211, 252, 0.16),
    0 1px 0 rgba(0,0,0,0.28);
}

.switch.mini {
  height: 40px;
  border-radius: 12px;
  padding: 0 10px;
}
.switch.mini .switchStatus { font-size: 13px; font-weight: 850; }
.switch.mini .switchPill { width: 42px; height: 26px; }
.switch.mini .switchKnob { width: 20px; height: 20px; }
.switch.mini.isOn .switchKnob { left: 19px; }

.subtleNote {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.25;
}

.nameBlock { padding-top: 2px; }

.linkSection {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0;
  margin-top: 20px;
}
.linkRow {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.linkBadge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  padding: 6px 12px;
  line-height: 1.2;
}
.linkBadgeDisabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.saveArea {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.saveStatus {
  margin-top: -2px;
  margin-bottom: -2px;
  min-height: 0;
  display: none;
}
.saveStatus.isOn { display: block; }

.saveBtn {
  width: 100%;
  padding: 14px 12px;
  border-radius: 12px;
  font-weight: 900;
  letter-spacing: 0.2px;
  border-color: rgba(125, 211, 252, 0.28);
  box-shadow: 0 0 0 1px rgba(125, 211, 252, 0.10) inset;
}

.stRuleCard {
  padding: 12px;
  border-radius: 12px;
  background: #0f1318;
  border: 1px solid rgba(125, 211, 252, 0.18);
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.35) inset,
    0 10px 18px rgba(0,0,0,0.22);
}

.stRuleHeader {
  display: grid;
  grid-template-columns: 1fr 40px;
  gap: 10px;
  align-items: center;
}

@media (min-width: 641px) {
  .stRuleHeader { grid-template-columns: 1fr 1fr 40px; }
  .stRuleEvent { grid-column: 1; }
  .stRuleScope { grid-column: 2; }
  .ruleTrashBtn { grid-column: 3; justify-self: end; }
}

@media (max-width: 640px) {
  .stRuleEvent { grid-column: 1; grid-row: 1; }
  .ruleTrashBtn { grid-column: 2; grid-row: 1; justify-self: end; }
  .stRuleHeader .stRuleScope { grid-column: 1 / -1; grid-row: 2; }
}

.hrRule {
  height: 2px;
  border: 0;
  margin: 12px 2px;
  background: linear-gradient(
    90deg,
    rgba(125,211,252,0.00),
    rgba(125,211,252,0.55),
    rgba(125,211,252,0.00)
  );
  opacity: 0.95;
}

#rulesWrap { gap: 0 !important; }

@media (max-width: 640px) {
  .hrRule { margin: 14px 0; }
}

.stSelect {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  background: #0f1318;
  color: var(--text);
  border-radius: 10px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa6b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 12px;
  padding: 6px 28px 6px 10px;
  font-size: 13px;
  line-height: 1;
  outline: none;
}
.stSelect:hover { border-color: #2f3a46; cursor: pointer; }
.stSelect:focus { border-color: #37566b; outline: 1px solid #37566b; }
.stSelect:disabled { opacity: 0.55; cursor: not-allowed; }

.stRuleRows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.stRuleRow {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: center;
}

@media (min-width: 641px) {
  .stRuleRow { grid-template-columns: minmax(220px, 300px) 1fr; }
}

.stRuleInput {
  height: 40px;
  padding: 10px 12px;
}
.stRuleInput:disabled { opacity: 0.55; }

.stRuleNote { margin-top: 2px; }

.ruleTrashBtn {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ruleTrashBtn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 640px) {
  .settingsWrap { padding-bottom: 130px; }
  .saveArea {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0;
    width: calc(100% - 28px);
    max-width: 980px;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
    background: rgba(18,22,27,0.92);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 14px;
    z-index: 1000;
  }
}

.addRuleRow { margin-top: 12px; }
.addRuleBtn { width: 100%; }

@media (prefers-color-scheme: light) {
  .switch { background: var(--lt-control); }
  .stRuleCard { background: var(--lt-surface); }
  .stSelect {
    background-color: var(--lt-control);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  }
  .stSelect:hover { border-color: var(--lt-hover); }
  .stSelect:focus { border-color: #3d7fa8; outline-color: #3d7fa8; }
  /* Mobile sticky save bar */
  .saveArea { background: var(--lt-sticky-bg); }
}

html[data-theme="light"] .switch { background: var(--lt-control); }
html[data-theme="light"] .stRuleCard { background: var(--lt-surface); }
html[data-theme="light"] .stSelect {
  background-color: var(--lt-control);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
html[data-theme="light"] .stSelect:hover { border-color: var(--lt-hover); }
html[data-theme="light"] .stSelect:focus { border-color: #3d7fa8; outline-color: #3d7fa8; }
html[data-theme="light"] .saveArea { background: var(--lt-sticky-bg); }

html[data-theme="dark"] .switch { background: #0f1318; }
html[data-theme="dark"] .stRuleCard { background: #0f1318; }
html[data-theme="dark"] .stSelect {
  background-color: #0f1318;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa6b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
html[data-theme="dark"] .stSelect:hover { border-color: #2f3a46; }
html[data-theme="dark"] .stSelect:focus { border-color: #37566b; outline-color: #37566b; }
html[data-theme="dark"] .saveArea { background: rgba(18,22,27,0.92); }
