@font-face {
  font-family: 'MuseoModerno';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/fonts/museomoderno-latin-wght-normal.woff2') format('woff2-variations');
}

@font-face {
  font-family: 'Work Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/fonts/work-sans-latin-wght-normal.woff2') format('woff2-variations');
}

/*
  Same charter as mportail (mobiletic.com): violet #6A1FFF, green #00FC8E, anthracite #3A3A39,
  lavender #F2ECFD, MuseoModerno headings, Work Sans body. Light or dark follows the device.
*/
:root {
  color-scheme: light dark;

  --primary: #6a1fff;
  --primary-deep: #5314d6;
  --primary-soft: #9f70ff;
  --lavande: #f2ecfd;
  --lavande-2: #f9f6ff;
  --accent: #00fc8e;
  --accent-hover: #12e88a;
  --accent-deep: #0b8a4f;
  --accent-soft: #e3fbef;
  --ink: #3a3a39;
  --muted: #69727d;
  --mist: #eef0f3;
  --line: #e6e0f5;
  --line-strong: #d6ccf0;
  --warn: #a86a00;
  --warn-soft: #fbf1dc;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --page: #ffffff;
  --surface: #ffffff;
  --night: #3a3a39;
  --selection: #e3d6ff;
  --shadow-panel: 0 1px 2px rgba(58, 32, 120, 0.05), 0 16px 48px -16px rgba(106, 31, 255, 0.16);

  --font-display: 'MuseoModerno', ui-sans-serif, sans-serif;
  --font-sans: 'Work Sans', ui-sans-serif, system-ui, sans-serif;
  --radius-control: 10px;
  --radius-panel: 16px;
}

