:root {
  --bg: #f4f5ff;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --border: rgba(99, 102, 241, 0.12);
  --text: #1e1b4b;
  --muted: #6b6f93;
  --primary: #4f46e5;
  --primary-2: #06b6d4;
  --accent: #f472b6;
  --success: #10b981;
  --danger: #ef4444;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 45%, #06b6d4 100%);
  --shadow: 0 10px 30px -12px rgba(49, 46, 129, 0.25);
  --shadow-lg: 0 24px 60px -20px rgba(79, 70, 229, 0.45);
  --radius: 24px;
  --chip: #eef0ff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0b1d;
    --surface: rgba(30, 28, 60, 0.72);
    --surface-solid: #1a1836;
    --border: rgba(165, 180, 252, 0.14);
    --text: #eef0ff;
    --muted: #a3a6c8;
    --chip: #26244a;
    --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

.bg-blobs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bg-blobs span { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; }
.bg-blobs span:nth-child(1) { width: 340px; height: 340px; background: #a5b4fc; top: -120px; left: -100px; }
.bg-blobs span:nth-child(2) { width: 300px; height: 300px; background: #67e8f9; top: 30%; right: -140px; opacity: .35; }
.bg-blobs span:nth-child(3) { width: 260px; height: 260px; background: #f9a8d4; bottom: -100px; left: 10%; opacity: .3; }
@media (prefers-color-scheme: dark) { .bg-blobs span { opacity: .22 !important; } }

.app {
  position: relative; z-index: 1;
  max-width: 480px; margin: 0 auto; min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 20px) 20px calc(env(safe-area-inset-bottom) + 28px);
  display: flex; flex-direction: column;
}
.screen { display: flex; flex-direction: column; flex: 1; gap: 18px; animation: in .45s cubic-bezier(.2, .8, .2, 1); }
@keyframes in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Tipografia */
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); }
@media (prefers-color-scheme: dark) { .eyebrow { color: #a5b4fc; } }
h1 { font-size: 30px; line-height: 1.15; margin: 0; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 22px; margin: 0; font-weight: 800; letter-spacing: -.01em; }
.lead { color: var(--muted); font-size: 16px; line-height: 1.5; margin: 0; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Topbar */
.topbar { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border); backdrop-filter: blur(12px);
}
.icon-btn svg { width: 22px; height: 22px; }
.steps { display: flex; gap: 6px; margin-left: auto; }
.steps i { width: 22px; height: 6px; border-radius: 3px; background: var(--border); }
.steps i.on { background: var(--grad); }

/* Hero benvenuto */
.hero { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 22px; text-align: center; align-items: center; }
.hero-art {
  width: 168px; height: 168px; border-radius: 48px; background: var(--grad);
  display: grid; place-items: center; box-shadow: var(--shadow-lg); position: relative;
  animation: float 5s ease-in-out infinite;
}
.hero-art::after { content: ''; position: absolute; inset: -14px; border-radius: 58px; border: 2px dashed rgba(99, 102, 241, .3); }
.hero-art svg { width: 92px; height: 92px; }
@keyframes float { 50% { transform: translateY(-8px) rotate(-2deg); } }
.studio-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-size: 14px; font-weight: 600;
}
.studio-pill b { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }

/* Bottoni */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  min-height: 58px; padding: 0 22px; border-radius: 18px; font-weight: 700; font-size: 17px;
  transition: transform .15s ease, box-shadow .2s ease, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: var(--shadow-lg); }
.btn-ghost { background: var(--surface); border: 1px solid var(--border); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn svg { width: 20px; height: 20px; }
.bottom { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 8px; }

/* Card */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.label { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 10px; display: block; }

/* Griglia apparecchi */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.app-card {
  text-align: left; display: flex; flex-direction: column; gap: 12px; padding: 18px 16px;
  border-radius: var(--radius); background: var(--surface); border: 2px solid var(--border);
  box-shadow: var(--shadow); transition: transform .15s, border-color .2s;
}
.app-card:active { transform: scale(.97); }
.app-card.wide { grid-column: span 2; flex-direction: row; align-items: center; }
.app-card .emo {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 28px; flex: none;
}
.app-card strong { font-size: 16px; display: block; }
.app-card small { color: var(--muted); font-size: 13px; line-height: 1.35; display: block; margin-top: 3px; }
.tone-0 { background: linear-gradient(135deg, #e0e7ff, #c7d2fe); }
.tone-1 { background: linear-gradient(135deg, #cffafe, #a5f3fc); }
.tone-2 { background: linear-gradient(135deg, #fce7f3, #fbcfe8); }
.tone-3 { background: linear-gradient(135deg, #fef3c7, #fde68a); }
.tone-4 { background: linear-gradient(135deg, #dcfce7, #bbf7d0); }

/* Selezione apparecchio scelto */
.chosen { display: flex; align-items: center; gap: 14px; }
.chosen .emo { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; font-size: 30px; }
.chosen strong { font-size: 18px; display: block; }
.chosen small { color: var(--muted); }

/* Input */
.field {
  width: 100%; min-height: 54px; padding: 0 16px; border-radius: 16px; border: 1.5px solid var(--border);
  background: var(--surface-solid); font-size: 17px; outline: none; transition: border-color .2s, box-shadow .2s;
}
.field:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(99, 102, 241, .15); }

.time-row { display: flex; align-items: center; gap: 14px; }
.time-row .ico { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; flex: none; font-size: 22px; }
.ico-on { background: linear-gradient(135deg, #d1fae5, #a7f3d0); }
.ico-off { background: linear-gradient(135deg, #fee2e2, #fecaca); }
.time-row .txt { flex: 1; }
.time-row .txt strong { display: block; font-size: 16px; }
.time-row .txt small { color: var(--muted); font-size: 13px; }
input[type="time"].time {
  font-size: 22px; font-weight: 800; padding: 10px 12px; border-radius: 14px; border: 1.5px solid var(--border);
  background: var(--chip); min-width: 110px; text-align: center; letter-spacing: .02em; outline: none;
  -webkit-appearance: none; appearance: none;
}
input[type="time"].time:focus { border-color: var(--primary); }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* Toggle */
.toggle { position: relative; width: 54px; height: 32px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle span { position: absolute; inset: 0; border-radius: 999px; background: var(--chip); border: 1px solid var(--border); transition: background .25s; }
.toggle span::after {
  content: ''; position: absolute; width: 26px; height: 26px; left: 2px; top: 2px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .2); transition: transform .25s cubic-bezier(.3, 1.4, .5, 1);
}
.toggle input:checked + span { background: var(--grad); }
.toggle input:checked + span::after { transform: translateX(22px); }

/* Giorni */
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day {
  aspect-ratio: 1; border-radius: 14px; background: var(--chip); font-weight: 800; font-size: 15px;
  border: 1.5px solid transparent; transition: all .18s;
}
.day.on { background: var(--grad); color: #fff; box-shadow: 0 6px 16px -6px rgba(79, 70, 229, .6); }
.presets { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.preset { padding: 8px 14px; border-radius: 999px; background: var(--chip); font-size: 14px; font-weight: 600; }
.preset.on { background: var(--text); color: var(--bg); }

/* Home */
.home-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.home-head .studio { font-size: 14px; color: var(--muted); font-weight: 600; }
.next {
  border-radius: 28px; padding: 22px; color: #fff; background: var(--grad); box-shadow: var(--shadow-lg);
  position: relative; overflow: hidden;
}
.next::before, .next::after { content: ''; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.next::before { width: 200px; height: 200px; right: -60px; top: -80px; }
.next::after { width: 120px; height: 120px; right: 40px; bottom: -70px; }
.next .k { font-size: 13px; font-weight: 700; opacity: .85; letter-spacing: .06em; text-transform: uppercase; }
.next .t { font-size: 46px; font-weight: 800; letter-spacing: -.03em; margin: 6px 0 2px; }
.next .w { font-size: 16px; font-weight: 600; opacity: .95; }
.next .cd { margin-top: 14px; display: inline-flex; padding: 7px 12px; border-radius: 999px; background: rgba(255, 255, 255, .2); font-size: 13px; font-weight: 700; backdrop-filter: blur(6px); }

.section-title { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.section-title h2 { font-size: 18px; }
.add-mini { display: inline-flex; gap: 6px; align-items: center; color: var(--primary); font-weight: 700; font-size: 15px; padding: 8px 4px; }
@media (prefers-color-scheme: dark) { .add-mini { color: #a5b4fc; } }

.rem { display: flex; flex-direction: column; gap: 14px; }
.rem-top { display: flex; align-items: center; gap: 12px; }
.rem-top .emo { width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center; font-size: 25px; flex: none; }
.rem-top .info { flex: 1; min-width: 0; }
.rem-top strong { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rem-top small { color: var(--muted); font-size: 13px; }
.rem-times { display: flex; gap: 8px; flex-wrap: nowrap; }
.tchip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 12px; background: var(--chip); font-weight: 700; font-size: 15px; }
.tchip i { font-style: normal; font-size: 12px; font-weight: 600; color: var(--muted); }
.rem-days { display: flex; gap: 4px; }
.rem-days span { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: var(--chip); color: var(--muted); }
.rem-days span.on { background: rgba(99, 102, 241, .16); color: var(--primary); }
@media (prefers-color-scheme: dark) { .rem-days span.on { color: #c7d2fe; background: rgba(129, 140, 248, .25); } }
.rem-actions { display: flex; gap: 8px; margin-left: auto; }
.rem-actions button { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--chip); }
.rem-actions svg { width: 18px; height: 18px; }
.rem.off { opacity: .55; }
.rem-foot { display: flex; align-items: center; gap: 10px; }

.empty { text-align: center; padding: 28px 18px; color: var(--muted); }
.empty .big { font-size: 44px; }

.tip { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: var(--muted); line-height: 1.45; }
.tip .ti { font-size: 20px; }
.banner { border-radius: 18px; padding: 14px 16px; font-size: 14px; line-height: 1.45; display: flex; gap: 10px; align-items: flex-start; }
.banner.warn { background: rgba(245, 158, 11, .14); color: #92400e; }
@media (prefers-color-scheme: dark) { .banner.warn { color: #fcd34d; } }

/* Guida installazione iPhone */
.install-steps { display: flex; flex-direction: column; gap: 12px; counter-reset: s; }
.install-step { display: flex; align-items: center; gap: 14px; font-size: 16px; line-height: 1.4; }
.install-step::before {
  counter-increment: s; content: counter(s); width: 34px; height: 34px; border-radius: 12px; flex: none;
  display: grid; place-items: center; background: var(--grad); color: #fff; font-weight: 800;
}
.install-step svg { width: 22px; height: 22px; vertical-align: -5px; color: var(--primary); }
.arrow-hint { text-align: center; font-size: 34px; animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(8px); } }

/* Successo */
.success-art {
  width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto;
  background: linear-gradient(135deg, #34d399, #06b6d4); box-shadow: 0 24px 50px -18px rgba(16, 185, 129, .7);
  animation: pop .6s cubic-bezier(.3, 1.6, .5, 1);
}
.success-art svg { width: 60px; height: 60px; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translate(-50%, 140%);
  background: var(--text); color: var(--bg); padding: 14px 20px; border-radius: 16px; font-weight: 600; font-size: 15px;
  z-index: 10; opacity: 0; transition: transform .35s cubic-bezier(.2, .9, .3, 1.2), opacity .25s; max-width: calc(100% - 40px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .4); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.credit { text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; padding-top: 6px; opacity: .8; }
