/* Imaginator AI — Desktop Studio App (/studio-app), Task 2: CSS foundation +
   static 3-column layout. Built ONLY on real Awesomic tokens already defined
   in site.css's :root (--obsidian/--ember/--orchid/--canvas/--snow/--fog/
   --pebble/--steel/--slate/--ash/--mist/--radius/--radius-lg) and the real
   component-class conventions already established there (.aw-card/.aw-pill/
   .aw-chip/.aw-seg/.aw-toggle/.aw-input/.btn/.btn-primary). No new color
   custom properties are invented here. This file is a DIFFERENT, parallel
   stylesheet from app/webapp/static/studio.css (the Telegram Mini App's own
   CSS, with its own --r/--acc-1/--btn-style tokens) — do not mix the two. */

/* ---------- app-shell top bar ----------
   Reuses chrome.css's real .aw-brand/.aw-mark/.aw-word/.aw-dot/.aw-avatar/
   .aw-pill component classes (already linked in studio_app.html's <head>);
   only the outer bar/nav layout is new here. */
.studio-topbar{position:sticky;top:0;z-index:40;background:var(--canvas);border-bottom:1px solid var(--pebble)}
.studio-topbar-inner{max-width:var(--maxw);margin:0 auto;height:74px;padding:0 30px;
  display:flex;align-items:center;gap:24px}
