/* Number widget */
.widget-number { display: flex; flex-direction: column; gap: 1rem; }
.widget-number .number-row { display: flex; flex-direction: column; gap: 0.75rem; }
.widget-number input[type="range"] {
  width: 100%;
  height: 8px;
  accent-color: var(--accent);
  cursor: pointer;
}
.widget-number .number-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.widget-number input[type="number"] {
  flex: 1;
  padding: 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  color: var(--text);
  font-size: 1.2rem;
  font-family: ui-monospace, monospace;
  min-height: 44px;
}
.widget-number select {
  padding: 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  color: var(--text);
  min-height: 44px;
}
.widget-number .unit-suffix {
  font-size: 1.1rem;
  color: var(--text-dim);
  white-space: nowrap;
  padding: 0 0.25rem;
}
.widget-number .human-preview { color: var(--text-dim); font-size: 0.85rem; }

@media (min-width: 701px) {
  .widget-number .number-row { flex-direction: row; align-items: center; }
  .widget-number input[type="range"] { flex: 1; }
  .widget-number .number-input-row { flex: 0 0 200px; }
}

/* Date widget */
.widget-date {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.date-picker-trigger {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  width: 100%;
  padding: 1rem 1.1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  color: var(--text);
  cursor: pointer;
  min-height: 64px;
  text-align: left;
  transition: border-color var(--motion-fast);
}

.date-picker-trigger:hover {
  border-color: var(--accent);
}

.date-picker-trigger-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.date-picker-trigger-value {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent);
}

.date-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(15, 17, 23, 0.75);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.date-modal-backdrop[hidden] {
  display: none !important;
}

.date-modal {
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-sheet);
  padding: 1rem 1rem max(1rem, env(safe-area-inset-bottom));
  animation: slideUp var(--motion-medium) ease;
}

.date-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.date-modal-close {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--surface2);
  color: var(--text);
  border-radius: var(--radius-panel);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.date-modal-selectors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.date-field-wrap.hidden {
  display: none;
}

.date-field-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.date-field-wrap:only-child {
  grid-column: 1 / -1;
}

.date-year-input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  color: var(--text);
  font-size: 1.1rem;
  font-family: ui-monospace, monospace;
  min-height: 44px;
}

.date-year-input:focus {
  outline: none;
  border-color: var(--accent);
}

.date-select {
  width: 100%;
  padding: 0.65rem 0.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  color: var(--text);
  font-size: 0.95rem;
  min-height: 44px;
}

.date-calendar.hidden {
  display: none;
}

.date-calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 0.35rem;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-dim);
}

.date-calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.date-day {
  aspect-ratio: 1;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color var(--motion-fast), background var(--motion-fast);
}

.date-day.empty {
  border: none;
  background: transparent;
  cursor: default;
}

.date-day.disabled {
  opacity: 0.25;
  pointer-events: none;
}

.date-day.selected {
  border-color: var(--accent);
  background: rgba(91, 141, 238, 0.2);
  color: var(--accent);
  font-weight: 700;
}

.date-day:not(.empty):not(.disabled):hover {
  border-color: var(--accent);
}

.date-modal-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.date-modal-actions .btn {
  flex: 1;
}

@media (min-width: 701px) {
  .date-modal-backdrop {
    align-items: center;
    padding: 1rem;
  }

  .date-modal {
    border-radius: var(--radius-card);
    max-height: 85vh;
  }
}

/* Color widget */
.widget-color {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 100%;
}

