:root {
  --fondo: #f4f4f2;
  --schermo: #ffffff;
  --inchiostro: #121214;
  --grigio: #6b6b73;
  --grigio-chiaro: #a4a4ac;
  --linea: rgba(18, 18, 20, 0.08);
  --campo: #f7f7f6;
  --scuro: #17171a;
  --accento: #5b5bf0;
  --verde: #1f9d55;
  --accento-55: rgba(91, 91, 240, 0.55);
  --accento-10: rgba(91, 91, 240, 0.1);
}

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

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: "Mona Sans Variable", "Mona Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: relative;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 14px;
}

/* the settings window: always visible, it is also what the preview frames */
.screen {
  position: relative;
  width: min(352px, 100%);
  height: min(440px, calc(100vh - 28px));
  background: var(--schermo);
  border-radius: 22px;
  border: 1px solid var(--linea);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 22px 44px -22px rgba(20, 20, 40, 0.2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: min(14px, 2.6vh) 16px min(6px, 1vh);
}
.back {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 12px; font-weight: 560; color: var(--grigio); text-decoration: none;
  padding: 4px 8px 4px 2px; border-radius: 8px;
}
.back svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .back:hover { color: var(--inchiostro); background: var(--campo); } }
.back:focus-visible { outline: 2px solid var(--accento); outline-offset: 1px; }
.brand { display: inline-flex; align-items: center; gap: 6px; font-weight: 640; font-size: 13px; letter-spacing: -0.01em; }
.brand svg { width: 16px; height: 16px; fill: none; stroke: var(--accento); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }

.head { padding: min(6px, 1vh) 18px min(10px, 1.8vh); }
.h1 { font-size: min(20px, 4.4vh); font-weight: 680; letter-spacing: -0.02em; }
.lead { font-size: 12px; color: var(--grigio); margin-top: 2px; }

.form { display: flex; flex-direction: column; gap: min(10px, 1.8vh); padding: 0 18px; }
.field { position: relative; display: flex; flex-direction: column; gap: 5px; }
/* the time zone list opens over the fields below it */
.field[data-field="zone"] { z-index: 6; }
.field__label { font-size: 11.5px; font-weight: 600; color: #3a3a42; }
.field__box {
  position: relative; display: flex; align-items: center;
  height: min(38px, 7.6vh);
  border-radius: 11px;
  background: var(--campo);
  border: 1px solid var(--linea);
  transition: border-color 0.25s, box-shadow 0.25s, background-color 0.25s;
}
/* a field that differs from what is saved: a quiet accent edge, never a dot */
.field.is-edited .field__box { border-color: var(--accento-55); background: #fff; box-shadow: 0 0 0 3px var(--accento-10); }
.field__box:focus-within { border-color: var(--accento); background: #fff; }
.field__input {
  width: 100%; height: 100%; border: 0; background: transparent; outline: none;
  font: inherit; font-size: 13px; color: var(--inchiostro); padding: 0 12px;
}
.select { width: 100%; font: inherit; cursor: pointer; justify-content: space-between; padding: 0 10px 0 12px; text-align: left; }
.select__val { font-size: 13px; position: relative; height: 18px; overflow: hidden; display: block; flex: 1; }
.chev { width: 16px; height: 16px; fill: none; stroke: var(--grigio); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.3s; }
.select[aria-expanded="true"] .chev { transform: rotate(180deg); }
.select:focus-visible { outline: 2px solid var(--accento); outline-offset: 1px; }

.menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 4;
  list-style: none; padding: 5px; border-radius: 12px;
  background: #fff; border: 1px solid var(--linea);
  box-shadow: 0 14px 30px -14px rgba(20, 20, 40, 0.3);
  visibility: hidden; opacity: 0;
}
.menu li { font-size: 12.5px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.menu li.is-on { background: var(--campo); font-weight: 600; }
@media (hover: hover) { .menu li:hover { background: var(--campo); } }

.field--row { flex-direction: row; align-items: center; justify-content: space-between; padding-top: 2px; }
.field__txt { display: flex; flex-direction: column; gap: 1px; }
.field__hint { font-size: 11px; color: var(--grigio); }
.field--row.is-edited .field__label { color: var(--accento); }
.toggle {
  position: relative; width: 38px; height: 22px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--inchiostro); flex: none;
}
.toggle__knob { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }
.toggle:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }

/* the bar */
.bar {
  position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 5;
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px;
  padding: 9px 9px 9px 14px;
  border-radius: 16px;
  background: var(--scuro);
  color: #fff;
  box-shadow: 0 16px 32px -14px rgba(0, 0, 0, 0.5);
  will-change: transform;
}
.bar__txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; position: relative; }
.bar__title { font-size: 13px; font-weight: 640; letter-spacing: -0.005em; height: 17px; line-height: 17px; overflow: hidden; position: relative; display: block; white-space: nowrap; }
.bar__sub { font-size: 11px; color: rgba(255, 255, 255, 0.58); height: 15px; line-height: 15px; overflow: hidden; position: relative; display: block; white-space: nowrap; }
.swap, .num { position: relative; display: inline-block; }
.swap > span, .num > span { display: block; white-space: nowrap; }
.num { height: 15px; overflow: hidden; min-width: 0.6em; text-align: center; vertical-align: bottom; }
.num > span { line-height: 15px; }

.bar__actions { display: flex; align-items: center; gap: 4px; }
.discard, .save {
  position: relative; font: inherit; font-size: 12px; font-weight: 620; border: 0; border-radius: 999px;
  padding: 8px 12px; cursor: pointer; white-space: nowrap; will-change: transform;
}
.discard { background: transparent; color: rgba(255, 255, 255, 0.78); }
@media (hover: hover) { .discard:hover { color: #fff; background: rgba(255, 255, 255, 0.08); } }
.save { background: #fff; color: var(--scuro); display: inline-flex; align-items: center; gap: 6px; overflow: hidden; }
.save__label { position: relative; display: block; height: 16px; line-height: 16px; overflow: hidden; }
.spin { width: 13px; height: 13px; fill: none; stroke: var(--scuro); stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 30 60; display: none; }
.discard:focus-visible, .save:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }
.done { position: absolute; right: 16px; top: 50%; width: 20px; height: 20px; margin-top: -10px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* a small flash on a value put back by Discard */
.flash { position: absolute; inset: -1px; border-radius: 11px; background: var(--accento); opacity: 0; pointer-events: none; }

.ghost {
  position: absolute; left: 0; top: 0; width: 22px; height: 22px; z-index: 9;
  fill: #fff; stroke: #121214; stroke-width: 1.4; stroke-linejoin: round;
  opacity: 0; pointer-events: none; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.18));
}

@media (max-width: 380px) {
  .discard, .save { padding: 8px 10px; font-size: 11.5px; }
  .discard { padding: 8px 7px; }
  .bar { padding-left: 12px; gap: 4px; }
  .bar__title { font-size: 12.5px; }
}
/* short boxes (the phone preview): the lead line goes and the form keeps clear of the bar */
@media (max-height: 470px) {
  .lead { display: none; }
  .head { padding-bottom: 6px; }
  .form { gap: 7px; }
  .field { gap: 3px; }
}
