.app-settings-container {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-5);
}

.app-settings-title {
  font-family: 'Newsreader', 'Noto Serif SC', serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--fg-primary);
  margin-bottom: var(--space-1);
}

.app-settings-desc {
  color: var(--fg-secondary);
  font-size: 0.875rem;
  margin-bottom: var(--space-5);
}

.app-settings-input-group {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.app-settings-url-input {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--rule-line);
  border-radius: var(--radius-input);
  font-size: 0.875rem;
  background: var(--bg-surface);
  color: var(--fg-primary);
  transition: border-color var(--duration-fast) var(--ease-standard);
}

.app-settings-url-input:focus {
  outline: none;
  border-color: var(--ink-cobalt);
  box-shadow: var(--shadow-inset);
}

.app-settings-init-btn {
  padding: var(--space-2) var(--space-4);
  border: none;
  border-radius: var(--radius-btn);
  background: var(--ink-cobalt);
  color: var(--fg-on-cobalt);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-standard);
}

.app-settings-init-btn:hover:not(:disabled) {
  background: var(--ink-cobalt-deep);
}

.app-settings-init-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.app-settings-url-error {
  color: var(--danger);
  font-size: 0.75rem;
  margin-bottom: var(--space-3);
}

.app-settings-toggle-link {
  font-size: 0.8rem;
  margin-bottom: var(--space-3);
}

.app-settings-toggle-link a {
  color: var(--ink-cobalt);
  text-decoration: none;
}

.app-settings-toggle-link a:hover {
  text-decoration: underline;
}

/* ─── Account info card ─────────────────────────────────────────────── */

.app-settings-account-card {
  border: 1px solid var(--rule-line);
  border-radius: var(--radius-tight);
  background: var(--bg-surface);
  padding: var(--space-4);
  margin-top: var(--space-3);
  margin-bottom: var(--space-4);
}

.app-settings-account-row {
  display: flex;
  align-items: baseline;
  padding: var(--space-1) 0;
  gap: var(--space-3);
}

.app-settings-account-label {
  flex-shrink: 0;
  width: 80px;
  font-size: 0.8rem;
  color: var(--fg-muted);
  text-align: right;
}

.app-settings-account-value {
  font-size: 0.875rem;
  color: var(--fg-primary);
  word-break: break-all;
}

.app-settings-account-mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
}

.app-settings-account-link {
  color: var(--ink-cobalt);
  text-decoration: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
}

.app-settings-account-link:hover {
  text-decoration: underline;
}

.app-settings-tables-details {
  margin-top: var(--space-3);
  border-top: 1px solid var(--rule-line);
  padding-top: var(--space-2);
}

.app-settings-tables-details summary {
  font-size: 0.8rem;
  color: var(--fg-secondary);
  cursor: pointer;
  user-select: none;
}

.app-settings-tables-grid {
  margin-top: var(--space-2);
}

.app-settings-table-row {
  display: flex;
  align-items: baseline;
  padding: 2px 0;
  gap: var(--space-3);
}

.app-settings-table-name {
  flex-shrink: 0;
  width: 140px;
  font-size: 0.8rem;
  color: var(--fg-secondary);
  text-align: right;
}

.app-settings-table-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--fg-muted);
}

.app-settings-reinit-btn {
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--rule-line);
  border-radius: var(--radius-btn);
  background: transparent;
  color: var(--fg-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-standard),
              color var(--duration-fast) var(--ease-standard);
}

.app-settings-reinit-btn:hover {
  border-color: var(--ink-cobalt);
  color: var(--ink-cobalt);
}

.app-settings-readonly-hint {
  margin-top: var(--space-3);
  font-size: 0.8rem;
  color: var(--fg-secondary);
}

.app-settings-rebind-details {
  margin-top: var(--space-2);
  border-top: 1px solid var(--rule-line);
  padding-top: var(--space-2);
}

.app-settings-rebind-details summary {
  font-size: 0.8rem;
  color: var(--fg-secondary);
  cursor: pointer;
  user-select: none;
}

/* ─── Log & summary ─────────────────────────────────────────────────── */

.app-settings-log {
  border: 1px solid var(--rule-line);
  border-radius: var(--radius-tight);
  padding: var(--space-3);
  max-height: 400px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  line-height: 1.6;
  background: var(--bg-sunken);
  margin-top: var(--space-3);
}

.app-settings-log-entry {
  padding: 2px 0;
}

.app-settings-log-entry--success { color: var(--good); }
.app-settings-log-entry--error { color: var(--danger); }
.app-settings-log-entry--skipped { color: var(--fg-muted); }
.app-settings-log-entry--warning { color: var(--warn); }
.app-settings-log-entry--info { color: var(--fg-secondary); }

