:root {
  --bg: #f0f0f0;
  --blue: #1565C0;
  --blue-dark: #0D47A1;
  --green-dark: #1B5E20;
  --red: #ef4444;
  --text: #000;
  --muted: #555;
  --card: #fff;
  --line: #ccc;
  --toggle-on: #1565C0;
  --toggle-off: #bbb;
}

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

body {
  background: var(--bg);
  font-family: 'Segoe UI', sans-serif;
  color: var(--text);
  min-height: 100vh;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 0 80px;
}

/* HEADER */
.top {
  background: var(--green-dark);
  color: white;
  text-align: center;
  padding: 16px 12px 12px;
}

.top h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
}

#tvTime {
  font-size: 52px;
  font-weight: 700;
  line-height: 1.1;
  margin: 4px 0 2px;
}

#tvDate {
  font-size: 15px;
  color: #ccc;
}

/* BOTTONI PRINCIPALI */
.buttons-main {
  display: flex;
  gap: 8px;
  margin: 10px 10px 0;
}

.buttons-main button {
  flex: 1;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  text-transform: uppercase;
}

.buttons-main button:active {
  background: var(--blue-dark);
  transform: scale(0.97);
}

/* TOGGLES */
.toggles {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 10px 0;
  flex-wrap: nowrap;
}

.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.toggle-wrap .icon {
  font-size: 20px;
}

/* Toggle switch */
.switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--toggle-off);
  border-radius: 24px;
  cursor: pointer;
  transition: background 0.2s;
}

.switch input:checked + .switch-slider {
  background: var(--toggle-on);
}

.switch-slider:before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.switch input:checked + .switch-slider:before {
  transform: translateX(20px);
}

/* BOTTONE ISTRUZIONI */
#btnIstruzioni {
  margin-left: auto;
  background: var(--green-dark);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
}

/* ULTIMO */
#tvUltimo {
  margin: 10px 10px 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 700;
  font-size: 14px;
}

/* TEXTAREA */
#etTesto {
  display: block;
  width: calc(100% - 20px);
  margin: 8px 10px 0;
  min-height: 55px;
  max-height: 100px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  font-size: 13px;
  resize: vertical;
  font-family: inherit;
}

/* BOTTONE ESTRAI */
#btnEstrai {
  display: block;
  width: calc(100% - 20px);
  margin: 10px 10px 0;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  letter-spacing: 0.5px;
}

#btnEstrai:active {
  background: var(--blue-dark);
}

/* LISTE */
.lists {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 10px 0;
}

.lists h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
}

.lists ul {
  list-style: none;
  background: var(--card);
  border: 2px solid var(--red);
  border-radius: 10px;
  min-height: 100px;
  max-height: 200px;
  overflow-y: auto;
  padding: 4px;
}

.lists li {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 6px;
  border-bottom: 1px solid #eee;
  font-size: 13px;
  font-weight: 600;
}

.lists li:last-child { border-bottom: none; }

.lists li button {
  background: none;
  border: none;
  color: var(--red);
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

.meta { font-size: 11px; color: var(--muted); }

/* DIALOG */
dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  max-width: 380px;
  padding: 20px;
}

dialog h3 { margin-bottom: 10px; }
dialog p { margin-bottom: 16px; font-size: 14px; color: var(--muted); }

dialog button {
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 400px) {
  .lists { grid-template-columns: 1fr 1fr; }
}
