/* THEME TOKENS - light and dark */
:root,
[data-theme="light"] {
  --ic-bg:           #FEFAE0;
  --ic-surface:      #ffffff;
  --ic-surface-2:    #f5f0d8;
  --ic-surface-3:    #ede8cc;
  --ic-border:       #e0d8b8;
  --ic-text:         #1a1410;
  --ic-text-muted:   #7a7060;
  --ic-accent:       #D4A373;
  --ic-accent-hover: #b8855a;
  --ic-accent-text:  #ffffff;
  --ic-radius-sm:    6px;
  --ic-radius-md:    10px;
  --ic-radius-lg:    14px;
  --ic-btn-pri-bg:       #D4A373;
  --ic-btn-pri-text:     #ffffff;
  --ic-btn-pri-hover:    #b8855a;
  --ic-btn-sec-bg:       #f5f0d8;
  --ic-btn-sec-text:     #1a1410;
  --ic-btn-sec-border:   #d0c8a0;
  --ic-btn-sec-hover:    #ede8cc;
  --ic-btn-ghost-text:   #5a5040;
  --ic-btn-ghost-hover:  #ede8cc;
  --ic-btn-ghost-htext:  #1a1410;
}

[data-theme="dark"] {
  --ic-bg:           #1a1410;
  --ic-surface:      #2a2218;
  --ic-surface-2:    #342c20;
  --ic-surface-3:    #3e3428;
  --ic-border:       #4a3e2c;
  --ic-text:         #f0e8d0;
  --ic-text-muted:   #9a8e78;
  --ic-accent:       #D4A373;
  --ic-accent-hover: #e8b888;
  --ic-accent-text:  #1a1410;
  --ic-radius-sm:    6px;
  --ic-radius-md:    10px;
  --ic-radius-lg:    14px;
  --ic-btn-pri-bg:       #D4A373;
  --ic-btn-pri-text:     #1a1410;
  --ic-btn-pri-hover:    #e8b888;
  --ic-btn-sec-bg:       #342c20;
  --ic-btn-sec-text:     #f0e8d0;
  --ic-btn-sec-border:   #4a3e2c;
  --ic-btn-sec-hover:    #3e3428;
  --ic-btn-ghost-text:   #c0b090;
  --ic-btn-ghost-hover:  #3e3428;
  --ic-btn-ghost-htext:  #f0e8d0;
}

/* BUTTON SYSTEM */
.ic-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem 1rem;
  border-radius: var(--ic-radius-sm);
  font-family: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
  -webkit-user-select: none;
  user-select: none;
}
.ic-btn:disabled,
.ic-btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }

.ic-btn-primary {
  background:   var(--ic-btn-pri-bg);
  color:        var(--ic-btn-pri-text);
  border-color: var(--ic-btn-pri-bg);
}
.ic-btn-primary:hover:not(:disabled) {
  background:   var(--ic-btn-pri-hover);
  border-color: var(--ic-btn-pri-hover);
}

.ic-btn-secondary {
  background:   var(--ic-btn-sec-bg);
  color:        var(--ic-btn-sec-text);
  border-color: var(--ic-btn-sec-border);
}
.ic-btn-secondary:hover:not(:disabled) {
  background: var(--ic-btn-sec-hover);
}

.ic-btn-ghost {
  background:   transparent;
  color:        var(--ic-btn-ghost-text);
  border-color: transparent;
}
.ic-btn-ghost:hover:not(:disabled) {
  background: var(--ic-btn-ghost-hover);
  color:      var(--ic-btn-ghost-htext);
}

/* Square icon-only buttons */
.ic-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border: 1px solid var(--ic-border);
  border-radius: var(--ic-radius-sm);
  background: var(--ic-surface-2);
  color: var(--ic-text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, color .15s, border-color .15s;
  flex-shrink: 0;
  padding: 0;
}
.ic-icon-btn:hover {
  background:   var(--ic-surface-3);
  border-color: var(--ic-accent);
  color:        var(--ic-accent);
}
.ic-icon-btn.ic-del:hover {
  background:   #fee2e2;
  border-color: #fca5a5;
  color:        #991b1b;
}
[data-theme="dark"] .ic-icon-btn.ic-del:hover {
  background:   #450a0a;
  border-color: #f87171;
  color:        #fca5a5;
}