.app-settings-log-timestamp {
  color: var(--fg-muted);
  margin-right: var(--space-2);
}

.app-settings-summary {
  margin-top: var(--space-4);
  padding: var(--space-3);
  border: 1px solid var(--rule-line);
  border-radius: var(--radius-tight);
  background: var(--bg-surface);
  font-size: 0.875rem;
  color: var(--fg-primary);
}

/* ─── Governed domain-memory review inbox ──────────────────────────── */

.domain-memory-panel {
  margin: var(--space-5) 0;
  padding: 18px;
  border: 1px solid var(--rule-line);
  border-radius: var(--radius-card);
  background: var(--bg-surface);
  box-shadow: var(--shadow-1);
}

.domain-memory-header,
.domain-memory-candidate-heading,
.domain-memory-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.domain-memory-header h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--fg-primary);
}

.domain-memory-mode,
.domain-memory-intro,
.domain-memory-status,
.domain-memory-provenance,
.domain-memory-empty {
  margin-top: 4px;
  color: var(--fg-muted);
  font-size: 12px;
  line-height: 1.5;
}

.domain-memory-mode[data-mode="shadow"] {
  color: var(--system-1);
}

.domain-memory-mode[data-mode="assist"] {
  color: var(--good);
}

.domain-memory-refresh,
.domain-memory-btn {
  border: 1px solid var(--rule-line-strong);
  border-radius: var(--radius-btn);
  background: var(--bg-surface);
  color: var(--fg-secondary);
  padding: 7px 12px;
  cursor: pointer;
}

.domain-memory-refresh:disabled,
.domain-memory-btn:disabled {
  cursor: wait;
  opacity: .55;
}

.domain-memory-status.is-error,
.domain-memory-action-status.is-error {
  color: var(--danger);
}

.domain-memory-candidates {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.domain-memory-candidate {
  padding: 15px;
  border: 1px solid var(--rule-line);
  border-radius: var(--radius-tight);
  background: var(--bg-canvas);
}

.domain-memory-candidate-term {
  display: block;
  color: var(--fg-primary);
  font-size: 15px;
}

.domain-memory-concept-id,
.domain-memory-kind {
  font-family: var(--font-mono);
  font-size: 11px;
}

.domain-memory-concept-id {
  display: block;
  margin-top: 3px;
  color: var(--fg-muted);
  overflow-wrap: anywhere;
}

.domain-memory-kind {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: var(--radius-pill);
  color: var(--ink-cobalt);
  background: var(--ink-cobalt-soft);
}

.domain-memory-evidence {
  margin: 12px 0;
  padding: 10px 12px;
  border-left: 3px solid var(--system-1);
  background: var(--bg-sunken);
}

.domain-memory-evidence-label,
.domain-memory-field-label {
  color: var(--fg-secondary);
  font-size: 11px;
  font-weight: 600;
}

.domain-memory-evidence blockquote {
  margin: 5px 0 0;
  color: var(--fg-primary);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.domain-memory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.domain-memory-field {
  display: grid;
  gap: 4px;
  margin-top: 10px;
}

.domain-memory-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 8px 9px;
  border: 1px solid var(--rule-line);
  border-radius: var(--radius-input);
  background: var(--bg-surface);
  color: var(--fg-primary);
  font: inherit;
  font-size: 13px;
}

textarea.domain-memory-input {
  resize: vertical;
  line-height: 1.5;
}

.domain-memory-input:focus {
  outline: none;
  border-color: var(--ink-cobalt);
  box-shadow: 0 0 0 2px var(--ink-cobalt-soft);
}

.domain-memory-group {
  margin: 12px 0 0;
  padding: 0;
  border: 0;
}

fieldset.domain-memory-group > legend,
.domain-memory-rule > summary {
  color: var(--ink-cobalt);
  font-size: 12px;
  font-weight: 600;
}

.domain-memory-rule > summary {
  cursor: pointer;
}

.domain-memory-action-status {
  margin-top: 12px;
  color: var(--fg-secondary);
  font-size: 12px;
}

.domain-memory-actions {
  justify-content: flex-end;
  margin-top: 12px;
}

.domain-memory-btn--reject {
  color: var(--danger);
}

.domain-memory-btn--confirm {
  border-color: var(--ink-cobalt);
  background: var(--ink-cobalt);
  color: var(--fg-on-cobalt);
}

@media (max-width: 560px) {
  .domain-memory-grid {
    grid-template-columns: 1fr;
  }

  .domain-memory-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .domain-memory-btn {
    width: 100%;
  }
}

/* ─── Rest reminder settings (redesigned) ───────────────────────────── */

.rest-panel { display: block; }

/* master switch */
.rest-master {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--bg-surface); border: 1px solid var(--rule-line);
  border-radius: var(--radius-card); padding: 16px 18px; box-shadow: var(--shadow-1);
}
.rest-master-text h2 {
  font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--fg-primary);
}
.rest-master-sub { font-size: 12.5px; color: var(--fg-muted); margin-top: 2px; }