@supports (color: light-dark(#000, #fff)) {
  :root {
    --primary: light-dark(#6a1fff, #7f45ff);
    --primary-deep: light-dark(#5314d6, #a27dff);
    --primary-soft: light-dark(#9f70ff, #6c4fc4);
    --lavande: light-dark(#f2ecfd, #2a2340);
    --lavande-2: light-dark(#f9f6ff, #1d1a29);
    --accent-deep: light-dark(#0b8a4f, #3ddc97);
    --accent-soft: light-dark(#e3fbef, #11291e);
    --ink: light-dark(#3a3a39, #ecebf3);
    --muted: light-dark(#69727d, #a19eb2);
    --mist: light-dark(#eef0f3, #282533);
    --line: light-dark(#e6e0f5, #2f2a3e);
    --line-strong: light-dark(#d6ccf0, #443c5e);
    --warn: light-dark(#a86a00, #f2b44a);
    --warn-soft: light-dark(#fbf1dc, #33270f);
    --danger: light-dark(#b42318, #f26b5e);
    --danger-soft: light-dark(#fdecea, #3a1714);
    --page: light-dark(#ffffff, #121019);
    --surface: light-dark(#ffffff, #1b1825);
    --selection: light-dark(#e3d6ff, #4b3391);
    --shadow-panel: 0 1px 2px light-dark(rgba(58, 32, 120, 0.05), rgba(0, 0, 0, 0.35)),
      0 16px 48px -16px light-dark(rgba(106, 31, 255, 0.16), rgba(0, 0, 0, 0.55));
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
  color: inherit;
}

::selection {
  background: var(--selection);
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* Shell: lavender sidebar on large screens, like mportail */

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 18rem;
  height: 100vh;
  flex: none;
  overflow-y: auto;
  padding: 1.5rem 1rem;
  border-right: 1px solid var(--line);
  background: var(--lavande-2);
}

.main {
  flex: 1;
  min-width: 0;
  max-width: 68rem;
  padding: 2.5rem;
}

.brand {
  display: block;
  border-radius: var(--radius-control);
  text-decoration: none;
}

/* Built like the mobiletic logo: violet block, white start, green end. */
.wordmark {
  display: inline-flex;
  align-items: baseline;
  padding: 0.125rem 0.5rem;
  border-radius: 7px;
  background: var(--primary);
  color: #ffffff;
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.wordmark-accent {
  color: var(--accent);
}

.tagline {
  display: block;
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1rem;
}

.sidebar-foot {
  display: grid;
  gap: 0.75rem;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.identity {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.5rem;
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary-deep);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.privacy {
  display: flex;
  gap: 0.5rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.125rem;
}

.privacy svg {
  color: var(--accent-deep);
}

/* Settings */

.settings-toggle {
  display: none;
}

.settings-form {
  display: grid;
  gap: 1.5rem;
  padding: 0 0.25rem;
}

.field {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.field-label {
  display: block;
  padding: 0;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.field-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.quality-value {
  padding: 0 0.5rem;
  border-radius: 999px;
  background: var(--lavande);
  color: var(--primary-deep);
  font-size: 0.8125rem;
  font-weight: 600;
}

.hint {
  margin: 0.375rem 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.25rem;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.pills label {
  position: relative;
}

.pills input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.pills span {
  display: block;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.8125rem;
  font-weight: 500;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.pills label:hover span {
  border-color: var(--primary-soft);
}

.pills input:checked + span {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.pills input:focus-visible + span {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

input[type='range'] {
  width: 100%;
  margin: 0;
  accent-color: var(--primary);
}

.check {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.625rem;
  align-items: start;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.check input {
  width: 1.0625rem;
  height: 1.0625rem;
  margin: 0.125rem 0 0;
  accent-color: var(--primary);
}

.check small {
  display: block;
  margin-top: 0.125rem;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.25rem;
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.625rem;
}

.pair label {
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.9375rem;
  line-height: 1.5rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder {
  color: color-mix(in srgb, var(--muted) 65%, transparent);
}

.input:hover {
  border-color: var(--primary-soft);
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 14%, transparent);
}

/* Page header */

.page-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 2.25rem;
  letter-spacing: -0.025em;
}

.page-lead {
  max-width: 42rem;
  margin: 0.5rem 0 0;
  color: var(--muted);
  line-height: 1.75rem;
}

/* Buttons, as in mportail */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.125rem;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.5rem;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-deep);
}

/* Main call to action: green on anthracite, as on mobiletic.com */
.btn-accent {
  background: var(--accent);
  color: var(--night);
}

.btn-accent:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--primary-deep);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--lavande-2);
  border-color: var(--primary-soft);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 2.125rem;
  height: 2.125rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Drop zone */

.drop {
  display: grid;
  justify-items: center;
  gap: 0.25rem;
  margin-top: 1.75rem;
  padding: 2.75rem 1.5rem;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-panel);
  background: var(--lavande-2);
  text-align: center;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.drop.is-over {
  border-color: var(--primary);
  background: var(--lavande);
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  margin-bottom: 0.5rem;
  border-radius: 999px;
  background: var(--lavande);
  color: var(--primary);
}

.drop-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.75rem;
}

.drop-text {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.875rem;
}

/* Results */

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
  box-shadow: var(--shadow-panel);
}

.results {
  margin-top: 1.75rem;
  padding: 1.25rem 1.5rem 0.5rem;
}

.results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.results-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.75rem;
}

.summary {
  max-width: 40rem;
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.summary strong {
  color: var(--accent-deep);
  font-weight: 700;
}

.results-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 0.875rem 0;
}

.item + .item {
  border-top: 1px solid var(--line);
}

.item-thumb {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--radius-control);
  object-fit: cover;
  background: var(--mist);
}

.item-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.375rem;
  min-width: 0;
}

.item-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.item-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9375rem;
  font-weight: 600;
}

/* Saving shown as a status pill */
.item-saving {
  flex: none;
  padding: 0.0625rem 0.625rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
}

.item-saving:empty {
  display: none;
}

.item[data-status='done'] .item-saving {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.item[data-status='done'] .item-saving.is-larger {
  background: var(--warn-soft);
  color: var(--warn);
}

.item[data-status='done'] .item-saving.is-kept {
  background: var(--mist);
  color: var(--muted);
}

.item-meta {
  color: var(--muted);
  font-size: 0.8125rem;
}

.item-detail {
  flex: none;
}

/* The track is the original file; the violet fill is what's left. Green is what was saved. */
.item-bar {
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--mist);
}

.item-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
  transform-origin: left;
  transform: scaleX(var(--size, 1));
  transition: transform 700ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.item[data-status='queued'] .item-bar-fill {
  opacity: 0.2;
}

.item[data-status='working'] .item-bar-fill {
  opacity: 0.45;
}

.item[data-status='done'] .item-bar {
  background: var(--accent);
}

.item[data-status='error'] .item-bar-fill {
  background: var(--danger);
}

.item[data-status='error'] .item-sizes {
  color: var(--danger);
}

.item-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.item:not([data-status='done']) [data-action='compare'],
.item:not([data-status='done']) [data-action='download'] {
  visibility: hidden;
}

/* Compare dialog */

.compare {
  width: min(64rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-panel);
}

.compare::backdrop {
  background: rgba(18, 16, 25, 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.compare-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.compare-head form {
  margin: 0;
}

.compare-title {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
}

.compare-stage {
  position: relative;
  height: min(65vh, 40rem);
  border-radius: var(--radius-control);
  overflow: hidden;
  background-color: var(--lavande-2);
  background-image:
    linear-gradient(45deg, var(--line) 25%, transparent 25%, transparent 75%, var(--line) 75%),
    linear-gradient(45deg, var(--line) 25%, transparent 25%, transparent 75%, var(--line) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
  cursor: ew-resize;
  touch-action: none;
  --pos: 50%;
}

.compare-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.compare-after {
  clip-path: inset(0 0 0 var(--pos));
}

.compare-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos);
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(58, 58, 57, 0.25);
  pointer-events: none;
}

input.compare-range {
  margin-top: 0.875rem;
}

.compare-legend {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.compare-legend b {
  color: var(--ink);
  font-weight: 600;
}

/* Name dialog, shown once per browser */

.whoami {
  width: min(26rem, calc(100vw - 2rem));
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-panel);
}

.whoami::backdrop {
  background: rgba(18, 16, 25, 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.whoami-form {
  margin: 0;
}

.whoami-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.75rem;
}

.whoami-text {
  margin: 0.5rem 0 1.25rem;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.375rem;
}

.whoami-actions {
  display: flex;
  flex-direction: row-reverse;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

/* Usage page */

.usage-page {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 2.5rem 4rem;
}

.usage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.usage-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.pills a {
  color: inherit;
  text-decoration: none;
  border-radius: 999px;
}

.pills a:hover span {
  border-color: var(--primary-soft);
}

.pills .is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 1.25rem 0 0;
  padding: 0;
  overflow: hidden;
}

.stats div {
  padding: 1rem 1.25rem;
}

.stats div + div {
  border-left: 1px solid var(--line);
}

.stats dt {
  color: var(--muted);
  font-size: 0.8125rem;
}

.stats dd {
  margin: 0.25rem 0 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 2rem;
}

.usage-list {
  margin-top: 1.25rem;
}

.usage-scroll {
  overflow-x: auto;
}

.usage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.usage-table th {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.usage-table td {
  padding: 0.75rem 1rem;
  white-space: nowrap;
}

.usage-table tbody tr + tr td {
  border-top: 1px solid var(--line);
}

.usage-table tbody tr:hover td {
  background: var(--lavande-2);
}

.usage-table .num {
  text-align: right;
}

.usage-who {
  font-weight: 600;
}

.muted {
  color: var(--muted);
  font-weight: 400;
}

.saving-pill {
  display: inline-block;
  padding: 0.0625rem 0.625rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 0.8125rem;
  font-weight: 600;
}

.saving-pill.is-flat {
  background: var(--mist);
  color: var(--muted);
}

.usage-empty {
  margin: 0;
  padding: 2.5rem 1.5rem;
  color: var(--muted);
  text-align: center;
}

/* Below mportail's lg breakpoint: no sidebar, settings fold into a panel */

@media (max-width: 63.99rem) {
  .shell {
    flex-direction: column;
  }

  .sidebar {
    position: static;
    width: auto;
    height: auto;
    gap: 1rem;
    padding: 1rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.75rem;
  }

  .tagline {
    margin-top: 0;
  }

  .settings {
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    background: var(--surface);
  }

  .settings-toggle {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
  }

  .settings-summary {
    color: var(--muted);
    font-weight: 400;
    font-size: 0.8125rem;
  }

  .settings-form {
    padding: 0.5rem 0.875rem 1.25rem;
  }

  .sidebar-foot {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }

  .usage-page {
    padding: 1.25rem 1rem 3rem;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 1.5rem 1rem 3rem;
  }

  .page-title {
    font-size: 1.625rem;
    line-height: 2rem;
  }

  .drop {
    padding: 2rem 1rem;
  }

  .results {
    padding: 1rem 1rem 0.25rem;
  }

  .item {
    grid-template-columns: 3rem minmax(0, 1fr);
    gap: 0.75rem;
  }

  .item-thumb {
    width: 3rem;
    height: 3rem;
  }

  .item-actions {
    grid-column: 2;
  }

  .item-meta {
    flex-wrap: wrap;
    gap: 0 1rem;
  }

  .item:not([data-status='done']) [data-action='compare'],
  .item:not([data-status='done']) [data-action='download'] {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
