/* ============================================
   arwuchivo - ultra minimal
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #fff;
  --text: #000;
  --text-muted: #999;
  --border: #f0f0f0;
  --overlay-bg: rgba(255, 255, 255, 0.96);
  --header-h: 6dvh;
  --timeline-h: 28px;
  --upload-btn-size: 40px;
  --radius: 0px;
}

html, body {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  font-weight: 300;
  line-height: 1.4;
  letter-spacing: 0.04em;
}

/* ============================================
   HEADER
   ============================================ */

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 100;
}

.date-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
  padding: 6px 12px;
  cursor: pointer;
  text-transform: lowercase;
  letter-spacing: 0.06em;
  font-family: inherit;
}

/* ============================================
   CANVAS
   ============================================ */

.canvas {
  position: relative;
  width: 100%;
  margin-top: calc(var(--header-h) + var(--timeline-h));
  min-height: calc(100dvh - var(--header-h) - var(--timeline-h));
  overflow: visible;
}

.timeline {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  height: var(--timeline-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 12px;
  background: var(--bg);
  z-index: 99;
  overflow-x: auto;
  scrollbar-width: none;
}
.timeline::-webkit-scrollbar { display: none; }

.day-dot {
  appearance: none;
  border: none;
  padding: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e8e8e8;
  cursor: default;
  flex: 0 0 auto;
  transition: transform 0.15s ease;
}
.day-dot.is-active {
  cursor: pointer;
}
.day-dot.is-active:hover {
  transform: scale(1.4);
}
.day-dot.is-selected {
  width: 10px;
  height: 10px;
  outline: 1px solid var(--text);
  outline-offset: 2px;
}

.empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  letter-spacing: 0.08em;
}

/* ============================================
   VIDEO ITEMS
   ============================================ */

.video-item {
  position: absolute;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.video-item:hover {
  transform: scale(1.02);
  z-index: 10;
}

.video-item:active {
  transform: scale(0.98);
}

.video-item video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* barra de color fusion */
.video-item::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--video-color, #000);
}

/* ============================================
   LEYENDA
   ============================================ */

.legend {
  position: fixed;
  bottom: 12px;
  right: 12px;
  font-size: 9px;
  color: var(--text-muted);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 3px;
  letter-spacing: 0.06em;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================
   BOTON DE SUBIDA
   ============================================ */

.upload-btn {
  position: fixed;
  bottom: 12px;
  left: 12px;
  width: var(--upload-btn-size);
  height: var(--upload-btn-size);
  border-radius: 50%;
  border: 0.5px solid var(--text-muted);
  background: var(--bg);
  color: var(--text);
  font-size: 20px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  transition: opacity 0.15s ease;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-btn:hover {
  opacity: 0.6;
}

/* ============================================
   MENU DE MESES
   ============================================ */

.season-menu {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.season-menu[hidden] {
  display: none;
}

.season-menu-inner {
  width: min(380px, 100%);
  max-height: 80dvh;
  background: var(--bg);
  padding: 20px;
  position: relative;
  overflow-y: auto;
}

.season-menu-close {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 300;
  line-height: 1;
}

.season-menu-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
  padding: 4px 0;
}

.month-item {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  padding: 10px 6px;
  cursor: pointer;
  transition: opacity 0.15s ease;
  font-weight: 300;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  letter-spacing: 0.04em;
}

.month-item:hover {
  opacity: 0.5;
}

.month-item.has-content {
  color: var(--text);
  font-weight: 500;
}

.month-item.is-current {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.month-name {
  font-size: 12px;
}

.month-year {
  font-size: 10px;
  opacity: 0.5;
}

/* ============================================
   OVERLAY DE VIDEO
   ============================================ */

.video-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.video-overlay[hidden] {
  display: none;
}

.video-overlay-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 24px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 300;
  line-height: 1;
  z-index: 10;
}

.video-overlay-body {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  gap: 12px;
}

.video-overlay-body video {
  max-width: 100%;
  max-height: calc(100% - 80px);
}

.video-overlay-meta {
  width: min(640px, 92%);
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--text);
}

.video-overlay-title {
  font-weight: 400;
  margin-bottom: 6px;
}

.video-overlay-notes {
  color: var(--text-muted);
  white-space: pre-wrap;
  line-height: 1.5;
}

/* ============================================
   MODAL DE PASSWORD
   ============================================ */

.password-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 250;
  padding: 16px;
}