.color-picker-sv {
  position: relative;
  width: 100%;
  height: min(50vw, 220px);
  min-height: 180px;
  border-radius: var(--radius-panel);
  border: 1px solid var(--border);
  cursor: crosshair;
  touch-action: none;
  background-color: var(--picker-hue, #5b8dee);
  background-image:
    linear-gradient(to top, #000, transparent),
    linear-gradient(to right, #fff, transparent);
  overflow: hidden;
}

.color-picker-cursor {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.color-picker-hue {
  position: relative;
  width: 100%;
  height: 28px;
  min-height: 44px;
  border-radius: var(--radius-panel);
  border: 1px solid var(--border);
  cursor: pointer;
  touch-action: none;
  background: linear-gradient(
    to right,
    #ff0000 0%,
    #ffff00 17%,
    #00ff00 33%,
    #00ffff 50%,
    #0000ff 67%,
    #ff00ff 83%,
    #ff0000 100%
  );
}

.color-picker-hue-cursor {
  position: absolute;
  top: 50%;
  width: 6px;
  height: calc(100% + 8px);
  border: 2px solid #fff;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
  transform: translate(-50%, -50%);
  pointer-events: none;
  background: transparent;
}

.widget-color .color-controls-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.widget-color .color-swatch {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: var(--radius-panel);
  border: 1px solid var(--border);
}

.widget-color input[type="text"] {
  flex: 1;
  padding: 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  color: var(--text);
  font-family: ui-monospace, monospace;
  font-size: 1rem;
  min-height: 44px;
  text-transform: uppercase;
}

@media (min-width: 701px) {
  .color-picker-sv {
    height: 220px;
  }

  .widget-color .color-swatch {
    width: 64px;
    height: 64px;
  }
}

/* Location widget */
.widget-location .map-container {
  width: 100%;
  height: min(50vh, 400px);
  border-radius: var(--radius-panel);
  border: 1px solid var(--border);
  overflow: hidden;
  z-index: 1;
}
.widget-location .coords-readout {
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
}

@media (min-width: 701px) {
  .widget-location .map-container { height: 400px; }
}

/* Choice widget */
.widget-choice {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
.choice-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 1rem;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius-panel);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: border-color var(--motion-fast), background var(--motion-fast);
  text-align: center;
}
.choice-tile:hover { border-color: var(--accent); }
.choice-tile.selected {
  border-color: var(--accent);
  background: rgba(91, 141, 238, 0.1);
  color: var(--accent);
}
.choice-tile.selected::after {
  content: " ✓";
}

@media (min-width: 701px) {
  .widget-choice { grid-template-columns: 1fr 1fr; }
}

/* Reveal widgets */
.reveal-swatch {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-panel);
  margin: 0 auto;
  border: 1px solid var(--border);
}
.reveal-map { height: min(40vh, 300px); border-radius: var(--radius-panel); overflow: hidden; }
.reveal-bar-chart { margin-top: 0.75rem; }
.bar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
}
.bar-fill {
  height: 8px;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.4s ease;
}

.widget-locked { opacity: var(--disabled-opacity); pointer-events: none; }

/* Reveal answer charts (everyone's answers) */
.reveal-chart-wrap { margin: 1rem 0; }
.reveal-chart-wrap .micro-label { display: block; margin-bottom: 0.6rem; }
.reveal-chart { margin-top: 0.25rem; }

/* Number / date line (timeline) */
.chart-line { padding: 1.75rem 0.5rem 0.25rem; }
.chart-track {
  position: relative;
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  margin: 0 6px;
}
.chart-dot {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.chart-consensus {
  position: absolute;
  top: -14px;
  bottom: -14px;
  width: 2px;
  background: var(--accent);
  transform: translateX(-50%);
}
.chart-consensus-label {
  position: absolute;
  top: -1.15rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent);
  text-transform: uppercase;
}
.chart-axis {
  display: flex;
  justify-content: space-between;
  margin: 0.6rem 6px 0;
  font-size: 0.72rem;
  color: var(--text-dim);
  font-family: ui-monospace, monospace;
}

/* Color chart */
.chart-colors {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.5rem;
}
.color-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.4rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
}
.color-card-swatch {
  width: 100%;
  height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.color-card-name {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.color-card-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.color-card-hex {
  font-size: 0.7rem;
  color: var(--text-dim);
}
.color-card-consensus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.color-card-consensus .color-card-name {
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.7rem;
}
.inline-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid var(--border);
  vertical-align: -2px;
  margin-right: 4px;
}

/* Choice distribution bars */
.chart-choice { display: flex; flex-direction: column; gap: 0.4rem; }
.choice-bar-row {
  display: grid;
  grid-template-columns: minmax(60px, 30%) 1fr auto;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
}
.choice-bar-label { color: var(--text-dim); }
.choice-bar-winner .choice-bar-label { color: var(--text); font-weight: 600; }
.choice-bar {
  position: relative;
  height: 20px;
  background: var(--surface2);
  border-radius: 5px;
  overflow: hidden;
}
.choice-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--accent);
  opacity: 0.35;
  transition: width 0.4s ease;
}
.choice-bar-winner .choice-bar-fill { opacity: 0.75; }
.choice-voters {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 6px;
}
.choice-voter {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid var(--surface);
}
.choice-bar-count {
  font-family: ui-monospace, monospace;
  color: var(--text-dim);
  min-width: 1.2ch;
  text-align: right;
}
