:root {
  --yellow: #ffff00;
  --white: #ffffff;
  --black: #050505;
  --panel: rgba(255,255,255,.075);
  --panel-strong: rgba(255,255,255,.11);
  --line: rgba(255,255,255,.13);
  --muted: rgba(255,255,255,.60);
  --soft: rgba(255,255,255,.38);
  --text: #ffffff;
  --field: rgba(0,0,0,.34);
  --shadow: 0 24px 70px rgba(0,0,0,.48);
  --radius: 30px;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-theme="light"] {
  --black: #ececec;
  --panel: rgba(255,255,255,.56);
  --panel-strong: rgba(255,255,255,.75);
  --line: rgba(0,0,0,.10);
  --muted: rgba(0,0,0,.58);
  --soft: rgba(0,0,0,.38);
  --text: #111111;
  --field: rgba(255,255,255,.60);
  --shadow: 0 24px 70px rgba(0,0,0,.14);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--black); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, rgba(255,255,0,.10), transparent 28%),
    radial-gradient(circle at 88% 80%, rgba(77,132,255,.16), transparent 34%),
    linear-gradient(145deg, var(--black), #101010 52%, #050505);
  overflow-x: hidden;
  transition: background .3s ease, color .3s ease;
}

body[data-theme="light"] {
  background:
    radial-gradient(circle at 10% 10%, rgba(255,255,0,.33), transparent 30%),
    radial-gradient(circle at 88% 80%, rgba(77,132,255,.20), transparent 35%),
    linear-gradient(145deg, #f6f6f6, #e6e6e6 55%, #f7f7f7);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .17;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.13'/%3E%3C/svg%3E");
}

button, textarea, input { font: inherit; }

button { -webkit-tap-highlight-color: transparent; }

.ambient {
  position: fixed;
  border-radius: 999px;
  filter: blur(5px);
  pointer-events: none;
  opacity: .55;
  animation: drift 12s ease-in-out infinite;
}
.ambient-a { width: 220px; height: 220px; top: 6%; left: -70px; background: rgba(255,255,0,.20); }
.ambient-b { width: 260px; height: 260px; right: -110px; top: 42%; background: rgba(87,83,255,.21); animation-delay: -4s; }
.ambient-c { width: 120px; height: 120px; left: 26%; bottom: 3%; background: rgba(255,255,255,.14); animation-delay: -8s; }

@keyframes drift {
  50% { transform: translate3d(18px,-22px,0) scale(1.06); }
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 38px;
}

.glass {
  position: relative;
  border: 1px solid var(--line);
  background:
    linear-gradient(145deg, rgba(255,255,255,.12), rgba(255,255,255,.035));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), var(--shadow);
  backdrop-filter: blur(30px) saturate(155%);
  -webkit-backdrop-filter: blur(30px) saturate(155%);
}

.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(
      420px circle at var(--mx, 50%) var(--my, 0%),
      rgba(255,255,255,.17),
      transparent 45%
    );
  opacity: .72;
  transition: opacity .2s ease;
}

.glass::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.02),
    inset 0 14px 24px rgba(255,255,255,.025);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 17px 20px;
  border-radius: 26px;
}

.brand {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 15px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}
.brand img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  border-radius: 15px;
}
.brand strong {
  display: block;
  font-size: clamp(16px, 2.4vw, 24px);
  line-height: 1.1;
  letter-spacing: .035em;
  white-space: nowrap;
}
.brand strong span { color: var(--yellow); }
.brand small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }

.top-actions {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: stretch;
  gap: 9px;
}

.toggle-card, .mini-action {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255,255,255,.06);
  color: inherit;
}

