/* ---------- Base / Theme ---------- */
:root{
  /* Palette */
  --bg: #0f1115;
  --bg-2:#1a1d23;
  --text:#f5f7fa;
  --muted:#aab4c5;
  --border:#262b35;
  --brand:#007bff;
  --brand-2:#0095ff;
  --btn-primary:#007bff;
  --btn-primary-hover:#0095ff;
  --success:#27ae60;
  --danger:#ff4d4d;
  --warning:#f39c12;

  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.25);
  --container: 1200px;
  --font: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

*{
  box-sizing:border-box
}

html {
  height: 100%;
  background: none;
}

body {
  font-family: var(--font);
  font-size: 20px;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-attachment: fixed;
}

html, body { overflow-x: hidden; }

body.home .app {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 1fr auto;
  gap: 20px;
  margin-top: 40px;
  align-items: stretch;
}

body.gallery .app {
  display: block;
}


main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Utilities */
.muted{color:var(--muted); font-size:.95rem}
.label{display:block; margin-bottom:8px; font-weight:600; font-size: 1.05rem}; 
.sr-only{position:absolute !important; height:1px; width:1px; overflow:hidden; clip:rect(1px,1px,1px,1px)}

/* ---------- Header / Nav ---------- */
.site-header{
  position:sticky; top:0; z-index:50;
  background:linear-gradient(180deg, rgba(17,17,17,.85), rgba(17,17,17,.6));
  backdrop-filter: blur(10px);
  border-bottom:1px solid var(--border);
}
.header-inner{
  height:64px; display:flex; align-items:center; gap:16px;
}
.brand{display:flex; align-items:center; gap:10px; text-decoration:none; color:var(--text)}
.brand-mark{width:42px; height:42px; border-radius:6px}
.brand-name{font-weight:900; letter-spacing:.3px; align-items: left;}

.primary-nav{margin-left:auto; display:flex; gap:12px;}
.nav-link{
  padding:10px 12px; border-radius:12px; text-decoration:none; color:var(--text);
  border:1px solid transparent;
}
.nav-link:hover{border-color:var(--border); background:#0f1420}

.nav-tools{display:flex; align-items:center; gap:12px}
.nav-burger{display:none; background:transparent; border:0; width:40px; height:40px; border-radius:10px}
.nav-burger span{display:block; height:2px; background:var(--text); margin:6px 8px}

/* Language Selector */
#lang-select {
  background: #222;
  color: #ffffff;
  font-weight: 600;
  font-size: 1rem;
  padding: 8px 12px;
  border-radius: 12px;
  border: 2px solid var(--brand);
  box-shadow: 0 2px 8px #0006;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px 7px;
  min-width: 150px;
}
#lang-select:hover, #lang-select:focus {
  background: #1a1a1a;
  border-color: var(--brand);
  border: 2px solid var(--brand) !important;
  box-shadow: 0 0 10px #00eaff88;
  outline: none;
}

