/* ==========================================================================
   NIMZELIO — tools.css
   Tool workspace, dropzone, panels, previews, lightbox, status states
   ========================================================================== */

/* Workspace shell -------------------------------------------------------- */
.workspace { padding: var(--s6) 0 var(--s8); }

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: var(--s4);
  list-style: none;
}
.breadcrumb li { display: inline-flex; align-items: center; gap: 6px; }
.breadcrumb a { text-decoration: none; color: var(--text-2); }
.breadcrumb a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.breadcrumb .sep { color: var(--border-strong); }
.breadcrumb [aria-current="page"] { color: var(--text); font-weight: 500; }

.workspace-head { margin-bottom: var(--s5); }
.workspace-head h1 {
  font-size: clamp(24px, 3.4vw, 34px);
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex-wrap: wrap;
}
.workspace-title {
  display: flex;
  align-items: center;
  gap: var(--s3);
}
.workspace-title .tool-icon {
  width: 46px;
  height: 46px;
  margin-bottom: 0;
  border-radius: 13px;
  flex: 0 0 auto;
}
.workspace-title .tool-icon svg { width: 24px; height: 24px; }

.workspace-head p {
  margin-top: var(--s2);
  color: var(--text-2);
  font-size: 15.5px;
  max-width: 640px;
  line-height: 1.6;
}

.workspace-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: var(--s5);
  align-items: start;
}
@media (max-width: 940px) {
  .workspace-body { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-1);
}
.panel + .panel { margin-top: var(--s4); }
.panel-pad { padding: var(--s5); }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
}
.panel-body { padding: var(--s4); }

.side-panel .panel-body { padding: var(--s4); }
.side-panel .field + .field { margin-top: var(--s4); }

/* Dropzone --------------------------------------------------------------- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: var(--s7) var(--s4);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-card);
  background: var(--surface);
  text-align: center;
  transition: border-color 160ms var(--ease), background 160ms var(--ease);
  cursor: pointer;
  position: relative;
}
.dropzone:hover { border-color: #B9BDAF; background: #FCFCFA; }
.dropzone.is-over {
  border-color: #8A9A84;
  background: var(--sage-soft);
}
.dropzone.is-over::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--r-card);
  pointer-events: none;
}
.dropzone-icon { color: var(--text-2); margin-bottom: var(--s1); }
.dropzone-title { font-size: 15px; font-weight: 500; }
.dropzone-hint { font-size: 13px; color: var(--text-2); max-width: 380px; line-height: 1.5; }
.dropzone input[type="file"] {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}
.dropzone:focus-within { outline: 2px solid #6E7F68; outline-offset: 2px; }

.file-pill {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  font-size: 13.5px;
  min-width: 0;
}
.file-pill .name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
}
.file-pill .size { color: var(--text-2); font-size: 12.5px; flex: 0 0 auto; }

/* Stats / data rows ------------------------------------------------------ */
.kv {
  display: grid;
  grid-template-columns: minmax(120px, 34%) minmax(0, 1fr);
  gap: 2px var(--s4);
  font-size: 14px;
}
.kv dt { color: var(--text-2); padding: 7px 0; border-bottom: 1px solid var(--border); }
.kv dd {
  margin: 0;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  overflow-wrap: anywhere;
}
.kv dt:last-of-type, .kv dd:last-of-type { border-bottom: 0; }
.kv .unknown { color: var(--text-2); font-weight: 400; font-style: italic; }

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
}
.stat {
  flex: 1 1 140px;
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
}
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-2); font-weight: 600; }
.stat .v { font-size: 16px; font-weight: 600; margin-top: 2px; letter-spacing: -0.01em; }
.stat .v small { font-size: 12px; font-weight: 500; color: var(--text-2); margin-left: 4px; }

/* Previews --------------------------------------------------------------- */
.preview-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(45deg, #F1F1EC 25%, transparent 25%, transparent 75%, #F1F1EC 75%),
    linear-gradient(45deg, #F1F1EC 25%, transparent 25%, transparent 75%, #F1F1EC 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  min-height: 160px;
  padding: var(--s3);
  position: relative;
}
.preview-frame img,
.preview-frame video,
.preview-frame canvas {
  max-width: 100%;
  max-height: 420px;
  display: block;
  object-fit: contain;
}
.preview-frame.plain { background: var(--bg); }

.crop-stage { position: relative; display: inline-block; line-height: 0; }
.crop-stage img { display: block; max-width: 100%; max-height: 420px; }
.crop-overlay {
  position: absolute;
  border: 1.5px solid #242722;
  box-shadow: 0 0 0 9999px rgba(36, 39, 34, 0.34);
  pointer-events: none;
  box-sizing: border-box;
}
.crop-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px dashed rgba(255, 255, 255, 0.75);
}

.wave-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  overflow: hidden;
}
.wave-wrap canvas { display: block; width: 100%; height: 120px; }
.wave-legend {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-2);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

/* Controls --------------------------------------------------------------- */
.control-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s4);
}
@media (max-width: 560px) { .control-row { grid-template-columns: 1fr; } }

.control-row-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s3);
}
@media (max-width: 620px) { .control-row-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 400px) { .control-row-3 { grid-template-columns: 1fr; } }

