html[data-theme="light"] {
  color-scheme: light;
  --bg: #eef0f4;
  --surface: #ffffff;
  --text: #1c1d21;
  --muted: #5c5f69;
  --border: #e2e5eb;
  --accent: #3d4f6f;
  --accent-soft: #e8ecf4;
  --shadow: 0 1px 3px rgba(28, 29, 33, 0.06), 0 6px 20px rgba(28, 29, 33, 0.06);
  --emphasis-border: #d8dee9;
  --text-link-hover: #2d3d56;
  --modal-backdrop: rgba(22, 24, 30, 0.42);
  --modal-panel-border: rgba(226, 229, 235, 0.95);
  --modal-shadow: 0 4px 6px rgba(28, 29, 33, 0.04), 0 22px 56px rgba(28, 29, 33, 0.14);
  --control-hover-bg: rgba(28, 29, 33, 0.06);
  --btn-on-accent: #ffffff;
  --toast-bg: #1c1d21;
  --toast-fg: #f4f4f5;
  --toast-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 12px 32px rgba(0, 0, 0, 0.18);
  --social-img-base: none;
  --social-img-hover: brightness(0.82) contrast(1.08);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #13161c;
  --surface: #1b2029;
  --text: #e9ebf0;
  --muted: #9aa3b4;
  --border: #2e3542;
  --accent: #9ab6dc;
  --accent-soft: #252d3b;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 8px 28px rgba(0, 0, 0, 0.45);
  --emphasis-border: #3a4558;
  --text-link-hover: #c8daf5;
  --modal-backdrop: rgba(0, 0, 0, 0.58);
  --modal-panel-border: rgba(52, 58, 72, 0.96);
  --modal-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  --control-hover-bg: rgba(255, 255, 255, 0.08);
  --btn-on-accent: #ffffff;
  --toast-bg: #e9ebf0;
  --toast-fg: #13161c;
  --toast-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  --social-img-base: brightness(1.32) contrast(1.02);
  --social-img-hover: brightness(1.5) contrast(1.04);
}

:root {
  --toast-transition: 0.22s;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  font-family: "DM Sans", system-ui, sans-serif;
  line-height: 1.5;
}

body {
  min-height: 100%;
  margin: 0;
  padding: 1.5rem 1.25rem;
  max-width: 58rem;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  color: var(--text);
  background: var(--bg);
}

.site-main {
  flex: 1 0 auto;
  width: 100%;
  min-width: 0;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1.25rem;
}

.site-header h1 {
  margin: 0;
  flex: 1;
  min-width: min(100%, 14rem);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.theme-fieldset {
  border: none;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
}

.theme-fieldset .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.theme-switch {
  display: inline-flex;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.theme-option {
  display: flex;
  margin: 0;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}

.theme-option + .theme-option {
  border-left: 1px solid var(--border);
}

.theme-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
}

.theme-option-label {
  display: block;
  padding: 0.4rem 0.65rem;
  line-height: 1.2;
  transition: background 0.12s ease, color 0.12s ease;
}

.theme-option:hover .theme-option-label {
  color: var(--text);
  background: var(--accent-soft);
}

.theme-option input:focus-visible + .theme-option-label {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.theme-option input:checked + .theme-option-label {
  color: var(--accent);
  background: var(--accent-soft);
}

#hint {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 1rem;
  padding: 0.65rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

#hint:empty {
  display: none;
}

.stats {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1.35rem;
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.85rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 0.9375rem;
}

.stat-row--emphasis {
  background: var(--accent-soft);
  border-color: var(--emphasis-border);
}

.stat-row strong {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.stat-sep {
  color: var(--border);
  font-weight: 300;
  user-select: none;
}

.upload {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  margin-bottom: 1.35rem;
  box-shadow: var(--shadow);
}

.upload label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.upload input[type="file"] {
  margin-bottom: 0.85rem;
  max-width: 100%;
  font-size: 0.875rem;
}

button {
  font: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.55rem 1.1rem;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: var(--btn-on-accent);
  cursor: pointer;
  margin-top: 0.25rem;
}

button:hover {
  filter: brightness(1.08);
}

button:active {
  transform: scale(0.98);
}

.grid {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

@media (min-width: 42rem) {
  .grid {
    grid-template-columns: 1fr 1fr;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  min-height: 4rem;
  min-width: 0;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.55rem;
}

.panel-heading h2 {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.3;
}

.panel-heading-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.panel-heading-actions[hidden] {
  display: none !important;
}

button.btn-icon {
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  margin: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

button.btn-icon:hover {
  background: var(--accent-soft);
  filter: none;
}

button.btn-icon:active {
  transform: scale(0.96);
}

button.btn-icon img {
  display: block;
  flex-shrink: 0;
}

#list-you-only,
#list-they-only,
#list-mutuals {
  min-width: 0;
  width: 100%;
}

.panel ul {
  margin: 0;
  padding-left: 1.15rem;
  max-height: 65vh;
  overflow-y: auto;
  font-size: 0.9rem;
}

.panel li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.75rem;
  word-break: break-word;
  padding: 0.15rem 0;
}

.list-time {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 0.8125rem;
  color: var(--muted);
  font-style: italic;
}

.panel a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.panel a:hover {
  text-decoration: underline;
}

#list-mutuals ul {
  margin: 0.75rem 0 0;
  padding-left: 1.15rem;
  max-height: 50vh;
  overflow-y: auto;
  font-size: 0.9rem;
}

#list-mutuals li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.75rem;
  word-break: break-word;
  padding: 0.15rem 0;
}

#list-mutuals a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

#list-mutuals a:hover {
  text-decoration: underline;
}