.toggle-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
}
.bolt { color: var(--yellow); font-size: 21px; }
.toggle-copy { display: grid; gap: 2px; }
.toggle-copy strong { font-size: 12px; }
.toggle-copy small { color: var(--muted); font-size: 9px; }
.toggle-card input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  position: relative;
  width: 43px;
  height: 25px;
  border-radius: 99px;
  background: rgba(255,255,255,.14);
  border: 1px solid var(--line);
  transition: .22s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 3px 12px rgba(0,0,0,.35);
  transition: .22s ease;
}
.toggle-card input:checked + .switch {
  background: var(--yellow);
  box-shadow: 0 0 18px rgba(255,255,0,.35);
}
.toggle-card input:checked + .switch::after {
  transform: translateX(18px);
  background: #111;
}

.mini-action {
  display: grid;
  place-items: center;
  gap: 2px;
  min-width: 62px;
  padding: 7px 11px;
  cursor: pointer;
}
.mini-action span { color: var(--yellow); font-size: 19px; line-height: 1; }
.mini-action small { color: var(--muted); font-size: 9px; }
.mini-action:hover { background: rgba(255,255,255,.10); }

.hero {
  padding: 76px 16px 38px;
  text-align: center;
}
.eyebrow {
  margin: 0 0 12px;
  color: var(--yellow);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .22em;
}
.hero h1 {
  margin: 0;
  font-size: clamp(38px, 7vw, 74px);
  line-height: .99;
  letter-spacing: -.065em;
}
.hero h1 span { color: var(--yellow); }
.hero p:last-child {
  max-width: 640px;
  margin: 20px auto 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

.workspace, .result-panel, .tips {
  border-radius: var(--radius);
}
.workspace, .result-panel {
  padding: 26px;
}
.result-panel {
  margin-top: 18px;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  transform: translateY(-12px) scale(.99);
  overflow: hidden;
  pointer-events: none;
  transition: max-height .55s cubic-bezier(.2,.8,.2,1),
              padding .35s ease,
              opacity .35s ease,
              transform .35s ease;
}
.result-panel.visible {
  max-height: 650px;
  padding: 26px;
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.section-head {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.step-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 14px;
  color: #111;
  background: var(--yellow);
  box-shadow: 0 0 24px rgba(255,255,0,.20);
  font-weight: 800;
}
.step-icon.code { font-size: 12px; }
.section-title h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: -.02em;
}
.section-title p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
}
.example-btn {
  padding: 0;
  border: 0;
  color: var(--yellow);
  background: transparent;
  cursor: pointer;
}

.live-badge, .ready-badge {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}
.live-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
}
.live-badge i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #48e189;
  box-shadow: 0 0 13px rgba(72,225,137,.8);
}
.ready-badge {
  padding: 8px 11px;
  color: #111;
  background: var(--yellow);
  border-color: transparent;
}

.input-wrap, .output-wrap {
  position: relative;
  z-index: 3;
}
textarea {
  width: 100%;
  outline: none;
  resize: vertical;
  border: 1px solid rgba(255,255,0,.24);
  border-radius: 20px;
  color: var(--text);
  background: var(--field);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
textarea:focus {
  border-color: rgba(255,255,0,.70);
  box-shadow: 0 0 0 4px rgba(255,255,0,.07), inset 0 1px 0 rgba(255,255,255,.05);
}
#unicode-input {
  min-height: 240px;
  padding: 22px;
  font: 500 21px/1.8 "Noto Sans Malayalam", Inter, sans-serif;
}
#fml-output {
  min-height: 155px;
  padding: 22px 180px 22px 22px;
  font: 500 19px/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--yellow);
}

.suggestions {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: none;
  gap: 7px;
  flex-wrap: wrap;
  padding: 10px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: rgba(8,8,8,.88);
  box-shadow: 0 16px 40px rgba(0,0,0,.38);
  backdrop-filter: blur(20px);
}
.suggestions.visible { display: flex; }
.suggestion {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 7px 11px;
  color: #fff;
  background: rgba(255,255,255,.08);
  font: 500 14px/1.2 "Noto Sans Malayalam", sans-serif;
  cursor: pointer;
}
.suggestion:hover, .suggestion.active {
  color: #111;
  background: var(--yellow);
  border-color: transparent;
}

