/* ── Modal base ── */
.modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-wrap[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  width: 100%;
  max-width: 720px;
  max-height: calc(100vh - 48px);
  background: color-mix(in srgb, var(--bg) 93%, transparent);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (min-width: 600px) {
  .modal-wrap { align-items: center; padding: 1rem; }
  .modal-panel { border-radius: var(--radius-lg); max-height: calc(100vh - 48px); }
}

.modal-header {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.modal-header h2 { font-size: 0.95rem; font-weight: 600; flex: 1; }

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  padding: 0.25rem 0.4rem;
  border-radius: var(--radius-sm);
}
.modal-close:hover { color: var(--text); }

.modal-body { display: flex; flex: 1; overflow: hidden; }

/* ── Settings tabs ── */
#settings-tabs {
  width: 136px;
  flex-shrink: 0;
  border-right: 1px solid var(--glass-border);
  padding: 0.6rem 0;
  overflow-y: auto;
}

.tab-btn {
  display: block;
  width: 100%;
  padding: 0.55rem 1rem;
  text-align: left;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.82rem;
  transition: color 0.15s, background 0.15s;
}
.tab-btn:hover { color: var(--text); background: var(--subtle); }
.tab-btn.active { color: var(--accent); font-weight: 600; background: var(--subtle); }

#settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem 1.25rem;
}

/* ── Settings form components ── */
.s-section {
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 1.1rem 0 0.5rem;
}
.s-section:first-child { margin-top: 0; }

.s-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--glass-border);
}
.s-row:last-child { border-bottom: none; }

.s-label { flex: 1; min-width: 0; }
.s-label strong { display: block; font-size: 0.85rem; font-weight: 500; }
.s-label span { display: block; font-size: 0.78rem; color: var(--muted); margin-top: 0.1rem; }

.s-ctrl {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.s-input, .s-select {
  background: var(--subtle);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 0.38rem 0.6rem;
  color: var(--text);
  font-size: 0.82rem;
  outline: none;
  min-width: 150px;
  max-width: 100%;
  box-sizing: border-box;
}
.s-input:focus, .s-select:focus { border-color: var(--accent); }
.s-select option { background: var(--bg); }
.s-input-wide { min-width: min(220px, 100%); }
.s-input-full { width: 100%; min-width: 0; }

.s-textarea {
  background: var(--subtle);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 0.38rem 0.6rem;
  color: var(--text);
  font-size: 0.82rem;
  outline: none;
  width: 100%;
  resize: vertical;
  min-height: 80px;
}
.s-textarea:focus { border-color: var(--accent); }

/* ── Toggle ── */
.s-toggle {
  position: relative;
  width: 38px; height: 21px;
  flex-shrink: 0;
  cursor: pointer;
}
.s-toggle input { opacity: 0; position: absolute; width: 0; height: 0; }
.s-track {
  position: absolute;
  inset: 0;
  background: var(--subtle);
  border: 1px solid var(--glass-border);
  border-radius: 11px;
  transition: background 0.2s, border-color 0.2s;
}
.s-toggle input:checked ~ .s-track { background: var(--accent); border-color: var(--accent); }
.s-track::after {
  content: '';
  position: absolute;
  width: 15px; height: 15px;
  background: #fff;
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: transform 0.2s;
}
.s-toggle input:checked ~ .s-track::after { transform: translateX(17px); }
.s-toggle:focus-within .s-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Buttons ── */
.s-btn {
  padding: 0.4rem 0.9rem;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-md);
  color: #000;
  font-size: 0.82rem;
  font-weight: 600;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.s-btn:hover { opacity: 0.85; }
.s-btn.ghost {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text);
  font-weight: 400;
}
.s-btn.ghost:hover { background: var(--subtle); }
.s-btn.danger {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger-text);
  font-weight: 400;
}
.s-btn.danger:hover { background: rgba(239,68,68,0.22); }
.s-btn.sm { padding: 0.28rem 0.65rem; font-size: 0.75rem; }