/* ---------- Global Toast ---------- */
/* Global Toast */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 2000;
}
.toast.success { background: #27ae60; }
.toast.error   { background: #ff4d4d; }
.toast.info    { background: #2d89ef; }


/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.55);
  z-index: 1300;
}
.modal[hidden] { display: none !important; }

.modal-content {
  background: var(--card-bg, #1e1e1e);
  color: var(--text, #fff);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
  text-align: center;
  max-width: 400px;
}

.modal .modal-content {
  background: #14161a;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 16px;
  width: min(520px, 92vw);
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
}

/* ---------- Page Layout ---------- */
.app{
  display:grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 1fr auto;
  gap:20px;
  margin-top: 40px;
  align-items:stretch;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: linear-gradient(160deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-colors {
  grid-column: 1 / -1;
  grid-row: 3;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: stretch;
}

.panel-colors .card {
  display: flex;              /* switch from grid to flex */
  flex-direction: column;     /* stack elements vertically */
  gap: 12px;
  height: 100%;
}

.panel-colors .card .section-title {
  margin: 0;
  font-size: 1.1rem;
  width: 100%;
}

.panel-colors .card .btn-eye {
  align-self: flex-start; /* keep small icon aligned to left */
}

.panel-colors .card .btn {
  width: 100%;             /* button spans full width */
  align-self: flex-start;  /* align left */
}


.panel-left,
.panel-right {
  display: flex;
  flex-direction: column;
  align-self: stretch;
  gap: 20px;
}

.panel-left .card:nth-child(2) {
  flex: 1;
  display: flex;
  flex-direction: column;
}


.panel-right .canvas-wrap {
  flex: 1;
}

.panel-colors .span-2 { grid-column: 1 / -1; }

/* Titles */
h2#title, h2 {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 2px;
  margin: 0 0 10px 0;
  color: var(--brand);
}


.page-title { grid-column: 1 / -1; margin: 0 0 10px 0; }


/* ---------- Inputs / Controls ---------- */
/* Hide native file input */
.custom-upload input[type="file"] {
  position: absolute;
  left: -9999px;
}

/* Upload container */
.upload-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 30px 20px;
  border: 2px dashed var(--brand);
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(0, 149, 255, 0.1), rgba(0, 149, 255, 0.1));
  color: var(--text);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.upload-box:hover,
.custom-upload.dragover .upload-box {
  background: linear-gradient(
    160deg,
    rgba(0, 149, 255, 0.12),
    rgba(0, 149, 255, 0.20)
  );
  box-shadow: 0 0 12px rgba(0, 149, 255, 0.4);
  transform: scale(1.02);
}

/* Icon */
.upload-icon {
  font-size: 2.5rem;
}

/* Text */
.upload-text strong {
  font-size: 1.1rem;
}
.upload-text span {
  font-size: 0.9rem;
  color: var(--muted);
}

/* sliders */
.scroll-bar { display:flex; justify-content:center; align-items:center; flex-wrap:wrap; gap:12px; margin: 10px 0; }
#scaleRange, #zoomRange {
  width: 250px; max-width: 100%;
  accent-color: var(--brand);
  background: #222;
  border-radius: 8px;
  height: 8px;
}
#scaleValue, #zoomValue {
  font-size: 1.05rem;
  font-weight: bold;
  color: var(--brand);
}
.zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px; /* space between slider and value */
}