.password-overlay[hidden] {
  display: none;
}

.password-overlay-inner {
  width: min(320px, 100%);
  background: var(--bg);
  padding: 20px;
  position: relative;
}

.password-overlay-close {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 300;
  line-height: 1;
}

.password-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.password-form label {
  font-size: 11px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: 0.06em;
}

.password-form input {
  width: 100%;
  padding: 10px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 300;
  letter-spacing: 0.04em;
}

.password-form input:focus {
  outline: none;
  border-bottom-color: var(--text);
}

.password-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.password-actions button {
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.password-actions button:hover {
  color: var(--text);
}

.password-actions button.primary {
  color: var(--text);
  font-weight: 600;
}

.password-error {
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 0;
  letter-spacing: 0.04em;
}

/* ============================================
   MODAL DE SUBIDA
   ============================================ */

.upload-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 250;
  padding: 16px;
}

.upload-overlay[hidden] {
  display: none;
}

.upload-overlay-inner {
  width: min(420px, 100%);
  max-height: 90dvh;
  background: var(--bg);
  padding: 20px;
  position: relative;
  overflow-y: auto;
}

.upload-overlay-inner h2 {
  font-size: 14px;
  font-weight: 400;
  margin-bottom: 16px;
  color: var(--text);
  letter-spacing: 0.06em;
}

.upload-overlay-close {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 300;
  line-height: 1;
}

.upload-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field label {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: lowercase;
}

.form-field input[type="text"],
.form-field input[type="password"],
.form-field input[type="date"],
.form-field textarea {
  width: 100%;
  padding: 8px 0;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 300;
  letter-spacing: 0.04em;
}

.form-field textarea {
  resize: vertical;
  min-height: 48px;
  line-height: 1.4;
}

.form-field input:focus,
.form-field textarea:focus {
  outline: none;
  border-bottom-color: var(--text);
}

.form-field input[type="file"] {
  font-size: 11px;
  font-family: inherit;
  color: var(--text-muted);
}

.compress-btn {
  border: none;
  background: transparent;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-left: 8px;
}

/* Progress block: una sola barra grande, simple, estilo imgToWeb */
.progress-block {
  margin: 8px 0;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--text);
}

.progress-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-pct {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

.progress-bar {
  width: 100%;
  height: 3px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--text);
  transition: width 0.25s ease;
  width: 0%;
}

.progress-done .progress-pct {
  color: #2e7d32;
}

/* Error card (cuando algo falla del todo) */
.status-card.status-error {
  margin: 8px 0;
  padding: 12px;
  background: #fdf3f3;
  border-left: 2px solid #d32f2f;
  font-size: 12px;
  color: var(--text);
  letter-spacing: 0.04em;
  line-height: 1.45;
}

.status-warning {
  margin-top: 8px;
  padding: 8px 10px;
  background: #fff8e1;
  border-left: 2px solid #f4b400;
  font-size: 11px;
  color: var(--text);
  letter-spacing: 0.04em;
  line-height: 1.4;
}

.capability-warning {
  margin: 0 0 16px 0;
  padding: 10px 12px;
  background: #fff8e1;
  border-left: 2px solid #f4b400;
  font-size: 12px;
  color: var(--text);
  letter-spacing: 0.04em;
  line-height: 1.45;
}
.capability-warning[data-mode="no-wasm"] {
  background: #fdf3f3;
  border-left-color: #d32f2f;
}

