:root {
  --night: #0c0b0a;
  --night-2: #141210;
  --cream: #e6dfd3;
  --cream-dim: #b9b1a4;
  --smoke: #8a837a;
  --ash: #6e6861;
  --line: rgba(230, 223, 211, .16);
  --line-2: rgba(230, 223, 211, .32);
  --rose: #c9a9a6;           /* faded, used only for hearts + hover */
  --serif: "Cormorant Garamond", "Cormorant", Garamond, Georgia, serif;
  --sans: "Jost", "Futura", "Helvetica Neue", sans-serif;
  --fa: "Vazirmatn", "Noto Naskh Arabic", Tahoma, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--night);
  color: var(--cream);
  font-family: var(--serif);
  font-weight: 300;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; }
.fa { font-family: var(--fa); font-weight: 300; }
.heart { font-style: normal; color: var(--rose); }

/* ---- atmosphere: hazy light, dust, film grain ---------------------- */
.haze {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 45% at 50% -5%, rgba(230,223,211,.13), transparent 70%),
    radial-gradient(ellipse 50% 40% at 85% 110%, rgba(201,169,166,.06), transparent 70%);
  animation: breathe-light 14s ease-in-out infinite alternate;
}
@keyframes breathe-light { to { opacity: .6; } }
#veins { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
.grain {
  position: fixed; inset: -50%; z-index: 50; pointer-events: none;
  opacity: .2; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.4 -.2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0,0) } 20% { transform: translate(-3%,2%) }
  40% { transform: translate(2%,-4%) } 60% { transform: translate(-4%,-1%) }
  80% { transform: translate(3%,3%) } 100% { transform: translate(0,0) }
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: 40; pointer-events: none;
  background: radial-gradient(ellipse at 50% 35%, transparent 45%, rgba(0,0,0,.7) 100%);
}

/* ---- header -------------------------------------------------------- */
.top {
  position: relative; z-index: 2;
  display: flex; justify-content: space-between; gap: 16px;
  padding: max(20px, env(safe-area-inset-top)) clamp(18px, 4vw, 40px) 0;
}
.caption {
  display: flex; flex-direction: column; gap: 2px;
  font-family: var(--sans); font-weight: 300; font-size: 10px;
  letter-spacing: .28em; text-transform: lowercase; color: var(--smoke);
}
.caption.right { text-align: right; }

.hero { position: relative; z-index: 2; text-align: center; padding: 44px 18px 0; }
.eyes { display: flex; justify-content: center; gap: clamp(26px, 8vw, 96px); margin-bottom: 18px; opacity: .82; }
.eye { width: clamp(70px, 15vw, 132px); filter: blur(.35px); }
.eye .white { fill: rgba(230,223,211,.9); }
.eye .ir { fill: #4a4640; }
.eye .pu { fill: var(--night); transition: r .6s ease; }
.eye .glint { fill: var(--cream); opacity: .85; }
.eye .lash { fill: none; stroke: var(--night); stroke-width: 3.5; stroke-linecap: round; }
.eye .blink { fill: var(--night); transition: height .12s ease-in; }
.eye.closed .blink { height: 110px; }

.title {
  margin: 0; font-family: var(--serif); font-weight: 300;
  font-size: clamp(58px, 15vw, 150px); line-height: .95; letter-spacing: -.01em;
  color: var(--cream);
  text-shadow: 0 0 28px rgba(230,223,211,.22), 0 0 2px rgba(230,223,211,.4);
}
.title em { font-style: italic; color: var(--cream-dim); }
.sub {
  margin: 18px 0 0; font-family: var(--sans); font-weight: 300; font-size: 11px;
  letter-spacing: .38em; text-transform: lowercase; color: var(--cream-dim);
}
.sub span { color: var(--ash); margin: 0 .3em; }
.sub .fa { letter-spacing: 0; font-size: 14px; color: var(--cream-dim); margin: 0; }

/* ---- the card ------------------------------------------------------ */
.card {
  position: relative; z-index: 3;
  width: min(980px, calc(100% - 32px));
  margin: 44px auto 0;
  padding: 8px clamp(18px, 3vw, 36px) 22px;
  background: linear-gradient(180deg, rgba(20,18,16,.72), rgba(12,11,10,.55));
  border: 1px solid var(--line);
  border-radius: 2px;
  box-shadow: 0 40px 90px rgba(0,0,0,.55);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}

.langbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 0 8px; }
.seg { display: inline-flex; gap: 4px; }
.seg button {
  padding: 8px 12px; min-width: 40px;
  font-family: var(--sans); font-weight: 300; font-size: 13px; letter-spacing: .22em;
  color: var(--cream-dim); border-bottom: 1px solid transparent; transition: color .3s, border-color .3s;
}
.seg button.fa { font-family: var(--fa); letter-spacing: 0; font-size: 15px; padding-top: 6px; }
.seg button:hover { color: var(--cream); }
.seg button[aria-checked="true"] { color: #fff8ee; border-bottom-color: var(--cream); text-shadow: 0 0 10px rgba(230,223,211,.35); }
.swap {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(230,223,211,.55);
  display: grid; place-items: center; color: var(--cream); flex: none;
  transition: transform .6s ease, color .3s, border-color .3s;
}
.swap:hover, .swap:active { transform: rotate(180deg); color: var(--rose); border-color: var(--rose); }

.panes { display: grid; grid-template-columns: 1fr 1fr; }
.pane { display: flex; flex-direction: column; min-width: 0; padding: 14px 0; }
.pane:first-child { padding-right: clamp(16px, 2.5vw, 30px); }
.pane + .pane { border-left: 1px solid var(--line); padding-left: clamp(16px, 2.5vw, 30px); }
.pane-head {
  display: flex; justify-content: space-between; padding-bottom: 8px;
  font-family: var(--sans); font-weight: 300; font-size: 10px; letter-spacing: .28em; color: var(--ash);
}
#src, .dst {
  width: 100%; min-height: 200px; flex: 1;
  font-family: var(--serif); font-weight: 300; font-size: clamp(25px, 3vw, 31px); line-height: 1.28;
  color: var(--cream); background: transparent; border: 0; outline: none; resize: none;
  padding: 8px 0; white-space: pre-wrap; overflow-wrap: anywhere;
}
.dst { font-style: italic; }
#src::placeholder { color: var(--smoke); font-style: italic; }
#src[dir="rtl"], .dst[dir="rtl"] { font-family: var(--fa); font-weight: 300; font-style: normal; font-size: clamp(21px, 2.6vw, 26px); line-height: 1.8; text-align: right; }
.pane-head .fa { letter-spacing: 0; font-size: 12px; }
.dst:empty::before { content: attr(data-empty); color: var(--ash); }
.dst.loading { opacity: .35; filter: blur(1.5px); transition: opacity .4s, filter .4s; }
.dst.err { font-family: var(--sans); font-style: normal; font-size: 14px; color: var(--rose); }

.tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding-top: 12px; }
.tools button {
  padding: 9px 16px; border: 1px solid rgba(230,223,211,.5); border-radius: 999px;
  font-family: var(--sans); font-weight: 300; font-size: 11px; letter-spacing: .24em; text-transform: lowercase;
  color: var(--cream); transition: color .3s, border-color .3s, background .3s;
}
.tools button b { font-weight: 400; margin-right: 2px; }
.tools button:hover { color: #fff8ee; border-color: var(--cream); }
.tools .play.main { color: var(--night); border-color: var(--cream); background: var(--cream); font-weight: 400; }
.tools .play.main:hover { color: var(--night); background: #fff8ee; }
.tools .play.main.playing { background: var(--rose); border-color: var(--rose); color: var(--night); }
.tools .ghost { border-color: transparent; margin-left: auto; color: var(--cream-dim); text-decoration: underline; text-decoration-color: rgba(230,223,211,.35); text-underline-offset: 4px; }
.tools .ghost:hover { border-color: transparent; color: var(--cream); }
.tools button.playing { color: var(--rose); border-color: var(--rose); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }
button:focus-visible { outline: 1px solid var(--rose); outline-offset: 3px; }

.cardfoot {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line);
  font-family: var(--sans); font-weight: 300; font-size: 10px; letter-spacing: .28em; color: var(--ash);
}
.sig { font-family: var(--serif); font-style: italic; font-size: 26px; letter-spacing: 0; color: var(--cream-dim); }

/* ---- recently ------------------------------------------------------ */
.sheet { position: relative; z-index: 2; width: min(980px, calc(100% - 32px)); margin: 60px auto 0; padding-bottom: max(60px, env(safe-area-inset-bottom)); }
.sheet h2 {
  font-family: var(--sans); font-weight: 300; font-size: 10px; letter-spacing: .34em;
  color: var(--smoke); margin: 0 0 14px; text-align: center;
}
#history { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
#history li {
  padding: 14px 16px 12px; cursor: pointer; border: 1px solid rgba(230,223,211,.26);
  background: rgba(20,18,16,.6); display: flex; flex-direction: column; gap: 6px;
  transition: border-color .4s;
}
#history li:hover { border-color: rgba(230,223,211,.55); }
#history .h-meta { font-family: var(--sans); font-size: 9px; letter-spacing: .24em; color: var(--ash); display: flex; justify-content: space-between; text-transform: lowercase; }
#history .h-src { font-size: 17px; color: var(--cream-dim); }
#history .h-dst { font-size: 20px; font-style: italic; }
#history [dir="rtl"] { font-family: var(--fa); font-style: normal; font-size: 16px; text-align: right; }
#history:empty::before { content: "nothing here yet…"; display: block; text-align: center; font-style: italic; color: var(--ash); font-size: 19px; grid-column: 1 / -1; }

.foot {
  position: relative; z-index: 2; text-align: center;
  font-family: var(--sans); font-weight: 300; font-size: 10px; letter-spacing: .3em; color: var(--ash);
  padding: 70px 16px max(30px, env(safe-area-inset-bottom));
}

/* ---- phones -------------------------------------------------------- */
@media (max-width: 720px) {
  .hero { padding-top: 34px; }
  .panes { grid-template-columns: 1fr; }
  .pane:first-child { padding-right: 0; }
  .pane + .pane { border-left: 0; border-top: 1px solid var(--line); padding-left: 0; margin-top: 6px; padding-top: 18px; }
  #src, .dst { min-height: 120px; }
  .seg button { padding: 8px 9px; min-width: 34px; }
  .card { margin-top: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  .grain, .haze { animation: none; }
}