/* SETTINGS PANEL */
.ic-panel {
  border: 1px solid var(--ic-border);
  border-radius: var(--ic-radius-lg);
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.ic-panel-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .85rem 1.25rem;
  background: var(--ic-surface-2);
  border: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 700;
  color: var(--ic-text);
  font-family: inherit;
  text-align: left;
  transition: background .15s;
}
.ic-panel-toggle:hover { background: var(--ic-surface-3); }
.ic-panel-left { display: flex; align-items: center; gap: .5rem; }
.ic-chevron { transition: transform .25s; flex-shrink: 0; }
.ic-panel[data-open="true"] .ic-chevron { transform: rotate(180deg); }
.ic-panel-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .26s ease;
}
.ic-panel[data-open="true"] .ic-panel-body { grid-template-rows: 1fr; }
.ic-panel-inner { overflow: hidden; padding: 0 1.25rem; }
.ic-panel[data-open="true"] .ic-panel-inner { padding: 1rem 1.25rem 1.25rem; }

/* SETTINGS GRID */
.ic-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 1rem 1.5rem;
}
.ic-setting-group { display: flex; flex-direction: column; gap: .4rem; }
.ic-setting-group > label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--ic-text-muted);
  letter-spacing: .05em;
  text-transform: uppercase;
  display: block;
}
.ic-setting-group select,
.ic-setting-group input[type="number"],
.ic-setting-group input[type="text"] {
  padding: .45rem .7rem;
  border: 1px solid var(--ic-border);
  border-radius: var(--ic-radius-sm);
  background: var(--ic-surface);
  color: var(--ic-text);
  font-size: .875rem;
  font-family: inherit;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.ic-setting-group select:focus,
.ic-setting-group input:focus {
  outline: none;
  border-color: var(--ic-accent);
  box-shadow: 0 0 0 3px rgba(212,163,115,.25);
}
.ic-label-row { display: flex; align-items: baseline; justify-content: space-between; }
.ic-range-val { font-size: .82rem; font-weight: 700; color: var(--ic-accent); }
.ic-range-wrap { display: flex; align-items: center; margin-top: .3rem; }
.ic-range-wrap input[type="range"] {
  width: 100%;
  cursor: pointer;
  accent-color: var(--ic-accent);
}
.ic-presets { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .55rem; }
.ic-preset-btn {
  padding: .28rem .7rem;
  border: 1px solid var(--ic-border);
  border-radius: 999px;
  background: var(--ic-surface);
  color: var(--ic-text-muted);
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .14s, border-color .14s, color .14s;
  line-height: 1.4;
}
.ic-preset-btn:hover {
  border-color: var(--ic-accent);
  color: var(--ic-accent);
  background: var(--ic-surface-2);
}
.ic-preset-btn.active {
  background:   var(--ic-accent);
  border-color: var(--ic-accent);
  color:        var(--ic-accent-text);
}
.ic-settings-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  padding-top: 1rem;
  margin-top: 1rem;
  border-top: 1px solid var(--ic-border);
}
.ic-settings-note { font-size: .78rem; color: var(--ic-text-muted); }