/* dimensions (keeps your original look) */
.dimensions { display:flex; gap: 1.5rem; justify-content: center; }
.dimension-input { display:flex; flex-direction:column; align-items:center; }
.dimension-input label { font-size:1.05rem; margin-bottom:.3rem; color:#fff; }
.dimension-input input[type="number"],
.dimension-input .area-box {
  width: 100px; height: 30px; padding: 0 .75em;
  background: var(--bg);
  color: #fff; border: 2px solid var(--brand); border-radius: 7px;
  font-size: 1.05rem; font-weight: bold; text-align: center;
  transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
  appearance: none; -moz-appearance: textfield; box-sizing: border-box;
}
.dimension-input input[type="number"]::-webkit-inner-spin-button,
.dimension-input input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.dimension-input input[type="number"]:hover,
.dimension-input .area-box:hover {
  transform: scale(1.05);
}

/* ---------- Buttons / Chips ---------- */
.button, .btn {
  margin: 10px 10px;
  padding: 12px 22px;
  height: 44px;
  background: #007bff;
  color: #fff;
  border-radius: 12px;
  font-size: 1rem;
  border: none;
  box-shadow: 0 2px 8px #0006;
  font-weight: bold;
  letter-spacing: .5px;
  transition: background 0.2s, transform 0.2s, box-shadow .2s;
  text-decoration: none;
  display: inline-flex; align-items:center; justify-content:center; gap:8px;
}
.button:hover, .btn:hover { cursor: pointer; transform: scale(1.05); background:#0095ff; }
.btn-chip {
  width: 260px; /* pick a value that fits both texts */
  text-align: center;
  font-size: 1.05rem;
  height: 44px;
}
.btn-toggle.active, .toggle-color.active{ border: 2px solid #00eaff; box-shadow: 0 0px 12px #0095ff;}


/* color chips container */
.chips{
  display:flex; flex-wrap:wrap; gap:8px;
  border-radius: 18px;
  padding: 12px;
}

/* individual color chip buttons (keep your original) */
.toggle-color{
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: .8rem;
  font-weight: 600;
  border: 2px solid #ccc;
  box-shadow: none;
  transition: transform .12s, box-shadow .2s, border-color .2s;
  text-align: center;
}

/* secondary buttons so Download/Copy stay primary */
.btn-secondary{
  background:#0f1420; color:#e8eef8; border:1px solid var(--border);
  padding:10px 14px; border-radius:10px; font-weight:600;
  font-family: var(--font)!important;
}
.btn-secondary:hover{ transform:translateY(-1px) }


.toggle-color:hover{ transform: translateY(-1px); }
.toggle-color.active{ border-color: #9333ea; }

/* Eye button inside each color chip */
.toggle-color { position: relative; }
.toggle-color .hide-eye {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px;
  border: 0; border-radius: 6px;
  background: none; cursor: pointer; padding: 0;
  display: grid; place-items: center;
  opacity: .85;
  color: #111;
}
.toggle-color .hide-eye:hover { opacity: 1; }

.toggle-color[style*="color: #fff"] .hide-eye { color: #fff; }

/* SVG icons via mask (no extra files) */
/* eye on */
.hide-eye::before{
  content:"";
  width:16px;height:16px;display:block;background:currentColor;
  -webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5C21.27 7.61 17 4.5 12 4.5zm0 12a4.5 4.5 0 1 1 0-9 4.5 4.5 0 0 1 0 9z'/%3E%3C/svg%3E");
          mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5C21.27 7.61 17 4.5 12 4.5zm0 12a4.5 4.5 0 1 1 0-9 4.5 4.5 0 0 1 0 9z'/%3E%3C/svg%3E");
  -webkit-mask-repeat:no-repeat; mask-repeat:no-repeat;
  -webkit-mask-position:center;  mask-position:center;
  -webkit-mask-size:contain;     mask-size:contain;
}

/* eye with slash (hidden) */
.hide-eye.is-off::before{
  content:"";
  width:16px;height:16px;display:block;background:currentColor;
  -webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2.1 3.51 20.49 21.9l1.41-1.41L3.51 2.1 2.1 3.51zM12 6c4.42 0 8.19 2.55 10 6-1 2.22-2.76 4.07-4.94 5.16l-2.2-2.2A4.5 4.5 0 0 0 9.03 10l-2.1-2.1A12.7 12.7 0 0 1 12 6zm0 12c-4.42 0-8.19-2.55-10-6 .83-1.84 2.23-3.42 3.98-4.56l2.16 2.16A4.5 4.5 0 0 0 14.4 14.3l2.36 2.36A12.6 12.6 0 0 1 12 18z'/%3E%3C/svg%3E");
          mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2.1 3.51 20.49 21.9l1.41-1.41L3.51 2.1 2.1 3.51zM12 6c4.42 0 8.19 2.55 10 6-1 2.22-2.76 4.07-4.94 5.16l-2.2-2.2A4.5 4.5 0 0 0 9.03 10l-2.1-2.1A12.7 12.7 0 0 1 12 6zm0 12c-4.42 0-8.19-2.55-10-6 .83-1.84 2.23-3.42 3.98-4.56l2.16 2.16A4.5 4.5 0 0 0 14.4 14.3l2.36 2.36A12.6 12.6 0 0 1 12 18z'/%3E%3C/svg%3E");
  -webkit-mask-repeat:no-repeat; mask-repeat:no-repeat;
  -webkit-mask-position:center;  mask-position:center;
  -webkit-mask-size:contain;     mask-size:contain;
}


/* optional: dim hidden chips */
.toggle-color.color-hidden { filter: grayscale(.6) brightness(.8); }


/* containers (renamed FREE from #colors to #colors-free, keeps #colors-paid) */
#colors-free, #colors-paid{
  grid-column:1 / -1;
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap:15px;
  border-radius:14px;
  padding:12px;

  /* equalize and keep cards neat even with long lists */
  flex:1;
  min-height:260px;
  max-height:360px;
  overflow:auto;
}

/* Color list */
#color-list {
  border-radius: 18px;
  padding: 18px 12px;

  /* Manual column count mode */
  grid-template-columns: var(--color-list-template, repeat(2, minmax(0, 1fr)));
  display: grid;
  gap: 6px 12px;
  align-items: start;
}

/* Dynamic column count mode: responsive up to 4 cols */
#color-list.dynamic {
  /* 
    minmax( max( 20%, 250px ), 1fr )
    - min: the larger [max(..)] of 20% or 250px
    - max: flexible, share remaining space (1fr) 
  */
  grid-template-columns: repeat(auto-fit, minmax(max(20%, 250px), 1fr));
}

#color-list:empty { display: none; }


/* canvas area */
.canvas-wrap{
  overflow: hidden;
}

.canvas-viewport > #canvas { width: 100%; }

.canvas-viewport{
  width: min(92%, 980px);
  height: clamp(240px, 56vh, 340px);
  margin-left: auto;
  margin-right: auto;
  overflow: auto;
  padding: 8px;
  border: 2px dotted rgba(255,255,255,.18);
  border-radius: 12px;
  background: rgba(0,0,0,.12);
  cursor: grab;
}
.canvas-viewport:active { cursor: grabbing; }

/* hide only inside the canvas viewport */
.canvas-viewport::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.canvas-viewport {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.canvas-viewport > #canvas{
  width:auto !important;
  height:auto !important;
  max-width:none !important;
  aspect-ratio:auto !important;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

.actions .btn {
  flex: 0 0 auto;
  text-align: center;
}

/* layout helpers */
.row { display:flex; gap:10px; justify-content:center; align-items:center; }

/* Footer */
.site-footer{border-top:1px solid var(--border); padding:24px 0; margin-top:24px; background: linear-gradient(135deg, var(--bg) 0%, var(--bg-2) 100%);}
.license {
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 0 2px 12px #222, 0 0px 2px var(--brand);
  text-decoration: none
}

/* ---------- Responsive ---------- */
@media (max-width: 980px){
.app { grid-template-columns: 1fr 1fr; align-items: stretch; }
  .primary-nav{ display:none }
  .nav-burger{ display:block }
  body{ font-size: 18px; }
  h2#title, h2 { font-size: 1.8rem; }
  .panel-colors{ grid-template-columns: 1fr; }
}

/* --- Mobile patch --- */
@media (max-width: 820px) {
  /* Container should breathe edge-to-edge on phones */
  .container { width: 100%; padding-inline: 12px; }

  /* The main app becomes a single, orderly column */
  .app{
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  /* Header row */
  .header-inner{ height: 64px; }
  .primary-nav{ display:none; }
  .nav-burger{ display:block; }

  /* Titles a bit smaller on mobile */
  h2#title, h2{ font-size: 1.45rem; letter-spacing: 1px; }

  /* Cards look lighter and tighter */
  .card{ padding: 14px; margin: 0; }

  /* === Controls (left column) === */
  .scroll-bar { gap: 8px; }
  #scaleRange, #zoomRange { width: 100%; }

  .dimensions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    justify-items: stretch;
  }

  .dimension-input input,
  .dimension-input .area-box {
    width: 100%;
    min-width: 80px;
    height: 38px;
    font-size: 1rem;
    text-align: center;
    border: 2px solid #007bff;
    border-radius: 6px;
    padding: 4px 6px;
    box-sizing: border-box;
  }

  /* Buttons are easy to tap */
  .button, .btn{
    width: 100%;
    height: 46px;
    margin: 10px 0 0 0;
    font-size: 1rem;
  }

  /* Advanced options (summary) – wide hit area */
  .adv-card > summary{ padding: 12px; }

  /* === Canvas / actions (right column) === */
  .canvas-wrap { gap: 12px; }
  .canvas-viewport{
    width: 100%;
    height: clamp(260px, 50vh, 62vh);
    padding: 6px;
  }
  .canvas-viewport > #canvas{
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
  }

  /* Action buttons under the canvas */
  .actions .btn + .btn{ margin-left: 0; }

  /* === Colors section (bottom) === */

  .colors-card-head{
  display:flex; align-items:center; justify-content:space-between;
  width:100%;            /* <-- keeps the row spanning the card */
  gap:8px;
}
.colors-card-head .head-left{
  display:flex; align-items:center; gap:8px; min-width:0;
}
.section-title{ margin:0; white-space:nowrap; line-height:1.1; }
#paid-total-cost{ white-space:nowrap; }
.btn-eye{ flex:0 0 auto; }


  .panel-colors{
    grid-template-columns: 1fr;      /* Free / Paid stack */
    gap: 16px;
  }
  #colors-free, #colors-paid{
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
    max-height: 300px;               /* keep list scrollable, not endless */
    padding: 10px;
  }
  .toggle-color{ font-size: .95rem; padding: 10px 12px; }

  /* Footer spacing */
  .site-footer{ margin-top: 16px; }
}

/* Ultra-small phones (≤ 480px) – make color chips pack tighter */
@media (max-width: 480px){
  #colors-free, #colors-paid{
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  }
  .brand-name{ font-size: .95rem; }
}