.compression-result {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.compression-result a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.upload-people {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.person-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}

.person-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.person-chip-name {
  flex: 1;
  font-weight: 300;
  letter-spacing: 0.04em;
}

.person-chip-remove {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.add-person-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  padding: 8px 0;
  cursor: pointer;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-align: left;
  font-family: inherit;
}

.add-person-btn:hover {
  color: var(--text);
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}

.form-actions button {
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.form-actions button:hover {
  color: var(--text);
}

.form-actions button.primary {
  color: var(--text);
  font-weight: 600;
}

/* ============================================
   MODAL DE NUEVA PERSONA
   ============================================ */

.new-person-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 16px;
}

.new-person-overlay[hidden] {
  display: none;
}

.new-person-overlay-inner {
  width: min(320px, 100%);
  background: var(--bg);
  padding: 20px;
  position: relative;
}

.new-person-overlay-inner h3 {
  font-size: 13px;
  font-weight: 400;
  margin-bottom: 14px;
  color: var(--text);
  letter-spacing: 0.06em;
}

.new-person-overlay-close {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 300;
  line-height: 1;
}

.new-person-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ============================================
   COLOR GRID SELECTOR
   ============================================ */

.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(22px, 1fr));
  gap: 3px;
  max-height: 140px;
  overflow-y: auto;
  padding: 4px 0;
}

.color-swatch {
  width: 22px;
  height: 22px;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s ease;
}

.color-swatch:hover {
  transform: scale(1.3);
  z-index: 1;
}

.color-swatch.selected {
  outline: 1.5px solid var(--text);
  outline-offset: 1px;
  transform: scale(1.2);
  z-index: 1;
}

/* ============================================
   PRESET BUTTONS
   ============================================ */

#presetField[hidden] {
  display: none;
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-btn {
  flex: 1 1 70px;
  min-width: 70px;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 300;
  padding: 8px 4px;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.preset-btn:hover {
  color: var(--text);
}

.preset-btn.active {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--text);
}

/* Upload error */
.upload-error {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 0;
  letter-spacing: 0.04em;
}

/* ============================================
   MODAL TEMPORAL (Selector de personas)
   ============================================ */

.temp-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 350;
  padding: 16px;
}

.temp-modal-inner {
  width: min(320px, 100%);
  max-height: 80dvh;
  background: var(--bg);
  padding: 20px;
  position: relative;
  overflow-y: auto;
}

.temp-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 300;
  line-height: 1;
}

.person-selector h4 {
  font-size: 13px;
  font-weight: 400;
  margin-bottom: 12px;
  color: var(--text);
  letter-spacing: 0.06em;
}

.person-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.person-option {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  padding: 8px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 300;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}

.person-option:hover:not(:disabled) {
  opacity: 0.5;
}

.person-option:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.person-option-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.person-option-name {
  flex: 1;
  text-align: left;
}

.new-person-trigger {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  padding: 8px 0;
  cursor: pointer;
  font-weight: 400;
  width: 100%;
  font-family: inherit;
  text-align: left;
  letter-spacing: 0.06em;
}

.new-person-trigger:hover {
  color: var(--text);
}

.empty-people {
  font-size: 11px;
  color: var(--text-muted);
  padding: 8px 0;
  letter-spacing: 0.04em;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 480px) {
  .upload-btn {
    --upload-btn-size: 48px;
    font-size: 22px;
  }

  /* iOS evita zoom si el input es >= 16px */
  .form-field input[type="text"],
  .form-field input[type="password"],
  .form-field input[type="date"],
  .form-field textarea,
  .password-form input {
    font-size: 16px;
  }

  /* Modal de subida ocupa toda la pantalla en móvil */
  .upload-overlay {
    padding: 0;
    align-items: stretch;
  }
  .upload-overlay-inner {
    width: 100%;
    max-height: 100dvh;
    height: 100dvh;
    padding: 24px 18px 32px;
    padding-top: max(24px, env(safe-area-inset-top));
    padding-bottom: max(32px, env(safe-area-inset-bottom));
  }
  .upload-overlay-close {
    width: 40px;
    height: 40px;
    font-size: 22px;
    top: 6px;
    right: 6px;
  }
  .upload-overlay-inner h2 {
    font-size: 16px;
    margin-bottom: 20px;
  }

  /* Más espacio entre campos y botones más grandes en móvil */
  .form-field {
    margin-bottom: 18px;
  }
  .form-actions button,
  .preset-btn,
  .add-person-btn,
  .person-option,
  .new-person-trigger {
    min-height: 44px;
    font-size: 14px;
  }
  .preset-buttons {
    gap: 8px;
  }
}
