:root{
  --bg-a: #f2edff;
  --bg-b: #eaf2ff;
  --bg-c: #ffeef8;
  --surface: rgba(255,255,255,0.62);
  --surface-2: rgba(255,255,255,0.85);
  --surface-solid: #ffffff;
  --border: rgba(30,27,46,0.09);
  --border-strong: rgba(30,27,46,0.16);
  --text: #201c33;
  --text-dim: #6b6580;
  --accent: #7c5cff;
  --accent-2: #ff6fb0;
  --accent-soft: rgba(124,92,255,0.12);
  --success: #12b981;
  --success-soft: rgba(18,185,129,0.12);
  --danger: #ef4460;
  --danger-soft: rgba(239,68,96,0.10);
  --radius: 16px;
  --shadow: 0 8px 30px rgba(76,60,140,0.10);
  --blur: blur(18px) saturate(160%);
}
*{ box-sizing: border-box; }
html,body{ margin:0; padding:0; }
body{
  min-height: 100vh;
  background:
    radial-gradient(900px 600px at 8% -10%, var(--bg-c), transparent 60%),
    radial-gradient(900px 700px at 100% 0%, var(--bg-b), transparent 55%),
    radial-gradient(1100px 800px at 50% 120%, var(--bg-a), transparent 60%),
    #f7f5ff;
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a{ color: var(--accent); text-decoration: none; }
a:hover{ text-decoration: underline; }
:focus-visible{ outline: 2px solid var(--accent); outline-offset: 2px; }

.page-header{
  padding: 20px 32px;
  background: var(--surface-2);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.eyebrow{
  text-transform: uppercase;
  letter-spacing: .18em;
  font-size: 11px;
  color: var(--text-dim);
  margin: 0 0 6px;
}
.page-header h1{
  margin: 0;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: .01em;
}
.page-header h1 .brand{
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

nav.main-nav{ display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
nav.main-nav a{
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .02em;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
}
nav.main-nav a:hover{ color: var(--text); background: var(--accent-soft); text-decoration: none; }
nav.main-nav a.active{ color: var(--accent); border-color: var(--border); background: var(--accent-soft); }
nav.main-nav a.logout{ color: var(--danger); }
.usage-widget{
  font-size: 11px;
  color: var(--text-dim);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  white-space: nowrap;
  cursor: help;
}

.wrap{ max-width: 1600px; margin: 0 auto; padding: 24px 32px 40px; }

.page-footer{
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  padding: 18px 32px 32px;
  opacity: .8;
}

.flash{
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  margin-bottom: 16px;
  backdrop-filter: var(--blur);
}
.flash.ok{ background: var(--success-soft); border: 1px solid var(--success); color: #067a56; }
.flash.error{ background: var(--danger-soft); border: 1px solid var(--danger); color: #b41d3d; }

h2.section-title{
  font-size: 14px;
  letter-spacing: .03em;
  color: var(--text-dim);
  margin: 0 0 14px;
  font-weight: 700;
}

.panel{
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 24px;
}

.dropzone{
  border: 1.5px dashed var(--border-strong);
  border-radius: 12px;
  background: rgba(124,92,255,0.05);
  padding: 14px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover{ border-color: var(--accent); }
.dropzone.dragover{ border-color: var(--accent); background: var(--accent-soft); }
.dropzone.has-files{ border-style: solid; background: var(--surface-solid); }
.dropzone input[type="file"]{ display: none; }
.dropzone-text{
  display: block;
  font-size: 12.5px;
  color: var(--text-dim);
  text-align: center;
}
.dropzone.has-files .dropzone-text{ color: var(--text); text-align: left; margin-bottom: 8px; }
.dropzone-preview{ display: flex; gap: 6px; flex-wrap: wrap; }
.dropzone-preview img{
  width: 52px; height: 52px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--border);
}

label{
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
  font-weight: 700;
  margin: 14px 0 6px;
}
label:first-of-type{ margin-top: 0; }

input[type="text"], input[type="file"], select, textarea{
  width: 100%;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
}
input[type="text"]::placeholder{ color: var(--text-dim); }

button, .btn{
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-solid);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  transition: transform .1s ease, border-color .15s ease, box-shadow .15s ease;
}
.btn:hover, button:hover{ border-color: var(--accent); box-shadow: 0 2px 10px rgba(124,92,255,0.18); }
.btn-accent{
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(124,92,255,0.35);
}
.btn-accent:hover{ filter: brightness(1.05); transform: translateY(-1px); }
.btn-danger{ color: var(--danger); }
.btn-danger:hover{ border-color: var(--danger); box-shadow: 0 2px 10px rgba(239,68,96,0.18); }

.grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.tile{
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tile.selected{ border-color: var(--accent); background: var(--accent-soft); }
.tile img{
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
}
.tile .tile-name{ font-weight: 700; font-size: 14px; }
.tile .tile-meta{ font-size: 12px; color: var(--text-dim); }

.thumb-row{ display: flex; gap: 6px; flex-wrap: wrap; }
.thumb-row img{
  width: 56px; height: 56px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--border);
}

.picker{ display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 20px; }
.picker .panel{ flex: 1 1 260px; margin-bottom: 0; }
.picker select{ margin-top: 6px; }

.color-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.color-box{
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.color-box h3{
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent);
}
.color-box .thumb-row{ margin-bottom: 10px; }
.color-box label{ margin: 10px 0 4px; font-size: 10px; }
.color-box .dropzone{ padding: 8px; }
.color-box .dropzone-text{ font-size: 11px; }
.color-box .dropzone-preview img{ width: 36px; height: 36px; }
.color-box button{ margin-top: 10px; width: 100%; justify-content: center; padding: 7px; font-size: 12px; }

.toolbar{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  background: var(--surface-2);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 20px;
  position: sticky;
  top: 84px;
  z-index: 5;
}
.toolbar .fill-group{ display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.toolbar input[type="text"], .toolbar select{ width: auto; min-width: 120px; }

.toggle-switch{
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-dim);
  user-select: none;
}
.toggle-switch input{
  appearance: none;
  width: 34px;
  height: 20px;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  flex: 0 0 auto;
  margin: 0;
  transition: background .15s ease, border-color .15s ease;
}
.toggle-switch input::before{
  content: "";
  position: absolute;
  top: 1px; left: 1px;
  width: 16px; height: 16px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform .15s ease, background .15s ease;
}
.toggle-switch input:checked{ background: var(--accent); border-color: var(--accent); }
.toggle-switch input:checked::before{ transform: translateX(14px); background: #fff; }
.toggle-switch span{ max-width: 230px; line-height: 1.3; }

.toolbar-spacer{ flex: 1 1 auto; }
.select-count{ font-size: 12px; color: var(--accent); font-weight: 700; }

.cards{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.card{
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card.checked{ border-color: var(--accent); background: var(--accent-soft); }
.card-head{ display: flex; align-items: flex-start; gap: 8px; }
.card-num{
  font-size: 11px; color: var(--text-dim);
  background: var(--surface-solid); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 6px; flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}
.card-title{ font-weight: 800; font-size: 15px; flex: 1 1 auto; }
.card-check{ width: 18px; height: 18px; flex: 0 0 auto; accent-color: var(--accent); }
.card-notes{ font-size: 11.5px; color: var(--text-dim); }
.variant-select{
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 600;
}

.login-wrap{
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card{
  background: var(--surface-2);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  width: 320px;
}
.login-card h1{ font-size: 18px; margin: 0 0 20px; line-height: 1.3; }
.login-card h1 .brand{
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.login-card button{ width: 100%; justify-content: center; margin-top: 18px; }

.spinner{
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin{ to{ transform: rotate(360deg); } }

.lightbox-overlay{
  position: fixed; inset: 0;
  background: rgba(20,16,36,0.72);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
  flex-direction: column;
  padding: 24px;
}
.lightbox-overlay.open{ display: flex; }
.lightbox-overlay img{
  max-width: min(90vw, 900px); max-height: 70vh;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.25);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.lightbox-info{ color: #fff; text-align: center; margin-top: 14px; }
.lightbox-info .meta{ color: rgba(255,255,255,0.65); font-size: 13px; }
.lightbox-controls{
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: space-between;
  pointer-events: none;
  padding: 0 16px;
}
.lightbox-controls button{
  pointer-events: auto;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  width: 44px; height: 44px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
}
.lightbox-close{
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
}
.lightbox-select{
  margin-top: 10px;
  display: flex; align-items: center; gap: 8px;
  justify-content: center;
  color: rgba(255,255,255,0.75);
  font-size: 13px;
}

.modal-overlay{
  position: fixed; inset: 0;
  background: rgba(20,16,36,0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 110;
  padding: 24px;
}
.modal-overlay.open{ display: flex; }
.modal-box{
  background: var(--surface-solid);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  padding: 22px;
  width: min(560px, 92vw);
  max-height: 85vh;
  overflow-y: auto;
}
.modal-box h3{ margin: 0 0 12px; font-size: 15px; }
.modal-box textarea{ min-height: 220px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.5; }
.modal-actions{ display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.progress-note{
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.result-tile.error{ border-color: var(--danger); }
.result-tile .tile-status.status-ok{ color: var(--success); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.result-tile .tile-status.status-error{ color: var(--danger); font-size: 11px; font-weight: 700; text-transform: uppercase; }