/* toggle switch (hidden native checkbox + track/knob) */
.rest-switch { position: relative; width: 46px; height: 27px; flex: 0 0 auto; cursor: pointer; }
.rest-switch input[type="checkbox"] {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0;
  opacity: 0; cursor: pointer; z-index: 2; -webkit-appearance: none; appearance: none;
}
.rest-switch-track {
  position: absolute; inset: 0; background: var(--bg-sunken);
  border: 1px solid var(--rule-line-strong); border-radius: var(--radius-pill);
  transition: background var(--duration-base) var(--ease-standard), border-color var(--duration-base) var(--ease-standard);
}
.rest-switch-knob {
  position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; background: #fff;
  border-radius: 50%; box-shadow: var(--shadow-1);
  transition: transform var(--duration-base) var(--ease-standard);
}
.rest-switch input:checked ~ .rest-switch-track { background: var(--ink-cobalt); border-color: var(--ink-cobalt); }
.rest-switch input:checked ~ .rest-switch-knob { transform: translateX(19px); }
.rest-switch input:focus-visible ~ .rest-switch-track { box-shadow: 0 0 0 3px var(--ink-cobalt-soft); }

/* collapsible body */
.rest-body { margin-top: 18px; display: grid; gap: 18px; transition: opacity var(--duration-base) var(--ease-standard); }
.rest-body.off { opacity: .4; pointer-events: none; filter: grayscale(.3); }

/* cards */
.rest-card {
  background: var(--bg-surface); border: 1px solid var(--rule-line);
  border-radius: var(--radius-card); padding: 18px; box-shadow: var(--shadow-1);
}
.rest-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.rest-card-title { font-family: var(--font-display); font-size: 17px; font-weight: 600; color: var(--fg-primary); }
.rest-card-title--leaf::before { content: "🌿 "; }
.rest-card-note { font-size: 12.5px; color: var(--fg-muted); margin-top: 4px; line-height: 1.5; }

/* timeline */
.rest-tl-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.rest-tl-title { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.rest-eyebrow {
  font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-secondary);
}
.rest-preview-tag {
  flex: none; font-size: 10.5px; font-weight: 600; letter-spacing: .04em; line-height: 1;
  padding: 3px 7px; border-radius: var(--radius-pill); white-space: nowrap;
  color: var(--fg-muted); background: var(--bg-sunken); border: 1px solid var(--rule-line-strong);
}
.rest-seg { display: inline-flex; background: var(--bg-sunken); border-radius: var(--radius-pill); padding: 3px; gap: 2px; }
.rest-seg button {
  border: 0; background: transparent; font-family: var(--font-ui); font-size: 12px; font-weight: 600;
  color: var(--fg-secondary); padding: 5px 12px; border-radius: var(--radius-pill); cursor: pointer;
  transition: all var(--duration-fast) var(--ease-standard);
}
.rest-seg button.active { background: #fff; color: var(--ink-cobalt); box-shadow: var(--shadow-1); }
.rest-band {
  position: relative; height: 34px; border-radius: var(--radius-tight); overflow: hidden;
  background: var(--system-1-soft);
}
.rest-band .work { position: absolute; top: 0; bottom: 0; background: var(--ink-cobalt); opacity: .92; }
.rest-band .work span {
  position: absolute; left: 6px; top: 50%; transform: translateY(-50%); color: #fff;
  font-size: 10.5px; font-weight: 600; font-family: var(--font-mono); white-space: nowrap; overflow: hidden;
}
.rest-band .now { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--danger); z-index: 3; }
.rest-band .pin {
  position: absolute; top: -3px; transform: translateX(-50%); z-index: 4;
  width: 9px; height: 9px; border-radius: 50%; background: var(--system-1);
  border: 1.5px solid #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
.rest-ticks { position: relative; height: 16px; margin-top: 4px; }
.rest-ticks span {
  position: absolute; transform: translateX(-50%); font-family: var(--font-mono); font-size: 10px; color: var(--fg-muted);
}
.rest-legend { display: flex; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.rest-legend i { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--fg-secondary); font-style: normal; }
.rest-legend .sw { width: 11px; height: 11px; border-radius: 3px; }
.rest-legend .sw.work { background: var(--ink-cobalt); }
.rest-legend .sw.slow { background: var(--system-1); }

/* fields */
.rest-field { margin-top: 16px; }
.rest-field:first-of-type { margin-top: 0; }
.rest-flabel {
  display: block; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--fg-secondary); margin-bottom: 9px;
}