/* DROP ZONE */
.ic-dropzone {
  border: 2px dashed var(--ic-border);
  border-radius: var(--ic-radius-lg);
  padding: 3rem 2rem 2.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
  background: var(--ic-surface);
}
.ic-dropzone:hover,
.ic-dropzone.drag-over {
  border-color: var(--ic-accent);
  background: var(--ic-surface-2);
}
.ic-dropzone:focus-within {
  outline: 3px solid var(--ic-accent);
  outline-offset: 2px;
}
.ic-drop-icon {
  width: 52px; height: 52px;
  color: var(--ic-text-muted);
  margin-bottom: .9rem;
  opacity: .55;
  pointer-events: none;
}
.ic-drop-title {
  font-size: 1.1rem; font-weight: 800;
  margin: 0 0 .35rem;
  color: var(--ic-text);
  pointer-events: none;
}
.ic-drop-sub {
  font-size: .85rem;
  color: var(--ic-text-muted);
  margin: 0 0 1rem;
  pointer-events: none;
}
.ic-drop-formats {
  display: flex; flex-wrap: wrap;
  justify-content: center;
  gap: .35rem; margin-bottom: 1.4rem;
  pointer-events: none;
}
.ic-fmt-pill {
  padding: .2rem .6rem;
  background: var(--ic-surface-2);
  border: 1px solid var(--ic-border);
  border-radius: 999px;
  font-size: .72rem; font-weight: 700;
  letter-spacing: .04em; color: var(--ic-text-muted);
}
.ic-drop-browse-btn { pointer-events: none; }
.ic-dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  z-index: 2;
}

/* STATS BAR */
.ic-stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  padding: .75rem 1rem;
  background: var(--ic-surface-2);
  border: 1px solid var(--ic-border);
  border-radius: var(--ic-radius-md);
  margin: 1.25rem 0 1rem;
  font-size: .82rem;
}
.ic-stat { display: flex; align-items: center; gap: .4rem; color: var(--ic-text-muted); }
.ic-stat strong { color: var(--ic-text); font-weight: 700; }
.ic-stat-saved strong { color: #166534; }
[data-theme="dark"] .ic-stat-saved strong { color: #86efac; }

/* RESULTS HEADER */
.ic-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: .75rem;
}
.ic-results-title {
  font-size: 1rem; font-weight: 800; margin: 0;
  display: flex; align-items: center; gap: .5rem;
  color: var(--ic-text);
}
.ic-results-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  background: var(--ic-accent);
  color: var(--ic-accent-text);
  border-radius: 999px;
  font-size: .72rem; font-weight: 800;
}
.ic-header-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

/* RESULTS TABLE */
.ic-table-wrap {
  overflow-x: auto;
  border-radius: var(--ic-radius-md);
  border: 1px solid var(--ic-border);
}
.ic-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.ic-table th {
  text-align: left;
  padding: .55rem .85rem;
  font-size: .7rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--ic-text-muted);
  background: var(--ic-surface-2);
  border-bottom: 1px solid var(--ic-border);
  white-space: nowrap;
}
.ic-table td {
  padding: .7rem .85rem;
  border-bottom: 1px solid var(--ic-border);
  vertical-align: middle;
  color: var(--ic-text);
  background: var(--ic-surface);
}
.ic-table tbody tr:last-child td { border-bottom: none; }
.ic-table tbody tr:hover td { background: var(--ic-surface-2); }
.ic-table tr.ic-row-processing td { opacity: .65; }

/* THUMBNAIL */
.ic-thumb {
  width: 52px; height: 52px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  border: 1px solid var(--ic-border);
  cursor: zoom-in;
  transition: transform .15s, box-shadow .15s;
}
.ic-thumb:hover {
  transform: scale(1.07);
  box-shadow: 0 4px 18px rgba(0,0,0,.28);
}
.ic-thumb-placeholder {
  width: 52px; height: 52px; border-radius: 8px;
  background: var(--ic-surface-2);
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--ic-border);
}
.ic-fname-cell { max-width: 200px; }
.ic-fname { font-weight: 600; word-break: break-all; font-size: .85rem; color: var(--ic-text); }
.ic-dims { font-size: .71rem; color: var(--ic-text-muted); margin-top: 2px; }
.ic-size-val { font-weight: 600; color: var(--ic-text); }