/* Sticky header spacing: keep content from hiding underneath */
.site-header + .container.app{ margin-top: 14px; }

/* Keep header items usable and brand not squashed on mobile */
@media (max-width: 820px){
  .brand{ display:flex; align-items:center; gap:8px; min-width:0; }
  .brand-name{
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 52vw; font-size: clamp(1rem, 3.6vw, 1.15rem);
  }
  .nav-tools{ margin-left:auto; gap:8px; flex-shrink:0; }
  .nav-burger{ width:40px; height:40px; }
  #lang-select{ min-width:120px; padding:6px 10px; font-size:.95rem; }
}
/*Mobile patch end*/


/* Footer */

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.footer-links {
  display: flex;
  gap: 14px;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 1px;
}

.footer-links .nav-link {
  padding: 6px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
}

.footer-links .nav-link:hover {
  background: #0f1420;
  border: 1px solid var(--border);
}

/* Master eye buttons (hide/show all) */
.btn-eye{
  width:30px; height:30px; margin: 0 10px 8px 10px;
  border-radius: 10px; border:1px solid var(--border);
  background: var(--btn-primary); color:#e8eef8; cursor:pointer;
  display:inline-grid; place-items:center; padding:0;
  box-shadow:none;
}
.btn-eye:hover{ background: var(--btn-primary-hover); }

