:root {
  --bg: #0d0b1f;
  --card: rgba(255, 255, 255, 0.06);
  --card-strong: rgba(255, 255, 255, 0.1);
  --accent: #ff5f6d;
  --accent-2: #ffc371;
  --text: #f4f5fb;
  --muted: #a0a3b9;
  --success: #36c991;
  --danger: #ff7b7b;
  --glass: rgba(255, 255, 255, 0.08);
  --outline: rgba(255, 255, 255, 0.12);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --font: "Space Grotesk", "Segoe UI", Tahoma, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(160% 120% at 20% 20%, #201742 0%, #0d0b1f 45%, #0a0a14 100%);
  color: var(--text);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('/background/autismo.png');
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: contain;
  opacity: 0.3;
  pointer-events: none;
  z-index: 0;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 20px 48px;
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  position: relative;
  margin-top: 40px;
}

.icon-button {
  position: absolute;
  right: 0;
}

.brand-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.logo-corner {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 101;
}

.logo {
  width: 130px;
  height: auto;
  object-fit: contain;
}

.brand {
  font-size: 31px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-align: center;
}

.donation-widget {
  position: fixed;
  top: 20px;
  left: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px;
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.donation-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  letter-spacing: 0.05em;
}

.donate-form {
  display: flex;
  justify-content: center;
}

.donate-form input[type="image"] {
  height: 28px;
  width: auto;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.donate-form input[type="image"]:hover {
  transform: scale(1.08);
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--outline);
  display: grid;
  place-items: center;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-button:hover {
  background: var(--card-strong);
  border-color: var(--accent);
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.layout {
  display: grid;
  grid-template-columns: 2fr 1.2fr;
  gap: 18px;
}

.layout-column {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.timer-card {
  display: grid;
  gap: 16px;
}

.mode-switch {
  background: var(--glass);
  border: 1px solid var(--outline);
  border-radius: 12px;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.mode-button {
  border: none;
  padding: 12px 10px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-button.active {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #0b0b10;
  box-shadow: 0 10px 24px rgba(255, 95, 109, 0.35);
}

.mode-button:hover {
  color: var(--text);
}

.timer-display {
  display: grid;
  gap: 4px;
  text-align: center;
  padding: 10px 0 4px;
}

.time {
  font-size: 86px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.status {
  color: var(--muted);
}

.timer-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
}

button.primary {
  padding: 14px 18px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #0c0c12;
  font-weight: 700;
  cursor: pointer;
  min-width: 120px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 12px 30px rgba(255, 95, 109, 0.32);
}

button.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 36px rgba(255, 95, 109, 0.42);
}

button.ghost {
  padding: 14px 14px;
  border-radius: 12px;
  border: 1px solid var(--outline);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  min-width: 90px;
  transition: border-color 0.18s ease, background 0.18s ease;
}

button.ghost:hover {
  border-color: var(--accent);
  background: var(--glass);
}

.youtube-card {
  background: var(--glass);
  border: 1px solid var(--outline);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.audio-source-toggle {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.source-btn {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--outline);
  background: transparent;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.source-btn.active {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #0b0b10;
  border-color: var(--accent);
}

.source-btn:hover {
  border-color: var(--accent);
}

.audio-section {
  display: grid;
  gap: 8px;
}

.youtube-input input,
.todo-input input,
.settings-group input[type="text"],
.settings-group input[type="url"],
.settings-group input[type="number"],
.settings-group select {
  width: 100%;
  padding: 12px 12px;
  border-radius: 10px;
  border: 1px solid var(--outline);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 15px;
  transition: border-color 0.2s ease, background 0.2s ease;
  font-family: var(--font);
  color-scheme: dark;
}

.settings-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23f4f5fb' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

.settings-group select option {
  background-color: #0e0c1f;
  background-image: linear-gradient(#0e0c1f, #0e0c1f);
  color: #f4f5fb;
  padding: 8px;
}

.settings-group select option:checked {
  background-color: #ff5f6d;
  background-image: linear-gradient(#ff5f6d, #ff5f6d);
  color: #0c0c12;
}

.youtube-input input:focus,
.todo-input input:focus,
.settings-group input[type="text"]:focus,
.settings-group input[type="url"]:focus,
.settings-group input[type="number"]:focus,
.settings-group select:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}

.settings-group select:focus {
  background-color: rgba(255, 255, 255, 0.08);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23f4f5fb' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

/* Override autofill background */
.youtube-input input:-webkit-autofill,
.settings-group input:-webkit-autofill,
.settings-group select:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px rgba(255, 255, 255, 0.04) inset;
  -webkit-text-fill-color: var(--text);
}

.youtube-input input:-webkit-autofill:focus,
.settings-group input:-webkit-autofill:focus,
.settings-group select:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px rgba(255, 255, 255, 0.08) inset;
  -webkit-text-fill-color: var(--text);
}

/* Volume control slider */
.volume-control {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
}

.volume-control label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.volume-control input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.volume-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(255, 95, 109, 0.3);
}

.volume-control input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 8px rgba(255, 95, 109, 0.3);
}

#volumeDisplay,
#youtubeVolumeDisplay {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  min-width: 35px;
  text-align: right;
}

.youtube-card small {
  color: var(--muted);
}

.todo-card {
  display: grid;
  gap: 14px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.todo-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.time-spent {
  font-size: 14px;
  color: var(--accent);
  font-weight: 500;
}

#exportBtn {
  padding: 8px 12px;
  font-size: 13px;
  align-self: flex-end;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.card-header h3 {
  margin: 2px 0 0;
}

.pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--outline);
  color: var(--muted);
}

.todo-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.todo-input button {
  border-radius: 10px;
  border: none;
  background: var(--card-strong);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  padding: 12px 16px;
  border: 1px solid var(--outline);
}

.todo-input button:hover {
  border-color: var(--accent);
}

.todo-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.todo-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--outline);
}

.todo-item.complete {
  background: rgba(54, 201, 145, 0.2);
  border-color: rgba(54, 201, 145, 0.5);
}

.todo-actions {
  display: flex;
  gap: 6px;
}

.todo-actions button {
  border: 1px solid var(--outline);
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
}

.todo-actions button:hover {
  border-color: var(--accent);
}

.settings-panel {
  position: fixed;
  top: 0;
  right: -420px;
  width: 360px;
  height: 100vh;
  background: #0e0c1f;
  border-left: 1px solid var(--outline);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.4);
  padding: 20px 20px 28px;
  display: grid;
  gap: 16px;
  transition: right 0.24s ease;
  z-index: 10;
}