/* SAVING BADGES */
.ic-badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .25rem .6rem; border-radius: 999px;
  font-size: .74rem; font-weight: 700; white-space: nowrap;
}
.ic-badge--great { background: #d1fadf; color: #166534; }
.ic-badge--good  { background: #dcfce7; color: #166534; }
.ic-badge--ok    { background: #fef9c3; color: #854d0e; }
.ic-badge--worse { background: #fee2e2; color: #991b1b; }
[data-theme="dark"] .ic-badge--great { background: #14532d; color: #86efac; }
[data-theme="dark"] .ic-badge--good  { background: #14532d; color: #86efac; }
[data-theme="dark"] .ic-badge--ok    { background: #422006; color: #fde68a; }
[data-theme="dark"] .ic-badge--worse { background: #450a0a; color: #fca5a5; }

.ic-actions-cell { display: flex; align-items: center; gap: .35rem; justify-content: flex-end; }

/* SPINNER */
.ic-processing { display: flex; align-items: center; gap: .5rem; color: var(--ic-text-muted); font-size: .85rem; }
.ic-spinner {
  width: 15px; height: 15px;
  border: 2px solid var(--ic-border);
  border-top-color: var(--ic-accent);
  border-radius: 50%;
  animation: ic-spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes ic-spin { to { transform: rotate(360deg); } }

/* ERROR */
.ic-error { display: flex; align-items: center; gap: .35rem; font-size: .82rem; color: #991b1b; }
[data-theme="dark"] .ic-error { color: #fca5a5; }

/* MODAL OVERLAY */
.ic-modal-overlay[hidden] {
  display: none !important;
}
.ic-modal-overlay {
  display: flex;
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.82);
  align-items: center; justify-content: center;
  padding: 1.25rem;
  animation: ic-fade .16s ease;
}
@keyframes ic-fade { from { opacity: 0; } to { opacity: 1; } }

.ic-modal {
  background: var(--ic-surface);
  border: 1px solid var(--ic-border);
  border-radius: var(--ic-radius-lg);
  max-width: 980px; width: 100%; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 30px 70px rgba(0,0,0,.5);
}
.ic-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1.2rem;
  border-bottom: 1px solid var(--ic-border);
  flex-shrink: 0;
  background: var(--ic-surface-2);
}
.ic-modal-title {
  font-weight: 800; font-size: .95rem; margin: 0;
  color: var(--ic-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ic-modal-close {
  width: 32px; height: 32px;
  border: 1px solid var(--ic-border);
  background: var(--ic-surface);
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--ic-text);
  font-size: 1rem; line-height: 1;
  flex-shrink: 0;
  transition: background .15s, color .15s, border-color .15s;
}
.ic-modal-close:hover {
  background:   #fee2e2;
  border-color: #fca5a5;
  color:        #991b1b;
}
[data-theme="dark"] .ic-modal-close:hover {
  background:   #450a0a;
  border-color: #f87171;
  color:        #fca5a5;
}
.ic-modal-body { display: flex; flex: 1; overflow: hidden; min-height: 0; }
.ic-compare-pane {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-width: 0;
}
.ic-compare-pane + .ic-compare-pane { border-left: 1px solid var(--ic-border); }
.ic-compare-label {
  padding: .4rem .85rem;
  font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ic-text-muted);
  background: var(--ic-surface-2);
  border-bottom: 1px solid var(--ic-border);
  flex-shrink: 0;
}
.ic-compare-img-wrap {
  flex: 1; overflow: auto;
  display: flex; align-items: center; justify-content: center;
  padding: .75rem;
  background-color: var(--ic-surface-3);
  background-image:
    linear-gradient(45deg,  rgba(128,128,128,.12) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(128,128,128,.12) 25%, transparent 25%),
    linear-gradient(45deg,  transparent 75%, rgba(128,128,128,.12) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(128,128,128,.12) 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}
.ic-compare-img-wrap img {
  max-width: 100%; max-height: 100%;
  object-fit: contain; display: block;
  border-radius: 4px;
}
.ic-modal-footer {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .5rem;
  padding: .75rem 1.2rem;
  border-top: 1px solid var(--ic-border);
  background: var(--ic-surface-2);
  font-size: .82rem; color: var(--ic-text-muted);
  flex-shrink: 0;
}

/* RESPONSIVE */
@media (max-width: 640px) {
  .ic-table th:nth-child(3),
  .ic-table td:nth-child(3) { display: none; }
  .ic-fname-cell { max-width: 110px; }
  .ic-modal-body { flex-direction: column; }
  .ic-compare-pane + .ic-compare-pane {
    border-left: none;
    border-top: 1px solid var(--ic-border);
  }
}