/* icon */
.btn-eye::before{
  content:"";
  width:18px; height:18px; display:block; background:currentColor;
  -webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5C21.27 7.61 17 4.5 12 4.5zm0 12a4.5 4.5 0 1 1 0-9 4.5 4.5 0 0 1 0 9z'/%3E%3C/svg%3E");
          mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5C21.27 7.61 17 4.5 12 4.5zm0 12a4.5 4.5 0 1 1 0-9 4.5 4.5 0 0 1 0 9z'/%3E%3C/svg%3E");
  -webkit-mask-repeat:no-repeat; mask-repeat:no-repeat;
  -webkit-mask-position:center;  mask-position:center;
  -webkit-mask-size:contain;     mask-size:contain;
}

/* active = “hide all” -> slashed eye + highlighted border */
.btn-eye.active{
  border-color:#00eaff;
  box-shadow:0 0 0 2px #00eaff55;
}
.btn-eye.active::before{
  -webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2.1 3.51 20.49 21.9l1.41-1.41L3.51 2.1 2.1 3.51zM12 6c4.42 0 8.19 2.55 10 6-1 2.22-2.76 4.07-4.94 5.16l-2.2-2.2A4.5 4.5 0 0 0 9.03 10l-2.1-2.1A12.7 12.7 0 0 1 12 6zm0 12c-4.42 0-8.19-2.55-10-6 .83-1.84 2.23-3.42 3.98-4.56l2.16 2.16A4.5 4.5 0 0 0 14.4 14.3l2.36 2.36A12.6 12.6 0 0 1 12 18z'/%3E%3C/svg%3E");
          mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2.1 3.51 20.49 21.9l1.41-1.41L3.51 2.1 2.1 3.51zM12 6c4.42 0 8.19 2.55 10 6-1 2.22-2.76 4.07-4.94 5.16l-2.2-2.2A4.5 4.5 0 0 0 9.03 10l-2.1-2.1A12.7 12.7 0 0 1 12 6zm0 12c-4.42 0-8.19-2.55-10-6 .83-1.84 2.23-3.42 3.98-4.56l2.16 2.16A4.5 4.5 0 0 0 14.4 14.3l2.36 2.36A12.6 12.6 0 0 1 12 18z'/%3E%3C/svg%3E");
}

.toggle-color.color-hidden {
  opacity: 0.4;
  filter: grayscale(100%);
}

.toggle-color.color-hidden .hide-eye {
  opacity: 1;
}

.usage-item.hidden {
  opacity: 0.45;
  filter: grayscale(100%);
}

.usage-hide-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  background: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2.1 3.51 20.49 21.9l1.41-1.41L3.51 2.1 2.1 3.51zM12 6c4.42 0 8.19 2.55 10 6-1 2.22-2.76 4.07-4.94 5.16l-2.2-2.2A4.5 4.5 0 0 0 9.03 10l-2.1-2.1A12.7 12.7 0 0 1 12 6zm0 12c-4.42 0-8.19-2.55-10-6 .83-1.84 2.23-3.42 3.98-4.56l2.16 2.16A4.5 4.5 0 0 0 14.4 14.3l2.36 2.36A12.6 12.6 0 0 1 12 18z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2.1 3.51 20.49 21.9l1.41-1.41L3.51 2.1 2.1 3.51zM12 6c4.42 0 8.19 2.55 10 6-1 2.22-2.76 4.07-4.94 5.16l-2.2-2.2A4.5 4.5 0 0 0 9.03 10l-2.1-2.1A12.7 12.7 0 0 1 12 6zm0 12c-4.42 0-8.19-2.55-10-6 .83-1.84 2.23-3.42 3.98-4.56l2.16 2.16A4.5 4.5 0 0 0 14.4 14.3l2.36 2.36A12.6 12.6 0 0 1 12 18z'/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
}