.studio-nav{display:flex;align-items:center;gap:4px;flex:1 1 auto}
.studio-nav a{padding:8px 16px;border-radius:999px;font-size:14px;font-weight:600;color:var(--slate)}
.studio-nav a:hover{color:var(--obsidian)}
.studio-nav a.active{background:var(--obsidian);color:#fff}
.studio-topbar-right{display:flex;align-items:center;gap:12px;flex:0 0 auto}
.studio-credit-add{display:inline-flex;align-items:center;gap:7px;height:36px;padding:0 14px 0 8px;
  border-radius:999px;background:var(--fog);color:var(--obsidian);font-size:13px;font-weight:700}
.studio-credit-add:hover{background:var(--pebble)}
.studio-credit-add-icon{display:flex;align-items:center;justify-content:center;flex:none;
  width:22px;height:22px;border-radius:50%;background:var(--orchid);color:#fff;
  font-size:15px;font-weight:700;line-height:1}
.studio-credit-add-label{white-space:nowrap}

/* ---------- 3-column shell ---------- */
.studio-shell{max-width:var(--maxw);margin:0 auto;padding:32px 30px 64px;
  display:grid;grid-template-columns:288px minmax(0,1fr) 288px;gap:28px;align-items:start}

.studio-col{display:flex;flex-direction:column;gap:20px;min-width:0}
.studio-col-center{padding:0;min-height:400px}

/* Pin the left column under the sticky 74px topbar; scroll inside it when tall. */
#studio-left{position:sticky;top:90px;max-height:calc(100vh - 106px);overflow-y:auto;overscroll-behavior:contain}

/* each left/right block is its own aw-card-derived panel */
.studio-panel{padding:22px}
.studio-panel h4{margin:0 0 14px}
.studio-panel p{margin:0 0 14px;color:var(--steel);font-size:13.5px;line-height:1.55}
.studio-panel p:last-child{margin-bottom:0}

/* ---------- left: "ВАШ АВАТАР" — 3 upload slots ---------- */
.studio-avatar-slots{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-bottom:14px}
.studio-avatar-slot{display:flex;flex-direction:column;align-items:center;gap:6px}
.studio-avatar-slot-box{width:100%;aspect-ratio:1/1;border-radius:var(--radius);
  border:1.5px dashed var(--mist);background:var(--fog);
  display:flex;align-items:center;justify-content:center;
  color:var(--ash);font-size:22px;font-weight:300;line-height:1}
.studio-avatar-slot-label{font-size:11px;font-weight:600;color:var(--steel);text-align:center}
.studio-avatar-progress{font-size:13px;color:var(--steel);margin:0 0 14px}

/* ---------- left: "ВАШ АВАТАР" — saved-avatar picker (vertical list) ---------- */
.studio-avatar-pick{display:flex;align-items:center;gap:10px;padding:8px;
  border-radius:var(--radius);border:1px solid var(--pebble);cursor:pointer;margin-bottom:8px}
.studio-avatar-pick.is-selected{border-color:var(--orchid);box-shadow:0 0 0 2px var(--orchid)}
.studio-avatar-pick-thumb{position:relative;flex:none;width:36px;height:36px;border-radius:8px;overflow:hidden;background:var(--fog)}
.studio-avatar-pick-thumb img{width:100%;height:100%;object-fit:cover;display:block}
.studio-avatar-pick-noimg{display:block;width:100%;height:100%}
.studio-avatar-pick-check{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
  background:rgba(254,69,226,.85);color:#fff;font-size:14px}
.studio-avatar-pick-name{flex:1;font-size:13.5px;font-weight:600;color:var(--obsidian);
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.studio-avatar-del{flex:none;border:none;background:none;cursor:pointer;font-size:13px;color:var(--ash)}
.studio-avatar-del:hover{color:#b91c1c}

/* ---------- shared full-width CTA + disabled state ----------
   Reuses the codebase's established .btn-primary:disabled convention
   (opacity dimming of the obsidian button, see flow.css/studio.css) rather
   than inventing a separate grey token. */
.studio-cta{width:100%}
.studio-cta:disabled,.studio-cta[disabled]{opacity:.4;cursor:not-allowed;box-shadow:none;filter:grayscale(.4)}

/* ---------- left: "ФОРМАТ ФОТО" — 2x2 toggle grid ---------- */
.studio-format-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:8px;margin-bottom:16px}
.studio-format-btn{display:flex;align-items:center;gap:10px;
  padding:10px 12px;border-radius:var(--radius);border:1px solid var(--pebble);
  background:var(--snow);color:var(--slate);font-family:var(--ui);cursor:pointer}
.studio-format-btn.is-on{background:var(--obsidian);color:#fff;border-color:var(--obsidian)}

/* Small aspect-ratio "swatch" icon, ported from the mockup's own approach:
   a bordered rect whose own w/h ratio visually mirrors the format's ratio
   (no SVG/icon font needed). Sizes/colors read directly off the mockup via
   getComputedStyle. */
.studio-format-icon{flex:none;display:inline-block;border:2px solid var(--pebble);border-radius:4px}
.studio-format-btn.is-on .studio-format-icon{border-color:var(--orchid)}
.studio-format-icon-portrait{width:14px;height:18px}
.studio-format-icon-square{width:16px;height:16px}
.studio-format-icon-stories{width:11px;height:18px}
.studio-format-icon-landscape{width:20px;height:12px}
.studio-format-icon-insta{width:14px;height:17px}

.studio-format-label{display:flex;flex-direction:column;text-align:left;line-height:1.3}
.studio-format-name{font-size:13.5px;font-weight:700}
.studio-format-ratio{font-size:11px;font-weight:400;color:var(--steel)}
.studio-format-btn.is-on .studio-format-ratio{color:var(--ash)}

.studio-hd-row{display:flex;align-items:center;justify-content:space-between;gap:12px}
.studio-hd-row .studio-hd-copy{display:flex;flex-direction:column;gap:2px}
.studio-hd-row .studio-hd-title{font-size:14px;font-weight:700;color:var(--obsidian)}
.studio-hd-row .studio-hd-caption{font-size:12px;color:var(--steel)}
/* Page-scoped override of site.css's shared .aw-toggle.is-on{background:
   var(--obsidian)} — the brand accent here, not the generic dark toggle
   state used elsewhere on the site. #id beats site.css's .aw-toggle.is-on
   on specificity, so no !important needed. */
#studio-hd-toggle.is-on{background:var(--orchid)}
#studio-style-toggle.is-on{background:var(--orchid)}

/* ---------- hairstyle / colour selects ---------- */
.studio-hair{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:16px}
.studio-hair-field{display:flex;flex-direction:column;gap:5px}
.studio-hair-label{font-size:12px;font-weight:700;color:var(--obsidian)}
.studio-hair-select{width:100%;font-size:13px;padding:9px 10px}

/* ---------- outfit / look select ---------- */
.studio-outfit{margin-top:12px}
.studio-outfit-field{display:flex;flex-direction:column;gap:5px}
.studio-outfit-label{font-size:12px;font-weight:700;color:var(--obsidian)}
.studio-outfit-select{width:100%;font-size:13px;padding:9px 10px}

/* ---------- makeup level select ---------- */
.studio-makeup{margin-top:12px}
.studio-makeup-field{display:flex;flex-direction:column;gap:5px}
.studio-makeup-label{font-size:12px;font-weight:700;color:var(--obsidian)}
.studio-makeup-select{width:100%;font-size:13px;padding:9px 10px}

/* Reveal the look settings only when «Улучшать образ» is on. */
.studio-look-settings{display:none}
.studio-look-settings.is-open{display:block}

/* ---------- face-source toggle + one-off selfie drop ---------- */
.studio-source-tabs{margin-bottom:16px}
#studio-source-tabs button.is-on{background:var(--obsidian);color:#fff}
.studio-source-drop{display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:6px;min-height:150px;padding:20px;text-align:center;cursor:pointer;
  border:1.5px dashed var(--mist);border-radius:var(--radius);background:var(--fog)}
.studio-source-drop:hover{border-color:var(--ash)}
.studio-source-drop-ico{font-size:26px;color:var(--ash);line-height:1}
.studio-source-drop-t{font-size:14px;font-weight:700;color:var(--obsidian)}
.studio-source-drop-s{font-size:12px;color:var(--steel)}
.studio-source-preview{max-width:100%;max-height:260px;border-radius:var(--radius);display:block}
.studio-source-msg{margin:8px 0 0;font-size:12.5px;color:#b91c1c}

/* A2: extra same-person selfies adder (studio-extra-shots, extra-thumb/extra-add/extra-hint) */
.studio-extra-shots{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-top:10px}
.extra-thumb{width:52px;height:52px;border-radius:10px;object-fit:cover;border:1px solid var(--mist)}
.extra-add{width:52px;height:52px;border-radius:10px;border:1.5px dashed var(--mist);background:var(--fog);
  display:flex;align-items:center;justify-content:center;text-align:center;font-size:10px;color:var(--steel);
  cursor:pointer;line-height:1.2;padding:2px}
.extra-add:hover{border-color:var(--ash);background:var(--pebble)}
.extra-add input{display:none}
.extra-hint{flex:1 1 100%;font-size:12px;color:var(--ash)}

/* ---------- left: "ВАШ НАБОР" summary ---------- */
.studio-cart-summary{display:flex;align-items:center;justify-content:space-between;
  padding:12px 14px;border-radius:var(--radius);background:var(--fog);margin-bottom:16px}
.studio-cart-summary .studio-cart-label{font-size:13.5px;font-weight:700;color:var(--slate)}
.studio-cart-summary .studio-cart-value{font-size:13.5px;font-weight:800;color:var(--obsidian)}
.studio-cart-list{list-style:none;margin:0 0 14px;padding:0;display:flex;flex-direction:column;gap:8px}
.studio-cart-item{display:flex;align-items:center;gap:10px;padding:8px;border-radius:var(--radius);background:var(--fog)}
.studio-cart-item-thumb{width:34px;height:34px;border-radius:8px;object-fit:cover;flex:none;background:var(--pebble)}
.studio-cart-item-title{flex:1;min-width:0;font-size:13px;font-weight:600;color:var(--obsidian);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.studio-cart-item-count{font-size:12px;font-weight:700;color:var(--steel);flex:none}
.studio-cart-remove{flex:none;width:24px;height:24px;border:none;border-radius:50%;background:var(--pebble);color:var(--slate);font-size:16px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center}
.studio-cart-remove:hover{background:#e11d48;color:#fff}

/* ---------- center: page heading ---------- */
.studio-heading{margin-bottom:20px}
.studio-heading h1{margin:0 0 8px;font-size:28px;line-height:1.2}
.studio-heading p{margin:0;color:var(--steel);font-size:14px;line-height:1.5}

/* ---------- center: "Свой сюжет" freeform-prompt card ---------- */
.studio-custom-card{margin-bottom:20px}
.studio-custom-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}
.studio-custom-head h4{margin:0}
.studio-custom-optional{font-size:12px;font-weight:600;color:var(--steel)}
.studio-custom-textarea{width:100%;min-height:72px;resize:vertical;font-family:inherit;
  padding:12px 14px;margin-bottom:12px}
.studio-custom-chips{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:14px}
.studio-custom-chips:empty{margin-bottom:0}
.studio-custom-list{list-style:none;margin:14px 0 0;padding:0;display:flex;flex-direction:column;gap:8px}
.studio-custom-list:empty{margin-top:0}
.studio-custom-list li{display:flex;align-items:center;justify-content:space-between;gap:10px;
  padding:8px 12px;border-radius:var(--radius);background:var(--fog);font-size:13px;color:var(--slate)}
.studio-custom-list li span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.studio-custom-list li button{flex:none;border:none;background:none;color:var(--ash);
  font-size:14px;cursor:pointer;line-height:1}
.studio-custom-list li button:hover{color:var(--obsidian)}

/* ---------- center: catalog (Task 3: real server-rendered grid) ---------- */
.studio-catalog-head{display:flex;align-items:center;justify-content:space-between;
  gap:16px;margin-bottom:16px;flex-wrap:wrap}
.studio-search{position:relative;flex:1 1 260px;max-width:340px}
.studio-search .aw-input{padding-left:38px}
.studio-search-ic{position:absolute;left:14px;top:50%;transform:translateY(-50%);
  color:var(--ash);font-size:15px;pointer-events:none}

.studio-chips{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:20px}

.studio-tab-panel.is-hidden-tab{display:none}

.studio-catalog-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:16px}

.studio-catalog-empty{text-align:center;color:var(--steel);
  padding:40px 16px;font-size:14px}

.studio-style-card{position:relative;background:var(--snow);border:1px solid var(--pebble);
  border-radius:var(--radius);overflow:hidden;cursor:pointer;
  transition:border-color .15s var(--ease),transform .15s var(--ease)}
.studio-style-card:hover{transform:translateY(-2px);border-color:var(--mist)}
.studio-style-card.is-selected{border-color:var(--orchid);box-shadow:0 0 0 2px var(--orchid)}
.studio-check{position:absolute;top:10px;right:10px;width:24px;height:24px;border-radius:50%;
  background:var(--snow);border:1.5px solid var(--pebble);z-index:1;
  display:flex;align-items:center;justify-content:center;color:transparent;font-size:13px}
.studio-style-card.is-selected .studio-check{background:var(--orchid);border-color:var(--orchid);color:#fff}

.studio-card-thumb{position:relative;width:100%;aspect-ratio:3/4;background:var(--fog);overflow:hidden}
.studio-card-thumb img{width:100%;height:100%;object-fit:cover;display:block}
.studio-card-badge{position:absolute;left:8px;top:8px;padding:3px 8px;border-radius:999px;
  background:var(--ember);color:#fff;font-size:11px;font-weight:700}
.studio-card-body{padding:10px 12px}
.studio-card-title{font-size:13.5px;font-weight:700;color:var(--obsidian);line-height:1.3}
.studio-card-cost{margin-top:3px;font-size:12px;font-weight:600;color:var(--steel)}

/* ---------- right: "НЕДАВНИЕ КАДРЫ" + recent-frame cards ---------- */
.studio-empty-note{color:var(--steel);font-size:13.5px}
.studio-recent-list{display:flex;flex-direction:column;gap:16px}
.studio-recent-card{padding:10px;border-radius:var(--radius);border:1px solid var(--pebble);background:var(--snow)}
.studio-recent-photo{display:block;width:100%;aspect-ratio:3/4;border-radius:var(--radius);
  overflow:hidden;background:var(--fog);border:none;padding:0;cursor:pointer;margin-bottom:10px}
.studio-recent-photo img{width:100%;height:100%;object-fit:cover;display:block}
.studio-recent-info{min-width:0}
.studio-recent-title{font-size:13.5px;font-weight:700;color:var(--obsidian);
  line-height:1.3;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.studio-recent-date{margin-top:2px;font-size:12px;font-weight:600;color:var(--steel)}
.studio-recent-actions{display:flex;gap:8px;margin-top:10px}
.studio-recent-action{flex:1;padding:8px 10px;border-radius:999px;border:1px solid var(--pebble);
  background:var(--snow);color:var(--slate);font-family:var(--ui);font-size:12.5px;
  font-weight:600;cursor:pointer;text-align:center}
.studio-recent-action:hover{border-color:var(--mist);color:var(--obsidian)}

/* ---------- generation progress overlay: spinner + animated brand bar ---------- */
@keyframes studioGenSpin{to{transform:rotate(360deg)}}
.studio-gen-spinner{width:56px;height:56px;margin:4px auto 18px;border-radius:50%;
  background:conic-gradient(from 0deg,var(--ember),var(--orchid),var(--ember));
  animation:studioGenSpin 1.1s linear infinite;position:relative}
.studio-gen-spinner::before{content:'';position:absolute;inset:6px;border-radius:50%;background:var(--snow)}
.studio-gen-bar{height:6px;border-radius:3px;background:rgba(0,0,0,.08);overflow:hidden}
.studio-gen-bar-fill{height:100%;background:linear-gradient(90deg,var(--ember),var(--orchid),var(--ember));
  background-size:200% 100%;animation:awFlow 2.2s ease-in-out infinite;transition:width .4s ease}

@media (max-width:1180px){
  .studio-shell{grid-template-columns:260px minmax(0,1fr) 260px;gap:20px}
}

/* ---------- phone sticky generate bar (hidden on desktop) ---------- */
.studio-mobile-bar{display:none}

/* ---------- tablet: drop to 2 columns, "Недавние кадры" spans full width ---------- */
@media (max-width:1000px){
  .studio-shell{grid-template-columns:220px minmax(0,1fr)}
  #studio-right{grid-column:1 / -1}
  /* recent frames read better as a row than a tall column when full-width */
  #studio-right .studio-recent-list{flex-direction:row;flex-wrap:wrap}
  #studio-right .studio-recent-card{flex:1 1 200px;max-width:260px}
}

/* ---------- phone: single-column stack + wrapping/scrolling nav + sticky CTA ---------- */
@media (max-width:680px){
  .studio-topbar-inner{height:auto;flex-wrap:wrap;padding:10px 14px;gap:10px}
  .aw-brand{flex:0 0 auto}
  .studio-topbar-right{margin-left:auto}
  /* nav drops to its own full-width row and scrolls horizontally (all links stay reachable) */
  .studio-nav{order:3;flex:1 1 100%;width:100%;overflow-x:auto;flex-wrap:nowrap;
    -webkit-overflow-scrolling:touch;scrollbar-width:none}
  .studio-nav::-webkit-scrollbar{display:none}
  .studio-nav a{white-space:nowrap}
  .studio-credit-add-label{display:none}   /* keep just the "+" pill */

  .studio-shell{grid-template-columns:1fr;padding:16px 14px 96px;gap:16px}
  #studio-left{position:static;max-height:none;overflow:visible}
  #studio-right .studio-recent-list{flex-direction:column}
  #studio-right .studio-recent-card{max-width:none}
  .studio-heading h1{font-size:23px}
  .studio-catalog-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}

  /* sticky bottom action bar mirroring the (now scrolled-up) generate CTA */
  .studio-mobile-bar{display:flex;align-items:center;gap:12px;
    position:fixed;left:0;right:0;bottom:0;z-index:50;
    padding:10px 14px calc(10px + env(safe-area-inset-bottom));
    background:var(--canvas);border-top:1px solid var(--pebble)}
  .studio-mobile-bar-frames{font-size:13px;font-weight:800;color:var(--obsidian);white-space:nowrap}
  #studio-generate-cta-mobile{flex:1;min-width:0}
  #studio-generate-cta-mobile:disabled,#studio-generate-cta-mobile[disabled]{
    opacity:.4;cursor:not-allowed;box-shadow:none;filter:grayscale(.4)}
}