#list-mutuals .empty {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
}

.mutuals-wrap {
  margin-top: 1.25rem;
  min-width: 0;
}

.mutuals-wrap[hidden] {
  display: none !important;
}

.mutuals-summary {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.45rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
  padding: 0.65rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.mutuals-summary::-webkit-details-marker {
  display: none;
}

.mutuals-wrap .mutuals-summary::after {
  content: "\25B8";
  color: var(--muted);
  font-weight: 500;
  font-size: 0.85em;
  line-height: 1;
  flex-shrink: 0;
}

.mutuals-wrap[open] .mutuals-summary::after {
  content: "\25BE";
}

.panel .empty {
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
}

.intro {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 1.25rem;
  line-height: 1.55;
}

.intro .text-link {
  display: inline;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  vertical-align: baseline;
}

.intro .text-link:hover {
  color: var(--text-link-hover);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--modal-backdrop);
  backdrop-filter: blur(5px);
  cursor: pointer;
}

.modal-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 30rem;
  max-height: min(88vh, 38rem);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--modal-panel-border);
  border-radius: 18px;
  box-shadow: var(--modal-shadow);
}

.modal-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem 0.8rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.025em;
  line-height: 1.3;
}

.modal-close {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  margin: -0.15rem -0.15rem -0.15rem 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s ease, background 0.12s ease;
}

.modal-close:hover {
  color: var(--text);
  background: var(--control-hover-bg);
}

.modal-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1.25rem 1.5rem 1.35rem;
  -webkit-overflow-scrolling: touch;
}

.modal-steps {
  margin: 0;
  padding-left: 1.4rem;
  padding-right: 0.15rem;
  color: var(--text);
  font-size: 0.9375rem;
  line-height: 1.55;
}

.modal-steps li {
  margin-bottom: 1rem;
  padding-left: 0.15rem;
}

.modal-steps li:last-child {
  margin-bottom: 0;
}

.modal-steps code {
  font-size: 0.86em;
  background: var(--accent-soft);
  padding: 0.12em 0.4em;
  border-radius: 5px;
  font-weight: 500;
}

.modal-footer {
  flex-shrink: 0;
  padding: 0.75rem 1.5rem 0.95rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.modal-note {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.45;
}

.privacy-sections section {
  margin-bottom: 1.1rem;
}

.privacy-sections section:last-child {
  margin-bottom: 0;
}

.privacy-heading {
  margin: 0 0 0.5rem;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
}

.panel-disclaimer {
  margin: -0.35rem 0 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-wrap: break-word;
}

.panel-disclaimer[hidden] {
  display: none !important;
}

.panel .empty.list-result-empty {
  font-style: normal;
  font-size: 0.875rem;
  line-height: 1.45;
  max-width: none;
}

body.modal-open {
  overflow: hidden;
}

.toast {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  bottom: auto;
  z-index: 500;
  max-width: min(20rem, calc(100vw - 2.5rem));
  padding: 0.75rem 1rem;
  background: var(--toast-bg);
  color: var(--toast-fg);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
  border-radius: 12px;
  box-shadow: var(--toast-shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-0.5rem);
  transition: opacity var(--toast-transition) ease,
    transform var(--toast-transition) ease,
    visibility var(--toast-transition) ease;
  pointer-events: none;
}

.toast.toast--visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

@media (max-width: 28rem) {
  .toast {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }
}

.site-footer {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
}

.site-footer-disclaimer {
  margin: 0 0 1rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--muted);
}

.site-footer-copy {
  margin: 0 0 1.1rem;
  font-size: 0.875rem;
  color: var(--text);
}

.site-footer-copy-inner {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.5rem;
  max-width: 100%;
}

.site-footer-crumb {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.35rem;
}

.site-footer-sep {
  color: #a5aab4;
  color: color-mix(in srgb, var(--muted) 38%, var(--border));
  font-weight: 600;
  user-select: none;
}

.site-footer-privacy-open {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: inherit;
  cursor: pointer;
}

.site-footer-author,
.site-footer-privacy-open {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.site-footer-author:hover,
.site-footer-privacy-open:hover {
  text-decoration: underline;
}

.site-footer-author:focus-visible,
.site-footer-privacy-open:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.site-footer-social {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
}

.site-footer-icon {
  display: inline-flex;
  line-height: 0;
  transition: filter 0.15s ease, opacity 0.15s ease;
}

.site-footer-icon img {
  display: block;
  filter: var(--social-img-base);
}

.site-footer-icon:hover img {
  filter: var(--social-img-hover);
}

.site-footer-icon:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}
