/* Nano Studio, Robbie PRO design system (Brand Kits/רובי פרו/brand.md).
   Only Night, Lavender, White and their tints. FbBooster for text, Matritsa Narrow Black for numbers.
   Layout follows the old Nano Banana Studio: a full-width prompt bar on top, settings under it, the gallery below. */
@font-face { font-family: 'Booster'; src: url('/fonts/FbBooster-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Booster'; src: url('/fonts/FbBooster-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Booster'; src: url('/fonts/FbBooster-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Booster'; src: url('/fonts/FbBooster-Black.woff2') format('woff2'); font-weight: 900; font-display: swap; }
@font-face { font-family: 'Matritsa'; src: url('/fonts/FbMatritsaNarrowEnHeb-Black.woff2') format('woff2'); font-weight: 900; font-display: swap; }

:root {
  --night: #12191C; --night-80: #3A4043; --night-60: #717577; --night-40: #A0A3A4; --night-20: #D0D1D2;
  --lav: #9D8AC1; --lav-soft: rgba(157,138,193,.14); --white: #fff;
  --surface: #182024; --surface-2: #1F272B; --line: rgba(255,255,255,.09); --line-strong: rgba(255,255,255,.16);
  --muted: var(--night-40); --faint: var(--night-60);
  --font: 'Booster', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --num: 'Matritsa', 'Booster', sans-serif;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--night); color: var(--white); direction: rtl; line-height: 1.4; -webkit-font-smoothing: antialiased; min-height: 100dvh; }
button, textarea, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: progress; }
a { color: var(--lav); }
main { max-width: 1280px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(env(safe-area-inset-bottom, 0px) + 60px); }
[hidden] { display: none !important; }

.eyebrow { font-weight: 500; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--lav); direction: ltr; unicode-bidi: isolate; }
.num { font-family: var(--num); font-weight: 900; direction: ltr; unicode-bidi: isolate; }
.hint { color: var(--muted); font-size: 13px; }
.ic { width: 22px; height: 22px; flex: none; display: block; }
.ic.sm { width: 18px; height: 18px; }
.ic.xs { width: 14px; height: 14px; }
.ic .acc { stroke: var(--lav); }

.brandline { display: flex; align-items: baseline; gap: 12px; padding: 0 6px 12px; }
.brandline .eyebrow { font-size: 12px; }
.brandline .sub { color: var(--faint); font-size: 12px; }
.brandline .mock { margin-inline-start: auto; }