/* ── Style preset grid ── */
.style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 0.55rem;
  margin-top: 0.65rem;
}
.style-card {
  padding: 0.55rem;
  border: 2px solid var(--glass-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s;
  background: none;
}
.style-card:hover { border-color: var(--muted); }
.style-card.active { border-color: var(--accent); }
.style-swatch { height: 32px; border-radius: var(--radius-sm); margin-bottom: 0.35rem; }
.style-name { font-size: 0.72rem; font-weight: 500; color: var(--text); }

/* ── Color swatch input ── */
.color-swatch {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 2px solid var(--glass-border);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  flex-shrink: 0;
}
.color-swatch input[type="color"] {
  width: 130%; height: 130%;
  border: none;
  padding: 0;
  margin: -15% 0 0 -15%;
  cursor: pointer;
}

/* ── Mode/option pills ── */
.mode-group { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.mode-opt {
  padding: 0.3rem 0.6rem;
  background: var(--subtle);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  color: var(--muted);
  transition: all 0.15s;
}
.mode-opt:hover { color: var(--text); }
.mode-opt.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}

/* ── Links editor ── */
.folders-list { display: flex; flex-direction: column; gap: 0.65rem; }
.lfe {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.lfe-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  background: var(--subtle);
}
.lfe-fold-name {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  outline: none;
}
.lfe-fold-name:focus { text-decoration: underline; text-decoration-color: var(--accent); }
.lfe-fold-del { background: none; border: none; color: var(--muted); font-size: 0.85rem; }
.lfe-fold-del:hover { color: var(--danger-text); }
.lfe-links { padding: 0.5rem 0.75rem; display: flex; flex-direction: column; gap: 0.35rem; }
.lfe-link-row { display: flex; align-items: center; gap: 0.35rem; }
.lfe-ln, .lfe-lu {
  background: var(--subtle);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 0.28rem 0.5rem;
  color: var(--text);
  font-size: 0.78rem;
  outline: none;
  flex: 1;
}
.lfe-ln { max-width: 120px; }
.lfe-ln:focus, .lfe-lu:focus { border-color: var(--accent); }
.lfe-fav { background: none; border: none; cursor: pointer; font-size: 0.85rem; opacity: 0.35; transition: opacity 0.15s; }
.lfe-fav.on { opacity: 1; color: var(--accent); }
.lfe-link-del { background: none; border: none; color: var(--muted); font-size: 0.8rem; }
.lfe-link-del:hover { color: var(--danger-text); }
.lfe-add-link {
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.28rem;
  background: none;
  border: 1px dashed var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.78rem;
  cursor: pointer;
}
.lfe-add-link:hover { color: var(--text); border-color: var(--accent); }
.add-folder-btn {
  width: 100%;
  padding: 0.5rem;
  background: var(--glass-bg);
  border: 1px dashed var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.add-folder-btn:hover { color: var(--text); border-color: var(--accent); }

/* ── Widget accordion in settings ── */
.widget-section {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  margin-bottom: 0.65rem;
  overflow: hidden;
}
.widget-section-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.85rem;
  background: var(--subtle);
  cursor: pointer;
}
.widget-section-icon { font-size: 1rem; flex-shrink: 0; }
.widget-section-title { flex: 1; font-size: 0.88rem; font-weight: 500; }
.widget-section-desc { font-size: 0.75rem; color: var(--muted); display: none; }
.widget-section-body {
  padding: 0 0.85rem;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, padding 0.25s ease;
}
.widget-section.open .widget-section-body {
  padding: 0.5rem 0.85rem 0.85rem;
  max-height: 1400px;
}
.widget-section-caret {
  font-size: 0.7rem;
  color: var(--muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.widget-section.open .widget-section-caret { transform: rotate(180deg); }

/* ── About/info cards ── */
.about-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  margin-bottom: 0.75rem;
}
.about-card p { font-size: 0.85rem; color: var(--muted); line-height: 1.7; }
.about-card p strong { color: var(--text); }

.kofi-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  background: #ff5e5b;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  margin-top: 0.85rem;
  transition: opacity 0.15s;
}
.kofi-link:hover { opacity: 0.85; }

.repo-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  background: var(--subtle);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  margin-top: 0.75rem;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.repo-link:hover {
  background: var(--glass-bg);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Privacy panel ── */
.privacy-feature {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--glass-border);
}
.privacy-feature:last-child { border-bottom: none; }
.privacy-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 0.45rem;
}
.privacy-dot.local   { background: var(--success); }
.privacy-dot.external { background: var(--warning); }
.privacy-feature-info { flex: 1; min-width: 0; }
.privacy-feature-name { font-size: 0.85rem; font-weight: 500; }
.privacy-feature-desc { font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; line-height: 1.5; }