/* --- Advanced options (details/summary) --- */
.adv-card {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(160deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  box-shadow: var(--shadow);
}
.adv-card > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 1.1rem;
  border-radius: 12px;
  display: flex; align-items: center; gap: 10px;
  outline: none;
}
.adv-card > summary::-webkit-details-marker { display: none; }
.adv-card > summary::after {
  content: "";
  margin-left: auto;
  width: 10px; height: 10px;
  border-right: 2px solid var(--text);
  border-bottom: 2px solid var(--text);
  transform: rotate(45deg);
  opacity: .8;
}
.adv-card[open] > summary::after { transform: rotate(225deg); }

.adv-card .adv-content {
  padding: 10px 14px 14px 14px;
  display: grid; gap: 8px;
}
.adv-check {
  display: flex; align-items: center; gap: 10px;
  font-size: .98rem; color: var(--text);
}
.adv-check input { accent-color: var(--brand); }

/* --- Master eye (small icon button in card header) --- */
.btn-eye{
  width: 28px;
  height: 28px;
  margin-left: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f1420;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #e8eef8;
}

.btn-eye:hover { box-shadow: 0 0 0 2px #00eaff33; }

.btn-eye::before{
  content: "";
  width: 16px;
  height: 16px;
  display: block;
  background: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5C21.27 7.61 17 4.5 12 4.5zm0 12a4.5 4.5 0 1 1 0-9 4.5 4.5 0 0 1 0 9z'/%3E%3C/svg%3E");
          mask-image:       url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5C21.27 7.61 17 4.5 12 4.5zm0 12a4.5 4.5 0 1 1 0-9 4.5 4.5 0 0 1 0 9z'/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;           mask-repeat: no-repeat;
  -webkit-mask-position: center;            mask-position: center;
  -webkit-mask-size: contain;               mask-size: contain;
}

.btn-eye.active::before{
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2.1 3.51 20.49 21.9l1.41-1.41L3.51 2.1 2.1 3.51zM12 6c4.42 0 8.19 2.55 10 6-1 2.22-2.76 4.07-4.94 5.16l-2.2-2.2A4.5 4.5 0 0 0 9.03 10l-2.1-2.1A12.7 12.7 0 0 1 12 6zm0 12c-4.42 0-8.19-2.55-10-6 .83-1.84 2.23-3.42 3.98-4.56l2.16 2.16A4.5 4.5 0 0 0 14.4 14.3l2.36 2.36A12.6 12.6 0 0 1 12 18z'/%3E%3C/svg%3E");
          mask-image:       url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2.1 3.51 20.49 21.9l1.41-1.41L3.51 2.1 2.1 3.51zM12 6c4.42 0 8.19 2.55 10 6-1 2.22-2.76 4.07-4.94 5.16l-2.2-2.2A4.5 4.5 0 0 0 9.03 10l-2.1-2.1A12.7 12.7 0 0 1 12 6zm0 12c-4.42 0-8.19-2.55-10-6 .83-1.84 2.23-3.42 3.98-4.56l2.16 2.16A4.5 4.5 0 0 0 14.4 14.3l2.36 2.36A12.6 12.6 0 0 1 12 18z'/%3E%3C/svg%3E");
}

/* When the toggle is OFF, hide all color-hiding UI */
body.hide-ui-off .hide-eye,
body.hide-ui-off .btn-eye { display: none !important; }

/* Make the library card span BOTH columns of the homepage .app grid */
.container.app .gallery-shell{
  grid-column: 1 / -1;   /* <-- spans both columns */
  width: 100%;
  max-width: none;       /* kill any previous cap like 1100px/var(--container) */
  margin: 24px 0 40px;
  padding: 24px;
  box-sizing: border-box;
}

/*Gallery*/

/* Album grid fills the full card width */
.album-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
  width: 100%;
  margin-top: 12px;
}

/* Individual tiles */
.album-grid .gallery-item{
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-2);
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
  transition: transform .2s ease, box-shadow .2s ease;
}
.album-grid .gallery-item:hover{
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0,0,0,.45);
}

/* Image fit */
.album-grid .gallery-item img{
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: 4 / 3;   /* uniform rows */
}

/* Action bar on hover (kept if you already use it) */
.gallery-actions{
  position: absolute;
  top: 10px; right: 10px;
  display: flex; gap: 8px;
  opacity: 0; transform: translateY(-4px);
  transition: opacity .2s, transform .2s;
}
.gallery-item:hover .gallery-actions{ opacity: 1; transform: translateY(0); }
.gallery-actions a, .gallery-actions button{
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; cursor: pointer;
  background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.12);
}
.gallery-actions a:hover, .gallery-actions button:hover{ background: var(--btn-primary); }
.gallery-actions img{ width: 22px; height: 22px; filter: invert(1); pointer-events: none; }