.settings-panel.open {
  right: 0;
}

.settings-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  backdrop-filter: blur(2px);
  z-index: 9;
}

.settings-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-group {
  display: grid;
  gap: 8px;
}

.toggle-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #343447;
  transition: 0.2s;
  border-radius: 40px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 5px;
  bottom: 4px;
  background-color: white;
  transition: 0.2s;
  border-radius: 50%;
}

.switch input:checked + .slider {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
}

.switch input:checked + .slider:before {
  transform: translateX(20px);
}

.grid {
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.full {
  width: 100%;
}

.stacked {
  display: grid;
  gap: 8px;
}

.split {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

#youtubePlayer {
  width: 0;
  height: 0;
  visibility: hidden;
}

.expanded-timer {
  position: fixed;
  inset: 0;
  background: radial-gradient(160% 120% at 20% 20%, #201742 0%, #0d0b1f 45%, #0a0a14 100%);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  gap: 40px;
  padding: 20px;
}

.expanded-timer.active {
  display: flex;
}

.expanded-timer::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('/background/autismo.png');
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: contain;
  opacity: 0.3;
  pointer-events: none;
  z-index: -1;
}

.collapse-button {
  position: absolute;
  top: 20px;
  left: 20px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--outline);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font);
}

.collapse-button:hover {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.1);
}

.expanded-donation-widget {
  position: absolute;
  top: 20px;
  right: 20px;
  padding: 16px 20px;
  border-radius: 12px;
  border: 1px solid var(--outline);
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  text-align: center;
  z-index: 10;
}

.expanded-donation-widget .donation-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.expanded-donation-widget .donate-form {
  display: flex;
  justify-content: center;
}


.expanded-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}

.expanded-time {
  font-size: 140px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1;
}

.expanded-status {
  font-size: 24px;
  color: var(--muted);
  text-align: center;
}

.expanded-controls {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.expanded-primary {
  padding: 16px 32px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #0c0c12;
  font-weight: 700;
  cursor: pointer;
  font-size: 18px;
  min-width: 160px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 12px 30px rgba(255, 95, 109, 0.32);
  font-family: var(--font);
}

.expanded-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(255, 95, 109, 0.42);
}

.expanded-ghost {
  padding: 16px 24px;
  border-radius: 12px;
  border: 1px solid var(--outline);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 18px;
  min-width: 140px;
  transition: border-color 0.18s ease, background 0.18s ease;
  font-weight: 600;
  font-family: var(--font);
}