/* ── Help & Shortcuts ── */
.shortcut-group { margin-bottom: 1.1rem; }
.shortcut-group-title {
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.55rem;
}
.shortcut-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--glass-border) 50%, transparent);
  font-size: 0.85rem;
}
.shortcut-row:last-child { border-bottom: none; }
.shortcut-keys { display: flex; gap: 0.25rem; flex-shrink: 0; }
kbd {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  background: var(--subtle);
  border: 1px solid var(--glass-border);
  border-radius: 5px;
  font-size: 0.75rem;
  font-family: inherit;
  color: var(--text);
}
.shortcut-desc { flex: 1; color: var(--muted); }

/* ── Range slider ── */
.s-range {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 4px;
  border-radius: 2px;
  background: var(--subtle);
  outline: none;
  cursor: pointer;
}
.s-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid transparent;
}
.s-range:focus::-webkit-slider-thumb { border-color: color-mix(in srgb, var(--accent) 70%, transparent); }

/* ── Layout editor ── */
.widget-order-list { display: flex; flex-direction: column; gap: 0.4rem; }
.widget-order-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
}
.widget-order-handle {
  cursor: grab;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0 0.2rem;
  user-select: none;
}
.widget-order-name { flex: 1; }
.widget-order-arrows { display: flex; gap: 0.2rem; }
.widget-order-arrow {
  background: none;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.75rem;
  width: 24px; height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.widget-order-arrow:hover { color: var(--text); border-color: var(--muted); }
.widget-order-arrow:disabled { opacity: 0.3; cursor: default; }

/* ── RSS preset picker ── */
.rss-preset-picker { display: flex; flex-direction: column; gap: 0.65rem; }
.rss-preset-search {
  background: var(--subtle);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 0.38rem 0.7rem;
  color: var(--text);
  font-size: 0.82rem;
  outline: none;
  width: 100%;
}
.rss-preset-search:focus { border-color: var(--accent); }
.rss-preset-category { margin-bottom: 0.35rem; }
.rss-preset-cat-label {
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.rss-preset-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.4rem 0;
  cursor: pointer;
  border-bottom: 1px solid color-mix(in srgb, var(--glass-border) 40%, transparent);
}
.rss-preset-item:last-child { border-bottom: none; }
.rss-preset-item input[type="checkbox"] { flex-shrink: 0; accent-color: var(--accent); margin-top: 0.2rem; }
.rss-preset-item-info { flex: 1; }
.rss-preset-item-name { font-size: 0.85rem; font-weight: 500; }
.rss-preset-item-desc { font-size: 0.75rem; color: var(--muted); margin-top: 0.05rem; }

/* ── Feed list in settings ── */
.feed-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  max-height: 260px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.feed-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.7rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  min-width: 0;
  flex-shrink: 0;
}
.feed-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.feed-item-del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.8rem; flex-shrink: 0; }
.feed-item-del:hover { color: var(--danger-text); }
