*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg: #13110f;
  --bg-elevated: #262019;
  --bg-soft: #27221a;
  --border-subtle: rgba(255, 255, 255, 0.2);
  --text: #fdf7ec;
  --text-soft: #f0d9b5;
  --accent-left: #1e90ff;
  --accent-right: #ff6b35;
  --accent-mid: #9b51e0;
  --danger: #ff006e;
  --radius-card: 4px;
  --radius-pill: 2px;
  --shadow-soft: 0 18px 40px rgba(0, 0, 0, 0.7);
  --shadow-subtle: 0 0 0 1px rgba(0, 0, 0, 0.7);
  --transition-fast: 140ms cubic-bezier(0.46, 0.03, 0.52, 0.96);
  --transition-med: 220ms cubic-bezier(0.33, 1, 0.68, 1);
  --font-main: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
}

body {
  font-family: var(--font-main);
  background:
    linear-gradient(120deg, #f4e4c1 0, #f4e4c1 40%, #1e90ff 40%, #1e90ff 60%, #13110f 60%),
    repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.12) 0, rgba(0, 0, 0, 0.12) 2px, transparent 2px, transparent 6px);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* Layout */

#app {
  min-height: 100vh;
  max-width: 560px;
  margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top) + 24px)
    20px
    calc(env(safe-area-inset-bottom) + 32px);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 20px;
}

/* Header */

.pair-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f4e4c1;
  border-radius: 0;
  padding: 10px 14px;
  box-shadow: 6px 6px 0 #13110f;
  border: 2px solid #13110f;
  transform: rotate(-1.5deg) translateX(-4px);
}

.label-group {
  flex: 1;
  display: flex;
  justify-content: center;
}

.axis-input {
  background: transparent;
  border: none;
  text-align: center;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #13110f;
  padding: 2px 6px;
  border-radius: 0;
  outline: none;
  min-width: 0;
}

.axis-input:focus-visible {
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.axis-input::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

.divider-dot {
  width: 12px;
  height: 22px;
  background:
    linear-gradient(180deg, var(--accent-left) 0, var(--accent-mid) 50%, var(--accent-right) 100%);
  margin: 0 10px;
  box-shadow: 3px 3px 0 #13110f;
  transform: skewY(-18deg);
}

/* Main content */

.main-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.focus-card,
.list-card {
  background: #f4e4c1;
  border-radius: 0;
  padding: 16px 16px 14px;
  box-shadow: 10px 10px 0 #13110f;
  border: 2px solid #13110f;
  position: relative;
}

.focus-card {
  transform: rotate(1.2deg) translateX(6px);
}

.list-card {
  transform: rotate(-2deg) translateX(-4px);
}

/* Focus card */

.idea-input {
  width: 100%;
  border-radius: 0;
  border: 2px solid #13110f;
  background: repeating-linear-gradient(
    -45deg,
    rgba(155, 81, 224, 0.3) 0,
    rgba(155, 81, 224, 0.3) 3px,
    rgba(244, 228, 193, 0.8) 3px,
    rgba(244, 228, 193, 0.8) 7px
  );
  padding: 8px 10px;
  font-size: 14px;
  color: #13110f;
  outline: none;
}

.idea-input::placeholder {
  color: rgba(255, 255, 255, 0.28);
}

.idea-input:focus-visible {
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14);
}

/* Slider row */

.slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 8px;
}

.axis-preview {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  max-width: 70px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.axis-preview-left {
  text-align: left;
}

.axis-preview-right {
  text-align: right;
}

/* Range slider styling */

.balance-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 24px;
  background: transparent;
  cursor: pointer;
}

.balance-slider:focus-visible {
  outline: none;
}

.balance-slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 0;
  background:
    repeating-linear-gradient(
      90deg,
      #13110f 0,
      #13110f 6px,
      transparent 6px,
      transparent 12px
    ),
    linear-gradient(
      90deg,
      var(--accent-left) 0%,
      var(--accent-mid) 50%,
      var(--accent-right) 100%
    );
}

.balance-slider::-moz-range-track {
  height: 6px;
  border-radius: 0;
  background:
    repeating-linear-gradient(
      90deg,
      #13110f 0,
      #13110f 6px,
      transparent 6px,
      transparent 12px
    ),
    linear-gradient(
      90deg,
      var(--accent-left) 0%,
      var(--accent-mid) 50%,
      var(--accent-right) 100%
    );
}

.balance-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  margin-top: -9px;
  width: 26px;
  height: 26px;
  border-radius: 0;
  background: #f4e4c1;
  box-shadow:
    4px 4px 0 #13110f,
    0 0 0 2px #13110f;
  border: none;
}

.balance-slider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 0;
  background: #f4e4c1;
  box-shadow:
    4px 4px 0 #13110f,
    0 0 0 2px #13110f;
  border: none;
}

/* Meter */

.meter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.meter {
  flex: 1;
  height: 10px;
  border-radius: 0;
  background: repeating-linear-gradient(
    135deg,
    #13110f 0,
    #13110f 4px,
    transparent 4px,
    transparent 8px
  );
  overflow: hidden;
  position: relative;
}

.meter-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0%;
  background:
    linear-gradient(
      90deg,
      var(--accent-left),
      var(--accent-mid),
      var(--accent-right)
    );
  border-radius: 0;
  transition: width var(--transition-med);
}

.meter-text {
  font-size: 11px;
  color: var(--text-soft);
  white-space: nowrap;
}

