:root{
  --paper:#F6F7FB;
  --surface:#FFFFFF;
  --ink:#1B2433;
  --muted:#5B677A;
  --blue:#1557FF;
  --blue-ink:#0D3FCC;
  --pale-blue:#D7E4FF;
  --tab-cyan:#4DA3FF;
  --line:#E6EAF2;
  --focus:#1557FF;
  --radius-pill:999px;
  --radius-lg:20px;
  --ok:#1E9E63;
  --ok-bg:#E3F6ED;
  --warn:#B5750A;
  --warn-bg:#FBF0DD;
  --rcv:#3A5BA0;
  --rcv-bg:#E7ECFA;
  --danger:#C23A3A;
  --danger-bg:#FBEAEA;
  --ease:cubic-bezier(.2,.7,.2,1);
}
*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  background:var(--paper);
  color:var(--ink);
  font-family: ui-sans-serif, system-ui, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing:antialiased;
}
img{max-width:100%;display:block;}
button{font-family:inherit;}
a{color:inherit;}
:focus-visible{ outline:2px solid var(--focus); outline-offset:2px; border-radius:6px; }

.flash{
  max-width:1100px; margin:14px auto 0; padding:12px 16px; border-radius:12px;
  font-size:13.5px; font-weight:600;
}
.flash-error{ background:var(--danger-bg); color:var(--danger); border:1px solid #F3C9C9; }
.flash-success{ background:var(--ok-bg); color:var(--ok); border:1px solid #BFE7D3; }

/* ================= LOGIN / SIMPLE CENTERED SCREEN ================= */
.center-screen{ display:flex; flex-direction:column; min-height:100vh; }
.login-wrap{
  max-width:400px; margin:8vh auto 0; padding:0 20px 60px; flex:1;
  display:flex; flex-direction:column; align-items:center; text-align:center;
}
.login-logo{ width:96px; margin:0 auto 20px; filter:drop-shadow(0 10px 18px rgba(21,87,255,.18)); }
.login-card{
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius-lg);
  padding:28px 26px; width:100%; box-shadow:0 20px 40px rgba(20,30,60,.06);
  text-align:left;
}
.login-title{ margin:0 0 4px; font-size:20px; font-weight:700; text-align:center; }
.login-sub{ margin:0 0 22px; color:var(--muted); font-size:13.5px; text-align:center; }
.field{ margin-bottom:14px; }
.field label{ display:block; font-size:12.5px; color:var(--muted); margin-bottom:5px; font-weight:600; }
.field input{
  width:100%; padding:10px 12px; border:1px solid var(--line); border-radius:10px;
  font-size:14px; background:#fff; color:var(--ink);
}
.field input:focus{ border-color:var(--blue); }
.btn-primary{
  width:100%; border:0; background:var(--blue); color:#fff; padding:11px 16px;
  border-radius:var(--radius-pill); font-weight:650; font-size:14.5px; cursor:pointer;
  transition:background 160ms var(--ease);
}
.btn-primary:hover{ background:var(--blue-ink); }
.login-foot{ margin-top:16px; text-align:center; font-size:12.5px; color:var(--muted); }

.lang-switch{
  display:inline-flex; border:1px solid var(--line); border-radius:var(--radius-pill);
  padding:2px; background:var(--surface); gap:2px;
}
.lang-btn{
  border:0; background:transparent; padding:5px 11px; border-radius:var(--radius-pill);
  font-size:12px; font-weight:650; color:var(--muted); cursor:pointer; letter-spacing:.02em;
  text-decoration:none; display:inline-block;
}
.lang-btn.is-active{ background:var(--blue); color:#fff; }

/* ================= APP SHELL ================= */
.app-shell{ display:flex; flex-direction:column; min-height:100vh; }
.app-header{
  display:flex; align-items:center; gap:14px; padding:12px 22px;
  background:var(--surface); border-bottom:1px solid var(--line);
}
.app-logo{ width:34px; height:34px; flex:none; }
.app-brand{ font-weight:700; font-size:15px; letter-spacing:.01em; }
.app-client{
  font-size:12.5px; color:var(--muted); border-left:1px solid var(--line);
  padding-left:12px; margin-left:2px;
}
.app-header-spacer{ flex:1; }
.app-header .lang-switch{ margin-right:6px; }
.icon-btn{
  border:1px solid var(--line); background:#fff; border-radius:var(--radius-pill);
  padding:7px 14px; font-size:12.5px; color:var(--ink); cursor:pointer; font-weight:600;
  text-decoration:none; display:inline-block;
}
.icon-btn:hover{ border-color:var(--blue); background:var(--pale-blue); }

.app-body{ display:flex; flex:1; }
.app-nav{
  width:190px; flex:none; background:var(--surface); border-right:1px solid var(--line);
  padding:18px 12px;
}
.nav-item{
  display:flex; align-items:center; gap:9px; width:100%; text-align:left;
  border:0; background:transparent; padding:10px 12px; border-radius:12px;
  font-size:13.5px; font-weight:600; color:var(--muted); cursor:pointer; margin-bottom:4px;
  text-decoration:none;
}
.nav-item .dot{ width:7px; height:7px; border-radius:50%; background:var(--pale-blue); flex:none; }
.nav-item.is-active{ background:var(--pale-blue); color:var(--blue-ink); }
.nav-item.is-active .dot{ background:var(--blue); }
.nav-item:hover{ background:var(--paper); }

.app-main{ flex:1; padding:24px 26px 60px; max-width:980px; }

.view-head{ display:flex; align-items:flex-end; justify-content:space-between; gap:12px; margin-bottom:16px; flex-wrap:wrap; }
.view-title{ font-size:19px; font-weight:750; margin:0 0 3px; }
.view-sub{ margin:0; color:var(--muted); font-size:13px; }
.empty-state{ color:var(--muted); font-size:13.5px; padding:20px 0; }
.back-link{ display:inline-block; font-size:12.5px; color:var(--muted); text-decoration:none; margin-bottom:14px; }
.back-link:hover{ color:var(--blue); }

/* ---------- click-to-edit name (admin: client name, own name) ---------- */
/* :not([hidden]) matters here, not just style: an element hidden via the
   [hidden] attribute (as JS does below) only actually disappears if no
   author rule also sets its `display` — a plain `.name-display{display:flex}`
   has the same specificity as the browser's built-in `[hidden]{display:none}`
   and wins the tie (author origin beats user-agent origin), so the element
   stayed visible even while "hidden". Scoping display to :not([hidden]) below
   keeps the flex layout ONLY while visible and lets hidden take effect. */
.name-display:not([hidden]){ display:flex; align-items:center; gap:8px; margin-bottom:3px; }
.name-display .view-title{ margin:0; }
.edit-name-btn{
  border:1px solid transparent; background:transparent; color:var(--muted); font-size:13px;
  cursor:pointer; width:26px; height:26px; border-radius:8px; flex:none; padding:0;
  display:flex; align-items:center; justify-content:center;
}
.edit-name-btn:hover{ background:var(--pale-blue); border-color:var(--pale-blue); color:var(--blue-ink); }
.name-edit-form:not([hidden]){ display:flex; gap:8px; align-items:center; margin-bottom:3px; }
.name-edit-form .view-title-input{
  font-size:19px; font-weight:750; padding:5px 10px; border:1px solid var(--blue);
  border-radius:8px; max-width:260px; color:var(--ink); background:#fff;
}

/* ---------- upload dropzone ---------- */
.dropzone{
  border:1.5px dashed var(--pale-blue); border-radius:16px; background:#fbfcff;
  padding:18px 20px; display:flex; align-items:center; gap:14px; margin-bottom:22px;
}
.dropzone-icon{
  width:38px; height:38px; border-radius:11px; background:var(--pale-blue); color:var(--blue-ink);
  display:flex; align-items:center; justify-content:center; flex:none; font-size:18px;
}
.dropzone-text{ flex:1; }
.dropzone-text b{ font-size:13.5px; }
.dropzone-text span{ display:block; font-size:12px; color:var(--muted); margin-top:2px; }
.btn-secondary{
  border:1px solid var(--line); background:#fff; color:var(--ink); padding:8px 14px;
  border-radius:var(--radius-pill); font-size:12.5px; font-weight:650; cursor:pointer; flex:none;
}
.btn-secondary:hover{ border-color:var(--blue); background:var(--pale-blue); }

/* ---------- file rows ---------- */
.file-list{ display:flex; flex-direction:column; gap:8px; }
.file-row{
  /* v1.8: 7 auto/1fr tracks — admin's row only ever fills 6 (icon, main,
     status, date, view-slot/btn, delete-form), the client's row fills all 7
     (same plus its own separate comments-count badge). An unused trailing
     track just collapses to 0 width, so one shared column count is safe for
     both row shapes. */
  display:grid; grid-template-columns:auto 1fr auto auto auto auto auto; align-items:center; gap:14px;
  background:var(--surface); border:1px solid var(--line); border-radius:14px; padding:12px 14px;
  text-align:left; width:100%;
}
/* The row itself is a <div> (so a delete <form>/<button> can sit beside the
   clickable area without nesting interactive elements inside an <a>).
   display:contents makes the inner <a>'s children act as direct grid items
   of .file-row, so the visual layout is unchanged from when .file-row was
   the anchor itself. */
.file-row-link{ display:contents; text-decoration:none; color:inherit; }
.file-row:hover{ border-color:var(--blue); box-shadow:0 8px 20px rgba(21,87,255,.08); }
.file-delete-form{ margin:0; }
.file-delete-btn{
  border:1px solid transparent; background:transparent; color:var(--muted);
  width:30px; height:30px; border-radius:9px; font-size:14px; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
}
.file-delete-btn:hover{ background:var(--danger-bg); border-color:#F3C9C9; color:var(--danger); }
/* v1.7: "Смотреть" — only ever rendered for .json rows (see admin/client.php);
   other rows get an empty .file-view-slot in the same grid position so the
   delete button stays aligned down the list either way. */
.file-view-slot{ display:block; }
.file-view-btn{
  border:1px solid var(--pale-blue); background:#FAFBFF; color:var(--blue-ink);
  padding:6px 12px; border-radius:var(--radius-pill); font-size:11.5px; font-weight:650;
  cursor:pointer; white-space:nowrap; display:flex; align-items:center; gap:5px;
}
.file-view-btn:hover{ background:var(--pale-blue); }
.btn-danger{
  border:1px solid #F3C9C9; background:#fff; color:var(--danger); padding:8px 14px;
  border-radius:var(--radius-pill); font-size:12.5px; font-weight:650; cursor:pointer;
}
.btn-danger:hover{ background:var(--danger-bg); }
.file-icon{
  width:34px; height:34px; border-radius:9px; background:var(--paper); color:var(--muted);
  display:flex; align-items:center; justify-content:center; font-size:12px; font-weight:700; flex:none;
}
.file-icon.ext-ai,.file-icon.ext-eps,.file-icon.ext-cdr{ background:#FFE9D9; color:#B5540A; }
.file-icon.ext-pdf{ background:#FBE1E1; color:#B23A3A; }
.file-icon.ext-doc,.file-icon.ext-docx,.file-icon.ext-xls,.file-icon.ext-xlsx,.file-icon.ext-ppt,.file-icon.ext-pptx,.file-icon.ext-odt,.file-icon.ext-txt{ background:#DCE6FF; color:var(--blue-ink); }
.file-icon.ext-jpg,.file-icon.ext-jpeg,.file-icon.ext-png,.file-icon.ext-gif,.file-icon.ext-webp,.file-icon.ext-svg{ background:#E3F1FB; color:#1D77A6; }
.file-icon.ext-json,.file-icon.ext-lottie{ background:#DCFCE4; color:#1E9E63; }
.file-icon.ext-web{ background:#FFF3CE; color:#8A6A00; } /* v1.13: website previews */
.file-main{ min-width:0; }
/* v1.7: was white-space:nowrap + ellipsis — a long filename stretched the
   row or got silently cut off instead of just wrapping. Now wraps within
   the column instead of overflowing or truncating. */
.file-name{ font-size:13.5px; font-weight:650; white-space:normal; overflow-wrap:anywhere; word-break:break-word; line-height:1.3; }
.file-meta{ font-size:11.5px; color:var(--muted); margin-top:2px; display:flex; gap:8px; align-items:center; }
.dir-badge{
  font-size:10.5px; font-weight:700; padding:1.5px 7px; border-radius:var(--radius-pill);
  text-transform:uppercase; letter-spacing:.03em;
}
.dir-badge.to{ background:var(--pale-blue); color:var(--blue-ink); }
.dir-badge.from{ background:#EFE6FB; color:#6B3FB0; }
.status-badge{
  font-size:11.5px; font-weight:700; padding:4px 11px; border-radius:var(--radius-pill);
  white-space:nowrap; border:0;
}
.status-received{ background:var(--rcv-bg); color:var(--rcv); }
.status-in_progress{ background:var(--warn-bg); color:var(--warn); }
.status-delivered{ background:var(--ok-bg); color:var(--ok); }
.status-select{
  font-size:11.5px; font-weight:700; padding:4px 9px; border-radius:var(--radius-pill);
  border:1px solid transparent; cursor:pointer;
}
.status-select.status-received{ background:var(--rcv-bg); color:var(--rcv); }
.status-select.status-in_progress{ background:var(--warn-bg); color:var(--warn); }
.status-select.status-delivered{ background:var(--ok-bg); color:var(--ok); }
.status-inactive{ background:#EEF0F5; color:var(--muted); }
.status-active{ background:var(--ok-bg); color:var(--ok); }
.file-comments-count{ font-size:12px; color:var(--muted); display:flex; align-items:center; gap:4px; white-space:nowrap; }
.file-date{ font-size:11.5px; color:var(--muted); white-space:nowrap; }

/* ================= FILE DETAIL PANEL ================= */
.panel-page{ max-width:640px; margin:0 auto; }
.panel-top{
  display:flex; align-items:flex-start; justify-content:space-between; gap:10px;
  margin-bottom:16px;
}
.panel-top h1{ margin:0 0 4px; font-size:18px; }
.panel-actions{ display:flex; gap:8px; align-items:center; margin:2px 0 20px; flex-wrap:wrap; }

.comment{ display:flex; gap:10px; margin-bottom:16px; }
.comment-avatar{
  width:30px; height:30px; border-radius:50%; flex:none; display:flex; align-items:center;
  justify-content:center; font-size:11.5px; font-weight:700; color:#fff;
}
.comment.studio .comment-avatar{ background:var(--blue); }
.comment.client .comment-avatar{ background:#6B3FB0; }
.comment-body{ flex:1; }
.comment-head{ display:flex; align-items:baseline; gap:8px; margin-bottom:2px; flex-wrap:wrap; }
.comment-author{ font-size:12.5px; font-weight:700; }
.comment-time{ font-size:11px; color:var(--muted); }
.comment-text{
  display:block; font-size:13.5px; line-height:1.5; background:var(--paper); border-radius:12px;
  padding:9px 12px; white-space:pre-wrap; word-break:break-word;
}
.comment.studio .comment-text{ background:var(--pale-blue); }

.comment-form{ display:flex; gap:8px; margin-top:6px; }
.comment-form input{
  flex:1; border:1px solid var(--line); border-radius:var(--radius-pill); padding:10px 14px; font-size:13px;
}
.comment-form button{
  border:0; background:var(--blue); color:#fff; border-radius:var(--radius-pill);
  padding:0 16px; font-weight:650; font-size:13px; cursor:pointer;
}
.comment-form button:hover{ background:var(--blue-ink); }

/* ---------- v1.15: comment edit/delete (own comments only) ---------- */
.comment.is-deleted .comment-avatar{ opacity:.5; }
/* .comment-text already sets display:block unscoped above — an [hidden]
   override needs higher specificity to actually win (same lesson as
   .name-display/.info-display elsewhere in this file: an author rule always
   beats the UA [hidden]{display:none} default at equal specificity). */
.comment-text[hidden]{ display:none; }
.comment-text-deleted{ color:var(--muted); font-style:italic; }
.comment-edited-mark{ font-size:10.5px; color:var(--muted); font-style:italic; }
.comment-actions{ display:flex; gap:2px; margin-left:auto; }
.comment-action-btn{
  border:1px solid transparent; background:transparent; color:var(--muted); font-size:12px;
  cursor:pointer; width:24px; height:24px; border-radius:8px; flex:none; padding:0;
  display:flex; align-items:center; justify-content:center;
}
.comment-action-btn:hover{ background:var(--pale-blue); border-color:var(--pale-blue); color:var(--blue-ink); }
.comment-delete-form{ margin:0; display:contents; }
.comment-edit-form:not([hidden]){ display:flex; flex-direction:column; gap:8px; margin-top:2px; }
.comment-edit-form textarea{
  border:1px solid var(--line); border-radius:12px; padding:9px 12px; font-size:13.5px;
  font-family:inherit; resize:vertical; min-height:60px; width:100%;
}
.comment-edit-form textarea:focus{ border-color:var(--blue); }
.comment-edit-actions{ display:flex; gap:8px; }

/* ---------- v1.15: file categories (fixed list, admin-assigned only) ---------- */
.cat-filter{ display:flex; gap:6px; flex-wrap:wrap; margin-bottom:14px; }
.cat-filter-btn{
  border:1px solid var(--line); background:#fff; color:var(--muted); padding:6px 12px;
  border-radius:var(--radius-pill); font-size:11.5px; font-weight:650; cursor:pointer;
}
.cat-filter-btn.is-active{ background:var(--ink); color:#fff; border-color:var(--ink); }
.cat-badge{
  background:#E1F5F3; color:#137A6C; border-radius:var(--radius-pill);
  padding:2px 8px; font-size:10.5px; font-weight:700; white-space:nowrap;
}
.cat-select-form{ margin:0; }
.cat-select{
  font-size:11px; font-weight:650; padding:4px 8px; border-radius:var(--radius-pill);
  border:1px solid var(--line); background:#fff; color:var(--ink); cursor:pointer; max-width:150px;
}
.cat-select:hover{ border-color:var(--blue); }
.comment-log-title{ font-size:13px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); margin:26px 0 10px; font-weight:700; }
.comment-log-row .file-icon{ background:var(--pale-blue); color:var(--blue-ink); }
.comment-log-body{ display:block; margin-top:2px; font-style:italic; overflow-wrap:anywhere; }

/* ================= CHAT ================= */
.chat-frame{
  background:var(--surface); border:1px solid var(--line); border-radius:18px;
  display:flex; flex-direction:column; height:64vh; overflow:hidden;
}
.chat-log{ flex:1; overflow-y:auto; padding:20px 22px; display:flex; flex-direction:column; gap:14px; }
.chat-bubble-row{ display:flex; }
.chat-bubble-row.mine{ justify-content:flex-end; }
.chat-bubble{
  max-width:70%; padding:10px 14px; border-radius:16px; font-size:13.5px; line-height:1.5;
  background:var(--paper); white-space:pre-wrap; word-break:break-word;
}
.chat-bubble-row.mine .chat-bubble{ background:var(--blue); color:#fff; border-bottom-right-radius:4px; }
.chat-bubble-row:not(.mine) .chat-bubble{ border-bottom-left-radius:4px; }
.chat-time{ display:block; font-size:10.5px; margin-top:5px; opacity:.65; }
.chat-input-row{ display:flex; gap:10px; padding:14px 18px; border-top:1px solid var(--line); }
.chat-input-row input{
  flex:1; border:1px solid var(--line); border-radius:var(--radius-pill); padding:11px 16px; font-size:13.5px;
}
.chat-input-row button{
  border:0; background:var(--blue); color:#fff; border-radius:var(--radius-pill);
  padding:0 20px; font-weight:650; font-size:13.5px; cursor:pointer;
}
.chat-input-row button:hover{ background:var(--blue-ink); }

/* ---------- admin: client list ---------- */
.client-row{
  display:grid; grid-template-columns:auto 1fr auto auto; align-items:center; gap:14px;
  background:var(--surface); border:1px solid var(--line); border-radius:14px; padding:14px 16px;
  text-align:left; width:100%; margin-bottom:8px; text-decoration:none; color:inherit;
}
.client-row:hover{ border-color:var(--blue); box-shadow:0 8px 20px rgba(21,87,255,.08); }
.client-avatar{
  width:38px; height:38px; border-radius:50%; background:var(--pale-blue); color:var(--blue-ink);
  display:flex; align-items:center; justify-content:center; font-size:13px; font-weight:700; flex:none;
}
.client-name{ display:block; font-size:14px; font-weight:650; }
.client-email{ display:block; font-size:12px; color:var(--muted); margin-top:2px; }
.client-files-count{ font-size:12px; color:var(--muted); white-space:nowrap; }

/* ---------- add-client / generic modal-ish card ---------- */
.card{
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius-lg);
  padding:24px; max-width:440px;
}
.card h1{ margin:0 0 18px; font-size:17px; }
.inline-fields{ display:flex; gap:8px; }
.inline-fields input{ flex:1; }

.pill-tabs{
  display:inline-flex; border:1px solid var(--line); border-radius:var(--radius-pill);
  padding:2px; background:var(--surface); gap:2px; margin-bottom:18px;
}
.pill-tab{
  border:0; background:transparent; padding:6px 14px; border-radius:var(--radius-pill);
  font-size:12.5px; font-weight:650; color:var(--muted); cursor:pointer; text-decoration:none;
}
.pill-tab.is-active{ background:var(--ink); color:#fff; }

/* ---------- admin: per-client log tab ---------- */
.log-row.is-deleted{ opacity:.7; }
.log-row.is-deleted .file-icon{ background:var(--danger-bg); color:var(--danger); }
.log-deleted-badge{
  font-size:11px; font-weight:650; color:var(--danger); background:var(--danger-bg);
  padding:4px 10px; border-radius:var(--radius-pill); white-space:nowrap;
}

/* ---------- v1.7: admin — optional client info card ---------- */
.info-card-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:2px; }
.info-grid:not([hidden]){ display:grid; grid-template-columns:repeat(3,1fr); gap:16px; }
.info-item{ min-width:0; }
.info-label{ font-size:11px; color:var(--muted); text-transform:uppercase; letter-spacing:.03em; margin-bottom:3px; }
.info-value{ font-size:14px; font-weight:600; }
.info-value.is-empty{ color:var(--muted); font-weight:500; font-style:italic; }
.info-edit-form:not([hidden]){ display:grid; grid-template-columns:repeat(3,1fr); gap:14px; margin-top:2px; }
.info-edit-form .field{ grid-column:span 1; margin-bottom:0; }
.info-edit-form label{ display:block; font-size:11px; color:var(--muted); margin-bottom:5px; font-weight:650; text-transform:uppercase; letter-spacing:.03em; }
.info-edit-form input{ width:100%; padding:9px 11px; border:1px solid var(--line); border-radius:10px; font-size:13.5px; }
.info-edit-form input:focus{ border-color:var(--blue); }
.info-edit-actions{ grid-column:1 / -1; display:flex; gap:8px; margin-top:4px; }

/* ---------- v1.7: confirm-by-typing-name modal (delete client) ---------- */
.modal-overlay{ position:fixed; inset:0; background:rgba(17,22,34,.5); display:none; align-items:center; justify-content:center; z-index:100; padding:20px; }
.modal-overlay:not([hidden]){ display:flex; }
.modal-card{ background:var(--surface); border-radius:var(--radius-lg); max-width:460px; width:100%; padding:24px 26px; box-shadow:0 30px 60px rgba(15,20,40,.25); }
.modal-card h2{ margin:0 0 10px; font-size:16px; }
.modal-card p{ font-size:13px; color:var(--muted); line-height:1.5; margin:0 0 14px; }
.modal-danger-box{ background:var(--danger-bg); border:1px solid #F3C9C9; color:var(--danger); border-radius:10px; padding:10px 12px; font-size:12.5px; margin-bottom:16px; }
.modal-confirm-input{ width:100%; padding:9px 11px; border:1px solid var(--line); border-radius:10px; font-size:13.5px; margin-bottom:16px; }
.modal-confirm-input:focus{ border-color:var(--danger); }
.modal-actions{ display:flex; gap:8px; justify-content:flex-end; }
.btn-danger.solid{ background:var(--danger); color:#fff; border-color:var(--danger); }
.btn-danger.solid:hover{ background:#A52D2D; }
.btn-danger.solid:disabled{ opacity:.45; cursor:not-allowed; }

/* ---------- v1.7: in-portal Lottie/JSON animation viewer ---------- */
.viewer-overlay{ position:fixed; inset:0; background:rgba(17,22,34,.6); display:none; align-items:center; justify-content:center; z-index:100; padding:18px; }
.viewer-overlay:not([hidden]){ display:flex; }
.viewer-card{ background:var(--surface); border-radius:var(--radius-lg); width:100%; max-width:920px; max-height:92vh; overflow:auto; box-shadow:0 30px 70px rgba(15,20,40,.3); }
.viewer-head{ display:flex; align-items:center; justify-content:space-between; padding:16px 22px; border-bottom:1px solid var(--line); }
.viewer-head h2{ margin:0; font-size:15px; }
.viewer-close{ border:0; background:transparent; font-size:18px; cursor:pointer; color:var(--muted); width:30px; height:30px; border-radius:8px; }
.viewer-close:hover{ background:var(--paper); color:var(--ink); }
.viewer-body{ padding:22px; display:grid; grid-template-columns:1fr 280px; gap:24px; align-items:start; }
.source-tabs{ display:inline-flex; border:1px solid var(--line); border-radius:var(--radius-pill); padding:2px; margin-bottom:16px; }
.source-tab{ border:0; background:transparent; padding:6px 13px; border-radius:var(--radius-pill); font-size:12px; font-weight:650; color:var(--muted); cursor:pointer; }
.source-tab.is-active{ background:var(--blue); color:#fff; }
.stage-wrap{ display:flex; flex-direction:column; align-items:center; }
.aspect-switch{ display:flex; gap:6px; margin-bottom:14px; flex-wrap:wrap; justify-content:center; }
.aspect-btn{ border:1px solid var(--line); background:#fff; padding:6px 12px; border-radius:var(--radius-pill); font-size:11.5px; font-weight:650; color:var(--muted); cursor:pointer; }
.aspect-btn.is-active{ background:var(--ink); color:#fff; border-color:var(--ink); }
.stage-frame{ width:100%; max-width:300px; background:#0E1626; border-radius:22px; padding:10px; box-shadow:0 20px 40px rgba(21,36,80,.16); transition:aspect-ratio .25s var(--ease); }
.stage-frame[data-ratio="1:1"]{ aspect-ratio:1/1; }
.stage-frame[data-ratio="2:3"]{ aspect-ratio:2/3; }
.stage-frame[data-ratio="9:16"]{ aspect-ratio:9/16; }
.stage-frame[data-ratio="16:9"]{ aspect-ratio:16/9; }
.stage-inner{ width:100%; height:100%; border-radius:14px; overflow:hidden; position:relative; display:flex; align-items:center; justify-content:center; }
.stage-inner.is-checker{ background-image:conic-gradient(#dcdcdc 90deg,#f2f2f2 90deg 180deg,#dcdcdc 180deg 270deg,#f2f2f2 270deg); background-size:22px 22px; }
.viewer-anim{ width:82%; height:82%; }
.drop-hint{ position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:6px; color:rgba(20,30,60,.35); font-size:11.5px; pointer-events:none; text-align:center; padding:0 16px; }
.file-size-info{ margin-top:10px; font-size:11px; color:var(--muted); font-family:"SFMono-Regular",Consolas,monospace; word-break:break-all; text-align:center; }
.viewer-panel{ display:flex; flex-direction:column; gap:20px; }
.viewer-section h3{ font-size:11px; text-transform:uppercase; letter-spacing:.03em; color:var(--muted); margin:0 0 9px; font-weight:700; }
.viewer-upload-btn{ display:flex; align-items:center; justify-content:center; gap:8px; width:100%; padding:10px 14px; border:1px solid var(--pale-blue); background:#FAFBFF; color:var(--blue-ink); border-radius:10px; font-size:12.5px; font-weight:650; cursor:pointer; }
.viewer-upload-btn:hover{ background:var(--pale-blue); }
.portal-file-list{ display:flex; flex-direction:column; gap:6px; max-height:170px; overflow-y:auto; }
.portal-file-item{ display:flex; align-items:center; gap:8px; padding:7px 9px; border:1px solid var(--line); border-radius:9px; font-size:12px; cursor:pointer; text-align:left; background:#fff; width:100%; }
.portal-file-item:hover{ border-color:var(--blue); background:var(--pale-blue); }
.portal-file-item .file-icon{ width:24px; height:24px; font-size:9px; flex:none; }
.portal-file-item span.pf-name{ flex:1; min-width:0; overflow-wrap:anywhere; }
.portal-file-item span.pf-client{ color:var(--muted); font-size:10.5px; white-space:nowrap; }
.swatches{ display:flex; flex-wrap:wrap; gap:8px; }
.swatch{ width:28px; height:28px; border-radius:8px; border:1px solid rgba(0,0,0,.18); cursor:pointer; padding:0; }
.swatch.is-selected{ box-shadow:0 0 0 2px var(--blue); border-color:var(--blue); }
.swatch.is-checker{ background-image:conic-gradient(#dcdcdc 90deg,#f2f2f2 90deg 180deg,#dcdcdc 180deg 270deg,#f2f2f2 270deg); background-size:9px 9px; }
.viewer-controls{ display:flex; flex-direction:column; gap:6px; }
.viewer-controls button{ display:flex; align-items:center; gap:9px; padding:9px 12px; font-size:12.5px; color:var(--ink); background:#fff; border:1px solid var(--line); border-radius:9px; cursor:pointer; text-align:left; width:100%; }
.viewer-controls button:hover{ background:var(--paper); border-color:var(--blue); }
@media (max-width:760px){ .viewer-body{ grid-template-columns:1fr; } }

/* ---------- v1.12: in-portal video player ----------
   Reuses .viewer-overlay/.viewer-card/.viewer-head/.viewer-close from the
   animation viewer above so the window chrome matches — this body is its
   own simple block instead of .viewer-body's two-column grid, since a video
   only needs the <video controls> element, not a side control panel. */
.video-viewer-body{ padding:22px; }
.video-viewer-player{ width:100%; max-height:70vh; background:#0E1626; border-radius:14px; display:block; }
.video-viewer-status{ margin:10px 0 0; font-size:11.5px; color:var(--muted); word-break:break-all; }

/* ================= FOOTER ================= */
.portal-footer{
  margin-top:auto; background:#1B2433; color:#AEB8CC;
  padding:16px 20px; text-align:center; font-size:12px; letter-spacing:.02em;
}

@media (max-width:720px){
  .app-body{ flex-direction:column; }
  .app-nav{ width:100%; display:flex; gap:8px; padding:10px 14px; border-right:0; border-bottom:1px solid var(--line); overflow-x:auto; }
  .nav-item{ margin-bottom:0; white-space:nowrap; }
  .file-row{ grid-template-columns:auto 1fr auto; row-gap:8px; }
  .file-row .status-badge,.file-row .status-select,.file-row .file-comments-count,.file-row .file-date{ grid-column:2; justify-self:start; }
  .file-row .file-view-slot,.file-row .file-view-btn{ grid-column:2; justify-self:start; margin-top:4px; }
  .file-row .cat-select-form{ grid-column:2; justify-self:start; margin-top:4px; }
  .file-row .file-delete-form{ grid-column:3; grid-row:1; justify-self:end; }
  .file-row .log-deleted-badge{ grid-column:2; justify-self:start; }
  .client-row{ grid-template-columns:auto 1fr; row-gap:8px; }
  .client-row .status-badge,.client-row .client-files-count{ grid-column:2; justify-self:start; }
  .info-grid:not([hidden]),.info-edit-form:not([hidden]){ grid-template-columns:1fr; }
  .viewer-body{ grid-template-columns:1fr; }
  .app-main{ padding:18px 14px 50px; }
  .app-header{ flex-wrap:wrap; row-gap:10px; }
  .app-header-spacer{ flex-basis:100%; height:0; }
}