/* Empty state centered nicely */
.hidden{ display: none !important; }
.album-empty{
  min-height: 30vh;
  display: grid; place-items: center;
}

.gallery-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  position: relative;
  margin-bottom: 20px;
}

.gallery-title {
  font-size: 1.6rem;
  margin: 0;
}

/* ---------- Storage Meter ---------- */
.storage-meter {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 350px;
}

.storage-bar {
  flex: 1;
  background: #2c2c2c;
  border-radius: 6px;
  height: 12px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
}

.storage-bar span {
  display: block;
  height: 100%;
  background: var(--brand-2);
  border-radius: 6px;
  transition: width 0.3s ease;
}

#storageText {
  font-size: 0.85rem;
  color: #ccc;
  min-width: 90px;
}

.gallery-tools {
  position: absolute;
  right: 0;
  top: 0;
  display: flex;
  gap: 10px;
}

/* ----------- Mobile Fix ----------- */
@media (max-width: 768px) {
  .gallery-head {
    align-items: stretch;
  }

  .gallery-tools {
    position: static;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .gallery-tools .btn {
    flex: 1;
    min-width: 120px;
  }

  .storage-meter {
    max-width: 100%;
  }
}

/* === Burger dropdown === */
.menu-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(2px);
  z-index: 98;
}