/* Modal & Help Button */

.help-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 0;
  background: var(--accent-mid);
  color: #fdf7ec;
  border: 2px solid #13110f;
  box-shadow: 4px 4px 0 #1e90ff;
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
  z-index: 50;
  transform: rotate(6deg);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.help-btn:active {
  transform: translateY(2px) rotate(6deg);
  box-shadow: 2px 2px 0 #1e90ff;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(19, 17, 15, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 1;
  visibility: visible;
  transition: opacity var(--transition-fast), visibility var(--transition-fast);
}

.modal.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-content {
  background: #f4e4c1;
  border: 2px solid #13110f;
  box-shadow: 12px 12px 0 #1e90ff;
  padding: 24px 20px;
  max-width: 400px;
  width: 100%;
  position: relative;
  transform: rotate(-1.5deg);
  color: #13110f;
}

.modal-content h2 {
  margin: 0 0 14px;
  font-size: 22px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.modal-content p {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.5;
}

.modal-content p:last-child {
  margin-bottom: 0;
}

.close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #1e90ff;
  color: #13110f;
  border: 2px solid #13110f;
  width: 32px;
  height: 32px;
  font-size: 20px;
  font-weight: bold;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 2px 0 #13110f;
}

.close-btn:active {
  transform: translateY(1px);
  box-shadow: 1px 1px 0 #13110f;
}

/* Buttons */

.primary-btn,
.ghost-btn {
  border-radius: var(--radius-pill);
  border: none;
  font-size: 13px;
  padding: 8px 14px;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast),
    background var(--transition-fast), color var(--transition-fast), opacity 140ms ease-out;
  -webkit-tap-highlight-color: transparent;
}

.primary-btn {
  width: 100%;
  background: #13110f;
  color: #f4e4c1;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  box-shadow: 6px 6px 0 #1e90ff;
  border: 2px solid #13110f;
}

.primary-btn:active {
  transform: translateY(1px) scale(0.99);
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.14);
}

.ghost-btn {
  background: #1e90ff;
  color: #13110f;
  padding-inline: 10px;
  font-size: 11px;
  border: 2px solid #13110f;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.ghost-btn:active {
  transform: translateY(1px);
  background: rgba(255, 255, 255, 0.06);
}

/* List card */

.list-card {
  min-height: 120px;
  max-height: 140px;
  display: flex;
  flex-direction: column;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.list-title {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #13110f;
}

.items-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 2px;
  margin-right: -4px;
}

.items-list::-webkit-scrollbar {
  width: 2px;
}

.items-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.28);
  border-radius: 999px;
}

/* Venn diagram */

.venn-card {
  background: #f4e4c1;
  border-radius: 0;
  padding: 12px 16px 14px;
  box-shadow: 12px 12px 0 #13110f;
  border: 2px solid #13110f;
  transform: rotate(1.8deg) translateX(2px);
}

.venn-diagram {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  margin: 0 auto;
}

.venn-circle {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  border-radius: 50%;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition: left var(--transition-fast), right var(--transition-fast);
}

.venn-circle-left {
  left: 0%;
  background: radial-gradient(circle at 30% 50%, rgba(30, 144, 255, 0.55), transparent 70%);
}

.venn-circle-right {
  left: 50%;
  background: radial-gradient(circle at 70% 50%, rgba(255, 107, 53, 0.55), transparent 70%);
}

.venn-overlap {
  position: absolute;
  top: 0;
  left: 25%;
  width: 50%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(155, 81, 224, 0.8), transparent 82%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  z-index: 5;
  pointer-events: none;
}

.venn-count {
  font-size: 13px;
  font-weight: 800;
  color: #13110f;
  text-shadow: 2px 2px 0 #f4e4c1;
  position: relative;
  z-index: 20;
}

.venn-count-overlap {
  font-size: 14px;
}

.venn-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  background: var(--text);
  border: 3px solid #13110f;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: left var(--transition-fast);
  box-shadow: 2px 2px 0 #13110f;
  pointer-events: none;
  z-index: 10;
}

/* Align counts inside circles */
.venn-circle-left .venn-count {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.venn-circle-right .venn-count {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px;
  border-radius: 0;
  background: #13110f;
  border: 2px solid #f4e4c1;
  margin-bottom: 6px;
}

.item-row:last-child {
  margin-bottom: 0;
}

.item-tag {
  flex: 0 0 auto;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 0;
  background: #1e90ff;
  color: #13110f;
  border: 1px solid #13110f;
}

.item-name {
  flex: 1;
  font-size: 13px;
  color: #f4e4c1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-pill {
  flex: 0 0 82px;
  height: 18px;
  border-radius: 0;
  background: repeating-linear-gradient(
    90deg,
    #f4e4c1 0,
    #f4e4c1 4px,
    #13110f 4px,
    #13110f 8px
  );
  position: relative;
  overflow: hidden;
}

.item-marker {
  position: absolute;
  top: 1px;
  width: 9px;
  height: 16px;
  border-radius: 0;
  background: #1e90ff;
  box-shadow: 2px 2px 0 #13110f;
  border: 1px solid #13110f;
}

/* Alignment badges */

.align-label {
  font-size: 9px;
  min-width: 40px;
  text-align: right;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #f0d9b5;
}

/* Responsive tweaks */

@media (max-width: 375px) {
  #app {
    padding-inline: 12px;
  }
  .axis-preview {
    max-width: 58px;
  }
  .item-pill {
    flex-basis: 70px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}