/* ---------- top: prompt bar + tools ---------- */
.top { display: flex; gap: 12px; align-items: flex-start; position: sticky; top: 12px; z-index: 5; }
.bar { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: var(--shadow); }
.bar.drag { outline: 2px dashed var(--lav); outline-offset: 3px; }
.bar-row { display: flex; align-items: flex-start; gap: 6px; padding: 8px 10px; }
.bar-row + .bar-row { border-top: 1px solid var(--line); }
.n { flex: none; width: 26px; height: 42px; display: grid; place-items: center; font-family: var(--num); font-weight: 900; font-size: 15px; color: var(--lav); direction: ltr; }
.spacer { flex: none; width: 42px; }
.prompt { flex: 1; min-width: 0; border: 0; outline: 0; resize: none; background: transparent; font-size: 17px; line-height: 1.5; padding: 9px 4px; max-height: 45vh; overflow-y: auto; }
.prompt::placeholder { color: var(--faint); }
/* long prompts fold back to two lines when you click away, and open again on focus */
.prompt:not(:focus) { max-height: 3.4em; overflow: hidden; }
.prompt.long:not(:focus) { -webkit-mask-image: linear-gradient(to bottom, #000 45%, transparent); mask-image: linear-gradient(to bottom, #000 45%, transparent); cursor: text; }
.ib { flex: none; width: 42px; height: 42px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 12px; color: var(--white); }
.ib:hover { background: var(--surface-2); }
.ib.on, .ib[aria-pressed="true"] { background: var(--surface-2); }
.ib.dim { color: var(--muted); }
.go { flex: none; height: 42px; padding: 0 20px; border: 0; border-radius: 12px; background: var(--lav); color: var(--night); font-weight: 700; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.go .ic, .go .ic .acc { stroke: var(--night); }
.refs { display: flex; gap: 8px; flex-wrap: wrap; padding: 2px 14px 10px; }
.refs:empty { display: none; }
.ref { position: relative; width: 56px; height: 56px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line-strong); }
.ref img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ref button { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: rgba(18,25,28,.85); border: 0; display: grid; place-items: center; padding: 0; }
.foot { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 0 14px 11px; }
.meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tag { font-family: var(--num); font-weight: 900; font-size: 13px; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px 10px; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.tag.lav { color: var(--night); background: var(--lav); border-color: var(--lav); font-family: var(--font); font-weight: 700; font-size: 12px; direction: rtl; }
.tag.txt { font-family: var(--font); font-weight: 500; font-size: 12px; direction: rtl; }
.add { display: inline-flex; align-items: center; gap: 5px; border: 1px dashed var(--line-strong); background: transparent; color: var(--muted); border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.add:hover { color: var(--white); border-color: var(--lav); }
.tools { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 18px; padding: 8px; box-shadow: var(--shadow); margin-inline-start: auto; }
.modes { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.modes button { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 500; font-size: 14px; }
.modes button[aria-pressed="true"] { background: var(--night-80); color: var(--white); }

/* ---------- cards ---------- */
.panel { margin-top: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.card h3 { font-weight: 900; font-size: 17px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { height: 34px; border: 0; background: transparent; color: var(--muted); border-radius: 8px; font-size: 14px; font-weight: 500; padding: 0 10px; white-space: nowrap; }
.seg.nums button { font-family: var(--num); font-weight: 900; font-size: 15px; }
.seg button[aria-pressed="true"] { background: var(--night-80); color: var(--white); }
.seg button:hover:not([aria-pressed="true"]) { color: var(--white); }

/* aspect ratio: big shape + orientation + slider */
.ar { display: flex; align-items: center; gap: 26px; }
.ar-box { flex: none; width: 160px; height: 160px; position: relative; display: grid; place-items: center; }
.ar-box .ghost { position: absolute; width: 104px; height: 104px; border: 1.5px dashed var(--faint); border-radius: 6px; }
.ar-box .shape { position: relative; border: 2px solid var(--lav); border-radius: 8px; background: rgba(157,138,193,.08); display: grid; place-items: center; font-family: var(--num); font-weight: 900; font-size: 24px; direction: ltr; transition: width .2s, height .2s; }
.ar-ctl { flex: 1; min-width: 0; display: grid; gap: 22px; }
.slider { direction: ltr; }
.slider input { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 4px; border-radius: 4px; outline: 0; background: var(--line-strong); }
.slider input::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--white); border: 5px solid var(--lav); cursor: pointer; }
.slider input::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--white); border: 5px solid var(--lav); cursor: pointer; }
.ticks { display: flex; justify-content: space-between; margin-top: 10px; font-family: var(--num); font-weight: 900; font-size: 11px; color: var(--faint); }
.ticks button { border: 0; background: none; color: inherit; font: inherit; padding: 2px 0; }
.ticks button[aria-pressed="true"] { color: var(--white); }

/* output card as a boarding ticket: settings on the body, the total on the stub */
.ticket { --notch: 11px; position: relative; display: grid; grid-template-columns: 1fr 30%; }
.ticket-body { background: var(--surface); border-radius: 0 18px 18px 0; padding: 18px 20px;
  -webkit-mask: radial-gradient(circle var(--notch) at 0 0, transparent 98%, #000) top left / 100% 51% no-repeat, radial-gradient(circle var(--notch) at 0 100%, transparent 98%, #000) bottom left / 100% 51% no-repeat;
          mask: radial-gradient(circle var(--notch) at 0 0, transparent 98%, #000) top left / 100% 51% no-repeat, radial-gradient(circle var(--notch) at 0 100%, transparent 98%, #000) bottom left / 100% 51% no-repeat; }
.ticket-stub { background: var(--lav); color: var(--night); border-radius: 18px 0 0 18px; padding: 18px 10px; display: flex; flex-direction: column; justify-content: space-between; align-items: center; text-align: center; gap: 8px;
  -webkit-mask: radial-gradient(circle var(--notch) at 100% 0, transparent 98%, #000) top right / 100% 51% no-repeat, radial-gradient(circle var(--notch) at 100% 100%, transparent 98%, #000) bottom right / 100% 51% no-repeat;
          mask: radial-gradient(circle var(--notch) at 100% 0, transparent 98%, #000) top right / 100% 51% no-repeat, radial-gradient(circle var(--notch) at 100% 100%, transparent 98%, #000) bottom right / 100% 51% no-repeat; }
.ticket-stub .eyebrow { color: var(--night); opacity: .75; }
.ticket::after { content: ''; position: absolute; top: 17px; bottom: 17px; left: 30%; width: 2px; margin-left: -1px; background: repeating-linear-gradient(to bottom, var(--lav) 0 7px, transparent 7px 12px); border-radius: 2px; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.opt:first-of-type { border-top: 0; padding-top: 4px; }
.opt label { font-size: 15px; }
.opt small { display: block; color: var(--muted); font-size: 12px; }
.opt .seg { flex: none; width: 200px; }
.ticket-stub .big { font-family: var(--num); font-weight: 900; font-size: 64px; line-height: .9; direction: ltr; }
.code { display: inline-flex; align-items: center; gap: 5px; font-family: var(--num); font-weight: 900; font-size: 13px; letter-spacing: .06em; direction: ltr; }
.code .plane { width: 12px; height: 12px; }

/* ---------- gallery ---------- */
.status { margin: 20px 6px 0; color: var(--muted); font-size: 14px; min-height: 22px; display: flex; align-items: center; gap: 10px; }
.status .num { color: var(--lav); font-size: 16px; }
.status.err { color: var(--white); }
.status.err::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--lav); flex: none; }
.gallery { margin-top: 12px; columns: 4 240px; column-gap: 10px; }
.tile { break-inside: avoid; margin-bottom: 10px; position: relative; border-radius: 14px; overflow: hidden; background: var(--surface-2); }
.tile img { display: block; width: 100%; height: auto; cursor: zoom-in; }
.tile .over { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; padding: 10px; background: linear-gradient(to top, rgba(18,25,28,.92), transparent 60%); opacity: 0; transition: opacity .15s; pointer-events: none; }
.tile:hover .over, .tile:focus-within .over { opacity: 1; }
.tile .over p { font-size: 13px; margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.acts { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; pointer-events: auto; }
.act { height: 32px; border: 0; border-radius: 9px; background: rgba(255,255,255,.12); color: var(--white); display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; font-size: 12px; font-weight: 500; text-decoration: none; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.act:hover { background: rgba(255,255,255,.2); }
.acts .tag { margin-inline-start: auto; background: rgba(18,25,28,.6); }
.tile.loading { display: grid; place-items: center; }
.tile.loading::before { content: ''; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(157,138,193,.14) 50%, transparent 70%); animation: sweep 1.6s linear infinite; }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.timer { position: relative; font-family: var(--num); font-weight: 900; font-size: 34px; color: var(--lav); direction: ltr; }
.tile.error { padding: 18px 16px; color: var(--muted); font-size: 13px; border: 1px solid var(--line-strong); background: var(--surface); }
.tile.error b { display: block; color: var(--white); margin-bottom: 4px; }
.empty { text-align: center; color: var(--muted); padding: 70px 16px; }
.empty .ic { width: 44px; height: 44px; margin: 0 auto 12px; }

/* ---------- voiceover ---------- */
body[data-mode="voice"] .img-only, body:not([data-mode="voice"]) .voice-only { display: none !important; }
.voice { display: grid; gap: 12px; margin-top: 12px; }
.vgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.row-opt small { display: block; color: var(--muted); font-size: 12px; }
.select { position: relative; flex: none; }
.select select { -webkit-appearance: none; appearance: none; height: 38px; min-width: 170px; padding: 0 14px 0 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--white); font-size: 15px; cursor: pointer; outline: none; }
.select select:focus { border-color: var(--lav); }
.select .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--muted); }
.voices { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; max-height: 340px; overflow: auto; padding: 2px; }
.vchip { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 8px 10px; cursor: pointer; text-align: start; }
.vchip[aria-pressed="true"] { border-color: var(--lav); background: var(--lav-soft); }
.vchip .vt { flex: 1; min-width: 0; display: grid; }
.vchip .vn { font-weight: 700; font-size: 14px; direction: ltr; text-align: right; }
.vchip .vd { color: var(--muted); font-size: 12px; }
.play { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line-strong); background: transparent; display: grid; place-items: center; padding: 0; }
.play:hover { border-color: var(--lav); }
.play.busy { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.pill { border: 1px solid var(--line-strong); background: transparent; color: var(--white); border-radius: 999px; padding: 5px 13px; font-size: 13px; }
.pill:hover { border-color: var(--lav); }
.pill[aria-pressed="true"] { border-color: var(--lav); background: var(--lav-soft); }
.pill.primary { background: var(--lav); border-color: var(--lav); color: var(--night); font-weight: 700; }
.field { width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--white); padding: 12px 14px; resize: vertical; min-height: 110px; outline: 0; font-size: 15px; line-height: 1.55; }
.field:focus { border-color: var(--lav); }
.field::placeholder { color: var(--faint); }
.field.big { min-height: 180px; font-size: 17px; }
.foot2 { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.foot2 .go { height: 48px; padding: 0 26px; }
.sc-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.takes { display: grid; gap: 10px; }
.take { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; display: grid; gap: 10px; }
.take .th { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.take p { font-size: 14px; color: var(--night-20); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.take audio { width: 100%; height: 40px; }
.take .acts .act { background: var(--surface-2); }
.nk-text { border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); padding: 14px 16px; font-size: 22px; line-height: 2.1; min-height: 180px; max-height: 440px; overflow: auto; white-space: pre-wrap; }
.nk-text .w { cursor: pointer; border-radius: 6px; padding: 0 1px; }
.nk-text .w:hover { background: var(--night-80); }
.nk-text .w.sel { background: var(--lav-soft); outline: 1.5px solid var(--lav); }
.nk-edit { margin-top: 12px; border: 1px solid var(--line-strong); border-radius: 14px; padding: 12px; display: grid; gap: 10px; background: var(--surface-2); }
.nk-row { display: flex; gap: 8px; align-items: center; }
#nkWord { flex: 1; min-width: 0; font-size: 26px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--night); color: var(--white); outline: 0; }
#nkWord:focus { border-color: var(--lav); }
.nk-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.nk-opts .pill { font-size: 20px; padding: 2px 14px; }
.nk-keys { display: flex; flex-wrap: wrap; gap: 6px; }
.nk-keys button { min-width: 48px; height: 50px; border: 1px solid var(--line); background: var(--night); border-radius: 10px; font-size: 24px; line-height: 1; display: grid; place-items: center; padding: 0 8px; }
.nk-keys button small { font-size: 10px; color: var(--muted); display: block; margin-top: 2px; }
.nk-keys button:hover { border-color: var(--lav); }
.nk-keys button.on { background: var(--lav-soft); border-color: var(--lav); }

/* ---------- viewer + login ---------- */
dialog.viewer { border: 0; padding: 0; background: transparent; max-width: 96vw; margin: auto; }
dialog.viewer::backdrop { background: rgba(8,11,13,.85); }
dialog.viewer img { display: block; max-width: 96vw; max-height: 92vh; border-radius: 12px; }
.login { position: fixed; inset: 0; z-index: 50; background: var(--night); display: flex; align-items: center; justify-content: center; padding: 24px; }
.login .box { width: 100%; max-width: 340px; text-align: center; display: grid; gap: 12px; }
.login h1 { font-weight: 900; font-size: 30px; }
.login p { color: var(--muted); font-size: 15px; }
.login .go { height: 52px; width: 100%; font-size: 16px; }
.login input { display: block; width: 100%; height: 60px; text-align: center; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--white); outline: none; font-family: var(--num); font-weight: 900; font-size: 30px; letter-spacing: 8px; direction: ltr; }
.login input:focus { border-color: var(--lav); }
.login .ghost-btn { height: 52px; width: 100%; border-radius: 12px; border: 1px solid var(--line-strong); background: transparent; color: var(--white); font-weight: 700; }

@media (max-width: 760px) {
  main { padding-left: 12px; padding-right: 12px; }
  .top { flex-wrap: wrap; position: static; }
  .bar { flex-basis: 100%; }
  .tools { order: -1; padding: 4px; }
  .modes button span, .hide-sm { display: none; }
  .bar-row:first-child { flex-wrap: wrap; }
  .bar-row:first-child .prompt { flex-basis: calc(100% - 90px); }
  .bar-row:first-child #toggle { order: 3; }
  .bar-row:first-child .go { order: 4; flex: 1; }
  .panel, .vgrid { grid-template-columns: 1fr; }
  .ar { flex-direction: column; gap: 14px; align-items: stretch; }
  .ar-box { margin: 0 auto; }
  .opt { flex-direction: column; align-items: stretch; gap: 8px; }
  .opt .seg { width: 100%; }
  .ticket { grid-template-columns: 1fr 28%; }
  .ticket::after { left: 28%; }
  .ticks { font-size: 10px; }
  .gallery { columns: 2 140px; }
  .tile .over { opacity: 1; background: linear-gradient(to top, rgba(18,25,28,.9), transparent 45%); }
  .tile .over p, .act span, .acts .tag { display: none; }
  .act { padding: 0 8px; height: 30px; }
  .acts .ar2 { display: none; }
  .tile .over { padding: 6px; }
  .row-opt { flex-wrap: wrap; }
  .voices { grid-template-columns: 1fr 1fr; }
  .vchip { padding: 8px; }
  .select select { min-width: 150px; }
  .foot2 .go { flex: 1; }
}