.mobile-menu{
  position: fixed;
  right: 12px;
  top: calc(var(--header-height, 64px) + 8px);
  width: min(260px, 86vw);
  background: rgba(20, 20, 20, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  box-shadow: 0 12px 30px rgba(0,0,0,.45), inset 0 0 0 1px rgba(255,255,255,.04);
  border-radius: 14px;
  padding: 8px;
  z-index: 99;
  transform: translateY(-8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.mobile-menu.show{
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.mobile-menu-inner{ display: grid; gap: 4px; }
.menu-item{
  display: block;
  padding: 12px 14px;
  border-radius: 10px;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}
.menu-item:hover{ 
  background: rgba(255,255,255,.12); 
}
.menu-sep{ border: 0; height: 1px; background: var(--border); margin: 6px 0; }

@media (min-width: 981px){
  .mobile-menu, .menu-backdrop{ display:none !important; }
}

.icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.2s ease;
}
.icon-btn img {
  width: 33px;
  height: 33px;
}
.icon-btn.danger img {
  filter: invert(27%) sepia(97%) saturate(7483%) 
          hue-rotate(356deg) brightness(96%) contrast(112%);
}
.icon-btn:hover {
  background: rgba(255, 0, 0, 0.08);
}

/* ---------- Gallery toolbar ---------- */
.gallery-toolbar .toolbar-row{
  display:flex; gap:10px; align-items:center; flex-wrap:wrap;
}
.gallery-toolbar .input{
  background:#1c1f26; color:#fff; border:1px solid var(--border);
  border-radius:10px; padding:10px 12px; min-width:140px;
  outline:none;
}
.gallery-toolbar .input:focus{ border-color:var(--brand); box-shadow:0 0 0 2px #00eaff33; }
.gallery-toolbar .toggle{ display:flex; align-items:center; gap:8px; }
.gallery-toolbar .bulk-wrap{ margin-left:auto; display:flex; gap:10px; align-items:center; }

/* ---------- Selection mode ---------- */
.select-mode .gallery-item{ outline:2px dashed rgba(0,149,255,.25); }
.select-check{
  position:absolute; left:10px; top:10px; z-index:3;
  display:none; width:26px; height:26px; border-radius:6px;
  background:rgba(0,0,0,.5); border:1px solid rgba(255,255,255,.2);
  align-items:center; justify-content:center;
}
.select-mode .select-check{ display:flex; }
.select-check input{ width:18px; height:18px; }

/* ---------- Viewer ---------- */
.viewer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: grid;
  place-items: center;
  z-index: 1200;
}
.viewer[hidden]{ display:none; }
.viewer-inner{
  position:relative; width:min(1000px,94vw); max-height:92vh; background:#121418;
  color:#fff; border:1px solid var(--border); border-radius:14px; padding:14px; display:grid;
  grid-template-columns: 1fr 360px; gap:12px;
}
.viewer-close{ position:absolute; right:10px; top:10px; border:0; background:#222; color:#fff; width:34px; height:34px; border-radius:8px; }
.viewer-nav{ position:absolute; top:50%; transform:translateY(-50%); border:0; background:#222; color:#fff; width:40px; height:40px; border-radius:50%; }
.viewer-nav.prev{ left:10px; } .viewer-nav.next{ right:10px; }

#viewerImg{ width:100%; height:calc(92vh - 120px); object-fit:contain; background:#0d0f12; border-radius:10px; }
.viewer-meta{ display:grid; gap:10px; }
.viewer-meta .input{ background:#1c1f26; color:#fff; border:1px solid var(--border); border-radius:8px; padding:10px; }
.viewer-actions{ display:flex; gap:8px; flex-wrap:wrap; }

/* Buttons */
.btn-danger{ background: var(--danger); color:#fff; border:0; }
.btn-danger:hover{ filter:brightness(1.1); }

/* -------- Selection square: show on hover / when selected -------- */
.select-check{
  position:absolute; left:10px; top:10px; z-index:3;
  display:none; width:26px; height:26px; border-radius:6px;
  background:rgba(0,0,0,.5); border:1px solid rgba(255,255,255,.2);
  align-items:center; justify-content:center;
}
.gallery-item:hover .select-check{ display:flex; }
.gallery-item.is-selected .select-check{
  display:flex;
  background:rgba(0,149,255,.8);
  border-color:#fff;
}
.select-check input{ width:18px; height:18px; }

/* Highlight selected tile */
.gallery-item.is-selected{
  outline:2px solid rgba(0,149,255,.6);
  box-shadow: 0 12px 24px rgba(0,149,255,.15);
}

/* -------- Floating selection bar -------- */
.selection-bar{
  position: sticky; /* sits under the toolbar and scrolls away; change to fixed if you prefer */
  top: 10px;
  z-index: 15;
  backdrop-filter: blur(6px);
  background: rgba(20, 20, 26, 0.75);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 10px 0 6px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.selection-bar #selectionCount{
  font-weight: 600;
  color: #cfd7ff;
}
.selection-bar .selection-actions{
  margin-left: auto;
  display:flex; gap:8px;
}

/* -------- Viewer select control -------- */
.viewer-select{
  position:absolute; left:10px; top:10px;
  width:34px; height:34px; border-radius:8px;
  border:1px solid var(--border);
  background:#222; color:#fff; font-weight:700;
  display:grid; place-items:center; cursor:pointer;
  opacity:.9;
}
.viewer-select[aria-pressed="true"]{
  background: #0d6efd; /* brand */
  border-color: #7fb8ff;
}

/* Keep everything within the screen on mobile */
@media (max-width: 820px) {
  /* Container edge-to-edge */
  .container { width: 100% !important; padding-inline: 12px !important; }

  /* Force app to one column no matter what came before */
  .app { 
    display: grid !important; 
    grid-template-columns: 1fr !important; 
    gap: 16px !important;
  }

  /* Remove any leftover fixed widths that cause overflow */
  .scroll-bar { gap: 8px !important; flex-wrap: nowrap; }
  #scaleRange, #zoomRange { width: 100% !important; }

  /* Inputs stretch nicely */
  .dimensions {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 10px !important;
  }
  .dimension-input input,
  .dimension-input .area-box {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Buttons full width, stack with nice spacing */
  .button, .btn { 
    width: 100% !important; 
    height: 46px !important; 
    margin: 10px 0 0 0 !important; 
    font-size: 1rem !important; 
  }

  /* Canvas area should never overflow horizontally */
  .canvas-wrap { gap: 12px !important; }
  .canvas-viewport{
    width: 100% !important;
    max-width: 100% !important;
    height: clamp(260px, 50vh, 62vh) !important;
    padding: 6px !important;
    overflow: auto !important;
  }
  .canvas-viewport > #canvas{
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
    aspect-ratio: auto !important;
  }

  /* Colors section stacks and stays scrollable */
  .panel-colors{
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  #colors-free, #colors-paid{
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)) !important;
    gap: 10px !important;
    max-height: 300px !important;
    padding: 10px !important;
  }

  /* Header: keep brand readable and tools usable */
  .brand{ display:flex; align-items:center; gap:8px; min-width:0; }
  .brand-name{
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 52vw; font-size: clamp(1rem, 3.6vw, 1.15rem);
  }
  .nav-tools{ margin-left:auto; gap:8px; flex-shrink:0; }
  .nav-burger{ display:block !important; width:40px; height:40px; }
  #lang-select{ min-width:120px; padding:6px 10px; font-size:.95rem; }
}

/* Even tighter on tiny phones */
@media (max-width: 480px){
  #colors-free, #colors-paid{
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)) !important;
  }
  .brand-name{ font-size: .95rem !important; }
}