:root {
  --bg: #fbfaf7;
  --card: #ffffff;
  --ink: #1c1c1a;
  --muted: #6b6b66;
  --green: #2e7d5b;
  --green-dark: #246148;
  --warn-bg: #fdf2ef;
  --warn-ink: #b23b2f;
  --line: #e9e7e1;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 640px;
  margin: 0 auto;
  /* respect the iPhone notch + home bar in standalone mode */
  padding: calc(env(safe-area-inset-top) + 16px) 16px
           calc(env(safe-area-inset-bottom) + 24px) 16px;
}

h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 4px 0 16px;
  letter-spacing: -0.01em;
}
h1 span { color: var(--green); font-weight: 600; }

/* --- input --- */
#form { display: flex; flex-direction: column; gap: 10px; }

#input {
  width: 100%;
  font-size: 1.15rem;
  line-height: 1.4;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  resize: none;
}
#input:focus { outline: 2px solid var(--green); border-color: var(--green); }

#go {
  font-size: 1.1rem;
  font-weight: 600;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: var(--green);
  color: #fff;
  cursor: pointer;
}
#go:active { background: var(--green-dark); }
#go:disabled { opacity: 0.6; }

.status { margin: 14px 2px; color: var(--muted); }
.status.error { color: var(--warn-ink); }

/* --- result card --- */
.card {
  margin-top: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
}

.italian-row { display: flex; align-items: flex-start; gap: 10px; }
.italian {
  flex: 1;
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.25;
  -webkit-user-select: text;
  user-select: text;
}
.play {
  flex: none;
  font-size: 1.3rem;
  width: 48px; height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  cursor: pointer;
}
.play:active { background: #efeee9; }

.label {
  margin: 18px 0 4px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.label.warn { color: var(--warn-ink); }

.phonetic {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--green-dark);
  font-variant-ligatures: none;
}

.traps {
  margin: 6px 0 0;
  padding: 12px 14px 12px 30px;
  background: var(--warn-bg);
  border-radius: 12px;
}
.traps li { margin: 4px 0; color: var(--warn-ink); line-height: 1.4; }

.notes { margin: 0; color: var(--ink); line-height: 1.45; }

.alts { margin: 4px 0 0; padding-left: 20px; }
.alts li { margin: 3px 0; line-height: 1.4; }

/* --- recent --- */
.recent { margin-top: 26px; }
#recent { list-style: none; margin: 0; padding: 0; }
#recent li {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
#recent .r-it { font-weight: 600; }
#recent .r-en { color: var(--muted); font-size: 0.9rem; }
#recent .r-ph { color: var(--green-dark); font-size: 0.92rem; }

.hint {
  margin-top: 28px;
  padding: 12px 14px;
  background: #eef5f1;
  border-radius: 12px;
  color: var(--green-dark);
  font-size: 0.92rem;
  text-align: center;
}

/* --- access gate --- */
#gate { margin-top: 24px; }
.gate-msg { color: var(--muted); margin: 0 0 12px; }
#gateForm { display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
#code {
  font-size: 1.15rem;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
}
#code:focus { outline: 2px solid var(--green); border-color: var(--green); }
#unlock {
  font-size: 1.1rem;
  font-weight: 600;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: var(--green);
  color: #fff;
  cursor: pointer;
}
#unlock:active { background: var(--green-dark); }
