:root {
  --primary: #0b5ed7;
  --primary-dark: #084298;
  --surface: rgba(255,255,255,.94);
  --text: #172033;
  --muted: #68758a;
  --border: #dce4ef;
  --shadow: 0 18px 50px rgba(19, 39, 77, .12);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(11,94,215,.18), transparent 35%),
    radial-gradient(circle at bottom right, rgba(255,0,0,.10), transparent 32%),
    #f4f7fb;
}
.app { width: min(760px, 100%); margin: auto; padding: 24px 16px 40px; }
header { text-align: center; padding: 24px 8px; }
.logo {
  width: 92px; height: 92px; border-radius: 28px; margin: 0 auto 18px;
  display: grid; place-items: center; font-weight: 800; font-size: 16px;
  background: linear-gradient(135deg,#fff,#dbe9ff);
  box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,.8);
}
h1 { margin: 0; font-size: clamp(28px, 5vw, 44px); letter-spacing: -.04em; }
header p { color: var(--muted); margin: 10px 0 0; }
.card {
  background: var(--surface); border: 1px solid rgba(255,255,255,.8);
  border-radius: 24px; padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.language-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; margin-bottom: 18px; }
select, textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 14px; background: #fff;
  color: var(--text); font: inherit; outline: none;
}
select { padding: 13px 12px; font-weight: 700; }
textarea { resize: vertical; min-height: 150px; padding: 16px; font-size: 18px; line-height: 1.55; }
textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(11,94,215,.1); }
label { display: block; font-weight: 700; margin-bottom: 8px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
button { border: 0; cursor: pointer; font: inherit; font-weight: 750; transition: .2s ease; }
button:active { transform: scale(.98); }
.primary, .secondary, .speak-button { padding: 14px 18px; border-radius: 14px; }
.primary { color: white; background: linear-gradient(135deg,var(--primary),var(--primary-dark)); }
.secondary { background: #edf3fb; color: #25344f; }
.icon-button { width: 46px; height: 46px; border-radius: 14px; background: #edf3fb; color: #263855; font-size: 22px; }
.result-header { display:flex; align-items:center; justify-content:space-between; gap:12px; }
h2 { margin: 0; font-size: 18px; }
.output {
  margin-top: 14px; min-height: 72px; padding: 16px; border-radius: 16px;
  background: #f7f9fc; border: 1px solid var(--border); font-size: 20px; line-height: 1.6;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.sinhala { font-family: "Noto Sans Sinhala", system-ui, sans-serif; }
.speak-button { margin-top: 12px; background: #e9f1ff; color: var(--primary-dark); }
.note { color: var(--muted); font-size: 13px; line-height: 1.5; margin-bottom: 0; }
.text-button { background: transparent; color: var(--primary); }
.history-item { padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.history-item:last-child { border-bottom: 0; }
.history-item strong, .history-item span { display:block; }
.history-item span { color: var(--muted); margin-top: 5px; }
.empty { color: var(--muted); padding: 12px 0 2px; }
footer { text-align:center; color:var(--muted); font-size:13px; padding: 10px; }
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: #152238; color: white; padding: 11px 16px; border-radius: 99px;
  opacity: 0; pointer-events: none; transition: .25s ease; z-index: 99;
}
.toast.show { opacity:1; transform:translate(-50%,0); }
@media (max-width: 520px) {
  .app { padding: 10px 10px 28px; }
  header { padding: 22px 6px 18px; }
  .card { border-radius: 20px; padding: 16px; }
  .language-row { grid-template-columns: 1fr 44px 1fr; }
  select { padding: 12px 7px; }
}


.input-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.input-label-row label { margin-bottom: 0; }

.microphone-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  border-radius: 14px;
  background: #e9f1ff;
  color: var(--primary-dark);
}
.microphone-button.listening {
  background: #ffe9e9;
  color: #b42318;
  animation: microphonePulse 1.2s infinite;
}
.microphone-button:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.microphone-status {
  min-height: 22px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}
@keyframes microphonePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(180,35,24,.18); }
  50% { box-shadow: 0 0 0 9px rgba(180,35,24,0); }
}