.typing-bar, .result-meta {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 11px;
  color: var(--muted);
  font-size: 11px;
}
.typing-status { display: flex; align-items: center; gap: 8px; }
.status-light {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #48e189;
}
.counts span:last-child { color: var(--soft); }

.primary-actions {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}
.secondary-btn, .convert-btn, .copy-btn, .preview-toggle {
  border: 0;
  cursor: pointer;
}
.secondary-btn {
  min-height: 52px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 17px;
  color: var(--text);
  background: rgba(255,255,255,.07);
}
.convert-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-width: 240px;
  min-height: 54px;
  padding: 0 24px;
  border-radius: 17px;
  color: #111;
  background: linear-gradient(135deg, #fff500, #ffff00 58%, #fff9a8);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 12px 30px rgba(255,255,0,.16);
  font-weight: 800;
}
.convert-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.convert-btn:active, .secondary-btn:active, .copy-btn:active { transform: scale(.98); }

kbd {
  display: inline-grid;
  place-items: center;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-bottom-color: rgba(255,255,255,.22);
  border-radius: 9px;
  color: var(--muted);
  background: rgba(255,255,255,.055);
  font: 600 10px/1 Inter, sans-serif;
}

.copy-btn {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 138px;
  min-height: 48px;
  justify-content: center;
  border-radius: 15px;
  color: #111;
  background: var(--yellow);
  font-weight: 800;
}
.copy-btn.copied { background: #fff; }

.preview-toggle {
  padding: 0;
  color: var(--muted);
  background: transparent;
}
.unicode-preview {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  margin-top: 0;
  overflow: hidden;
  transition: grid-template-rows .28s ease, opacity .28s ease, margin .28s ease;
}
.unicode-preview.open {
  grid-template-rows: 1fr;
  opacity: 1;
  margin-top: 16px;
}
.unicode-preview > * { min-height: 0; }
.unicode-preview span { color: var(--yellow); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.unicode-preview p {
  margin: 8px 0 0;
  padding: 14px;
  border-radius: 14px;
  color: var(--text);
  background: rgba(255,255,255,.055);
  font: 500 16px/1.7 "Noto Sans Malayalam", sans-serif;
}

.tips {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
  padding: 18px;
}
.tips > div {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 11px;
  align-items: flex-start;
}
.tips > div > span { color: var(--yellow); font-size: 19px; }
.tips p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.tips strong { color: var(--text); }

footer {
  padding: 32px 10px 4px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
footer strong { color: var(--yellow); letter-spacing: .045em; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  transform: translate(-50%,20px);
  opacity: 0;
  pointer-events: none;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: #111;
  background: var(--yellow);
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
  font-weight: 700;
  transition: .25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%,0); }

@media (max-width: 780px) {
  .app-shell { width: min(100% - 20px,1120px); padding-top: 10px; }
  .topbar { align-items: flex-start; padding: 14px; }
  .brand img { width: 48px; height: 48px; }
  .brand strong { white-space: normal; }
  .toggle-copy { display: none; }
  .toggle-card { padding: 8px 9px; }
  .mini-action { min-width: 50px; }
  .hero { padding: 54px 10px 30px; }
  .workspace, .result-panel.visible { padding: 19px; border-radius: 24px; }
  .section-head { align-items: flex-start; }
  #unicode-input { min-height: 260px; padding: 17px; font-size: 18px; }
  #fml-output { padding: 18px; min-height: 205px; }
  .copy-btn {
    position: static;
    transform: none;
    width: 100%;
    margin-top: 10px;
  }
  .primary-actions { display: grid; grid-template-columns: 1fr; }
  .convert-btn { width: 100%; min-width: 0; order: -1; }
  .secondary-btn { width: 100%; }
  .primary-actions > kbd { display: none; }
  .tips { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .topbar { display: grid; }
  .top-actions { width: 100%; }
  .toggle-card { flex: 1; justify-content: center; }
  .mini-action { flex: 1; }
  .brand small { font-size: 10px; }
  .live-badge { display: none; }
  .section-title p { line-height: 1.45; }
  .typing-bar { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