/* day pills */
.rest-days { display: flex; gap: 6px; }
.rest-day {
  flex: 1; height: 38px; border: 1px solid var(--rule-line-strong); border-radius: var(--radius-tight);
  background: var(--bg-surface); color: var(--fg-secondary); font-family: var(--font-ui);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all var(--duration-fast) var(--ease-standard);
}
.rest-day.on { background: var(--ink-cobalt); border-color: var(--ink-cobalt); color: #fff; }
.rest-day.weekend { font-weight: 500; }
.rest-day.weekend.on { background: var(--system-1); border-color: var(--system-1); }
.rest-day-hint { font-size: 12px; color: var(--fg-muted); margin-top: 8px; line-height: 1.5; }

/* time range + stepper */
.rest-range { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.rest-rl { width: 56px; font-size: 12.5px; color: var(--fg-secondary); flex: 0 0 auto; }
.rest-rl-note { font-size: 12px; color: var(--fg-muted); }
.rest-dash { color: var(--fg-muted); }
.rest-timefield {
  display: inline-flex; align-items: center; background: var(--bg-sunken);
  border: 1px solid var(--rule-line); border-radius: var(--radius-pill); overflow: hidden; flex: 0 0 auto;
}
.rest-timefield button {
  border: 0; background: transparent; width: 30px; height: 34px; font-size: 16px;
  color: var(--fg-secondary); cursor: pointer; line-height: 1; transition: background var(--duration-fast);
}
.rest-timefield button:hover { background: var(--rule-line); }
.rest-panel .rest-timefield input {
  width: 54px; border: 0; background: transparent; text-align: center; font-family: var(--font-mono);
  font-size: 14px; font-weight: 500; color: var(--fg-primary); padding: 0; -webkit-appearance: none; appearance: none;
}
.rest-panel .rest-timefield input:focus { outline: none; }

/* advanced disclosure */
.rest-adv { margin-top: 16px; border-top: 1px solid var(--rule-line); padding-top: 12px; }
.rest-adv summary {
  font-size: 12.5px; font-weight: 600; color: var(--ink-cobalt); cursor: pointer;
  list-style: none; display: flex; align-items: center; gap: 6px;
}
.rest-adv summary::-webkit-details-marker { display: none; }
.rest-adv summary::before { content: "▸"; transition: transform var(--duration-fast); }
.rest-adv[open] summary::before { transform: rotate(90deg); }
.rest-intensity { display: flex; gap: 8px; margin-top: 12px; }
.rest-tier {
  flex: 1; text-align: center; border: 1px solid var(--rule-line); border-radius: var(--radius-tight);
  padding: 10px 6px; background: var(--bg-canvas);
}
.rest-tier .lvl { font-size: 11px; font-weight: 600; color: var(--fg-secondary); }
.rest-tier .cad { display: block; font-family: var(--font-mono); font-size: 15px; font-weight: 700; margin-top: 3px; }
.rest-tier .cad i { font-style: normal; font-size: 10px; color: var(--fg-muted); }
.rest-tier.low .cad { color: var(--good); }
.rest-tier.mid .cad { color: var(--system-1); }
.rest-tier.high .cad { color: var(--danger); }
.rest-adv-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.rest-adv-l { font-size: 12.5px; color: var(--fg-secondary); }
.rest-panel .rest-num {
  width: 64px; border: 1px solid var(--rule-line); border-radius: var(--radius-tight); background: var(--bg-surface);
  font-family: var(--font-mono); font-size: 13px; text-align: center; padding: 7px 0; color: var(--fg-primary);
}
.rest-adv-note { font-size: 11.5px; color: var(--fg-muted); margin-top: 10px; line-height: 1.5; }

/* holiday reveal */
.rest-reveal {
  overflow: hidden; max-height: 400px; opacity: 1; margin-top: 16px;
  transition: max-height var(--duration-slow) var(--ease-standard), opacity var(--duration-base) var(--ease-standard), margin var(--duration-base);
}
.rest-reveal.hide { max-height: 0; opacity: 0; margin-top: 0; }

.rest-savehint { text-align: center; font-size: 12px; color: var(--fg-muted); }
.app-settings-rest-error { color: var(--danger); font-size: 12px; text-align: center; }