.expanded-ghost:hover {
  border-color: var(--accent);
  background: var(--glass);
}

.expanded-audio-controls {
  margin-top: 40px;
  padding: 24px 32px;
  border-radius: 16px;
  border: 1px solid var(--outline);
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 320px;
}

.expanded-audio-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  margin-bottom: 8px;
}

.expanded-audio-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.expanded-audio-btn {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  border: 1px solid var(--outline);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.expanded-audio-btn:hover {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.expanded-volume-control {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.expanded-volume-control label {
  font-size: 14px;
  color: var(--muted);
  min-width: 60px;
}

.expanded-volume-control input[type="range"] {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  -webkit-appearance: none;
}

.expanded-volume-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: all 0.2s ease;
}

.expanded-volume-control input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.expanded-volume-control input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.expanded-volume-control input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.2);
}

#expandedVolumeValue {
  font-size: 14px;
  color: var(--text);
  min-width: 40px;
  text-align: right;
}

@media (max-width: 768px) {
  .expanded-time {
    font-size: 100px;
  }

  .expanded-status {
    font-size: 20px;
  }

  .expanded-controls {
    gap: 12px;
  }

  .expanded-primary {
    padding: 14px 24px;
    font-size: 16px;
    min-width: 130px;
  }

  .expanded-ghost {
    padding: 14px 20px;
    font-size: 16px;
    min-width: 110px;
  }
}

@media (max-width: 480px) {
  .expanded-time {
    font-size: 70px;
  }

  .expanded-status {
    font-size: 18px;
  }

  .expanded-controls {
    gap: 10px;
    flex-direction: column;
  }

  .expanded-primary,
  .expanded-ghost {
    width: 100%;
    max-width: 280px;
  }

  .collapse-button {
    top: 12px;
    left: 12px;
    padding: 10px 14px;
    font-size: 14px;
  }
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .brand {
    font-size: 26px;
  }

  .topbar {
    margin-top: 35px;
  }

  .logo-corner {
    top: 16px;
    right: 16px;
  }

  .logo {
    width: 110px;
  }

  .donation-widget {
    top: 16px;
    left: 16px;
    padding: 10px;
  }

  .time {
    font-size: 64px;
  }

  .youtube-input {
    grid-template-columns: 1fr;
  }

  .todo-input {
    grid-template-columns: 1fr;
  }

  .grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 16px 12px 24px;
  }

  .topbar {
    flex-direction: column;
    gap: 16px;
    margin-bottom: 16px;
    position: relative;
    margin-top: 100px;
  }

  .icon-button {
    position: absolute;
    top: 0;
    right: 0;
  }

  .brand-section {
    width: 100%;
    justify-content: center;
    flex-direction: column;
  }

  .logo-corner {
    top: 10px;
    right: 10px;
  }

  .logo {
    width: 90px;
  }

  .brand {
    font-size: 18px;
  }

  .time {
    font-size: 48px;
  }

  .timer-controls {
    flex-direction: column;
  }

  button.primary,
  button.ghost {
    min-width: auto;
    width: 100%;
  }

  .mode-switch {
    grid-template-columns: repeat(3, 1fr);
  }

  .mode-button {
    padding: 10px 8px;
    font-size: 13px;
  }

  .youtube-input,
  .todo-input,
  .audio-source-toggle {
    grid-template-columns: 1fr;
  }

  .split {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .todo-stats {
    width: 100%;
    margin-top: 12px;
    align-items: flex-start;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .eyebrow,
  .card-header h3 {
    width: 100%;
  }

  .settings-panel {
    width: 100%;
    right: -100%;
  }

  .pill {
    font-size: 11px;
    padding: 6px 10px;
  }

  .donation-widget {
    top: 12px;
    left: 12px;
    padding: 10px;
  }

  .donation-title {
    font-size: 11px;
    font-weight: 600;
  }

  .donate-form input[type="image"] {
    height: 26px;
  }
}

@media (max-width: 480px) {
  .page {
    padding: 12px 8px 20px;
  }

  .topbar {
    margin-top: 90px;
  }

  .logo-corner {
    top: 8px;
    right: 8px;
  }

  .logo {
    width: 70px;
  }

  .brand {
    font-size: 16px;
  }

  .time {
    font-size: 40px;
  }

  .donation-widget {
    top: 8px;
    left: 8px;
    padding: 8px;
  }

  .donation-title {
    font-size: 9px;
  }

  .donate-form input[type="image"] {
    height: 22px;
  }

  .mode-button {
    padding: 8px 6px;
    font-size: 11px;
  }
}