.slider-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
}
.slider-row input[type="range"] { flex: 1 1 auto; }
.slider-row .val {
  font-family: var(--mono);
  font-size: 13px;
  min-width: 62px;
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  align-items: center;
  padding-top: var(--s4);
  margin-top: var(--s4);
  border-top: 1px solid var(--border);
}
.action-bar .spacer { flex: 1 1 auto; }

/* Status ----------------------------------------------------------------- */
.status {
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  font-size: 13.5px;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.status:empty { display: none; }
.status[data-state="busy"] { background: var(--blue-soft); border-color: #D3E2EE; color: #3C5A70; }
.status[data-state="ok"]   { background: var(--ok-bg); border-color: #D7E5D3; color: var(--ok); }
.status[data-state="err"]  { background: var(--err-bg); border-color: #EBD2CF; color: var(--err); }
.status[data-state="warn"] { background: var(--peach-soft); border-color: #EFD6C8; color: #7C5343; }

.spinner {
  width: 14px; height: 14px;
  flex: 0 0 auto;
  margin-top: 2px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--text);
  border-radius: 999px;
  transition: width 160ms var(--ease);
}

/* Queue list ------------------------------------------------------------- */
.queue { list-style: none; display: flex; flex-direction: column; gap: var(--s2); }
.queue li {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 13.5px;
}
.queue .idx {
  width: 20px; height: 20px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.queue .name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue .size { color: var(--text-2); font-size: 12.5px; flex: 0 0 auto; }

.entry-list { list-style: none; display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow: auto; }
.entry {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13px;
  background: var(--surface);
}
.entry .name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12.5px; }
.entry .size { color: var(--text-2); font-size: 12px; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.entry.is-dir .name { color: var(--text-2); }

/* Lightbox --------------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s5);
  background: rgba(36, 39, 34, 0.55);
  backdrop-filter: blur(3px);
  animation: fade-in 160ms var(--ease) both;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.lightbox-panel {
  width: min(920px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--r-card);
  overflow: hidden;
  box-shadow: 0 24px 64px -20px rgba(36, 39, 34, 0.45);
}
.lightbox-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.lightbox-head h2 { font-size: 15px; font-weight: 600; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox-body {
  padding: var(--s4);
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  min-height: 200px;
  flex: 1 1 auto;
}
.lightbox-body img { max-width: 100%; max-height: 62vh; display: block; border-radius: 4px; }
.lightbox-foot {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  align-items: center;
  justify-content: space-between;
  padding: var(--s3) var(--s4);
  border-top: 1px solid var(--border);
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--text-2);
}

/* Favicon grid ----------------------------------------------------------- */
.favicon-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s2);
}
.favicon-cell {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
}
.favicon-thumb {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background:
    linear-gradient(45deg, #ECECE6 25%, transparent 25%, transparent 75%, #ECECE6 75%),
    linear-gradient(45deg, #ECECE6 25%, transparent 25%, transparent 75%, #ECECE6 75%);
  background-size: 12px 12px;
  background-position: 0 0, 6px 6px;
  border: 1px solid var(--border);
}
.favicon-thumb img { display: block; image-rendering: auto; }
.favicon-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.favicon-meta strong { font-size: 13.5px; font-weight: 600; }
.favicon-cell .btn { flex: 0 0 auto; }

/* Loading skeleton ------------------------------------------------------- */
.tool-skeleton {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: var(--s5);
  align-items: start;
}
@media (max-width: 940px) {
  .tool-skeleton { grid-template-columns: 1fr; }
}

.skeleton-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-1);
  padding: var(--s5);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
}

.skeleton-line,
.skeleton-block {
  border-radius: 6px;
  background: linear-gradient(90deg, #F1F1EC 25%, #F8F8F4 37%, #F1F1EC 63%);
  background-size: 400% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}
.skeleton-line { height: 14px; }
.skeleton-block { height: 132px; }
.skeleton-line.w40 { width: 40%; }
.skeleton-line.w50 { width: 50%; }
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w70 { width: 70%; }

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

/* Experimental notice ---------------------------------------------------- */
.experimental-panel { padding: var(--s5); }
.experimental-panel h2 { font-size: 17px; margin-bottom: var(--s2); }
.experimental-panel p { font-size: 14.5px; color: var(--text-2); line-height: 1.65; margin-bottom: var(--s3); }
.experimental-panel ul { list-style: none; display: flex; flex-direction: column; gap: 8px; margin: var(--s3) 0; }
.experimental-panel li {
  position: relative;
  padding-left: 20px;
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.55;
}
.experimental-panel li::before {
  content: "";
  position: absolute;
  left: 2px; top: 8px;
  width: 5px; height: 5px;
  border-radius: 1px;
  background: var(--peach);
}

/* Misc ------------------------------------------------------------------- */
.copy-row {
  display: flex;
  gap: var(--s2);
  align-items: center;
}
.swatch {
  width: 56px; height: 56px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  flex: 0 0 auto;
}
.inline-code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  overflow-wrap: anywhere;
  max-height: 160px;
  overflow: auto;
}
.visually-hidden-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
