/* Palette follows the Android app: calm greys and one teal for actions. */
:root {
  --ground: #f6f7f9;
  --surface: #ffffff;
  --ink: #14202b;
  --ink-muted: #4e5b69;
  --line: #dde2e8;
  --teal: #0b7a6f;
  --teal-deep: #075e55;
  --teal-tint: #e2f3f1;
  --bad: #b42318;
  --bad-tint: #fdecea;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

/* Dark follows the device unless the visitor picked a theme with the toggle, which sets
   data-theme on <html> (remembered in this browser). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #121a21;
    --surface: #1c2731;
    --ink: #eef2f5;
    --ink-muted: #a9b5c1;
    --line: #33414d;
    --teal: #35b3a5;
    --teal-deep: #5cc9bc;
    --teal-tint: #173a37;
    --bad: #ff8a80;
    --bad-tint: #3a1e1c;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --ground: #121a21;
  --surface: #1c2731;
  --ink: #eef2f5;
  --ink-muted: #a9b5c1;
  --line: #33414d;
  --teal: #35b3a5;
  --teal-deep: #5cc9bc;
  --teal-tint: #173a37;
  --bad: #ff8a80;
  --bad-tint: #3a1e1c;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Hind Siliguri", "Noto Sans Bengali", "Kohinoor Bangla",
    "Bangla Sangam MN", Vrinda, sans-serif;
  font-size: 17px;
  line-height: 1.65;
}

a {
  color: var(--teal-deep);
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- header and footer ---------- */

.site-head {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.site-head .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 19px;
  color: var(--ink);
  text-decoration: none;
}

.brand img {
  width: 30px;
  height: 30px;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

/* Shows the theme it switches to: a moon in light mode, a sun in dark mode. */
.theme-toggle .sun,
.theme-toggle[data-dark="true"] .moon {
  display: none;
}

.theme-toggle[data-dark="true"] .sun {
  display: block;
}

.theme-toggle:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

.lang {
  font-size: 15px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
  white-space: nowrap;
}

.site-foot {
  margin-top: 48px;
  padding: 24px 0 40px;
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: 15px;
}

.site-foot nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-bottom: 12px;
}

.site-foot p {
  margin: 0;
}

/* ---------- text ---------- */

main {
  padding: 24px 0 0;
}

h1 {
  font-size: 28px;
  line-height: 1.3;
  margin: 0 0 10px;
  text-wrap: balance;
}

h2 {
  font-size: 21px;
  line-height: 1.35;
  margin: 36px 0 10px;
}

.lead {
  margin: 0 0 20px;
  color: var(--ink-muted);
}

main ol,
main ul {
  padding-left: 24px;
}

main li {
  margin: 4px 0;
}

.note {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--teal-tint);
  font-size: 16px;
}

.size-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

.size-table th,
.size-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.size-table td:not(:first-child) {
  font-family: var(--mono);
  font-size: 15px;
  white-space: nowrap;
}

.cards {
  display: grid;
  gap: 10px;
  padding: 0;
  list-style: none;
}

.cards a {
  display: block;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
}

.cards strong {
  display: block;
}

.cards span {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink-muted);
}

details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 8px 0;
}

summary {
  font-weight: 600;
  cursor: pointer;
}

details p {
  margin: 8px 0 0;
  color: var(--ink-muted);
}

.app-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 36px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.app-link p {
  margin: 0;
  flex: 1 1 240px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn.primary {
    color: #06231f;
  }
}

:root[data-theme="dark"] .btn.primary {
  color: #06231f;
}

.btn.small {
  min-height: 40px;
  padding: 6px 14px;
  font-size: 15px;
}

.btn:focus-visible,
.lang:focus-visible,
[data-stage]:focus-visible,
summary:focus-visible,
input:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

/* ---------- the tool ---------- */

.tool {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.tool.is-dragging {
  border-color: var(--teal);
  background: var(--teal-tint);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tabs .btn.is-on {
  background: var(--teal-tint);
  border-color: var(--teal);
  color: var(--teal-deep);
}

.spec {
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--teal-deep);
}

.custom {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 6px;
}

.custom label {
  font-size: 14px;
  color: var(--ink-muted);
}

.custom input {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ground);
  color: var(--ink);
  font: inherit;
  font-family: var(--mono);
}

.compress label {
  display: block;
  font-size: 14px;
  color: var(--ink-muted);
}

.compress input {
  display: block;
  width: 100%;
  max-width: 220px;
  min-height: 44px;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ground);
  color: var(--ink);
  font: inherit;
  font-family: var(--mono);
}

.formats {
  margin-bottom: 4px;
}

.formats-label {
  font-size: 14px;
  color: var(--ink-muted);
}

.formats .chips {
  margin: 4px 0 10px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.chips .btn.is-on {
  background: var(--teal-tint);
  border-color: var(--teal);
  color: var(--teal-deep);
}

.custom-hint {
  grid-column: 1 / -1;
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--ink-muted);
}

.pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 16px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
}

.pick input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.pick:focus-within .btn {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

.pick-hint {
  font-size: 15px;
  color: var(--ink-muted);
}

.stage-wrap {
  width: 100%;
  margin: 0 auto;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 0 0 2px var(--teal);
  background: #fff;
}

[data-stage] {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

[data-stage]:active {
  cursor: grabbing;
}

.hint {
  margin: 10px 0;
  font-size: 15px;
  color: var(--ink-muted);
  text-align: center;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.zoom {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 100%;
  font-size: 15px;
}

.zoom input {
  flex: 1;
  min-height: 32px;
  accent-color: var(--teal);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  font-size: 15px;
}

.check input {
  width: 20px;
  height: 20px;
  accent-color: var(--teal);
}

.status {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--teal-tint);
}

.status p {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--ink);
}

.bar {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: var(--surface);
  overflow: hidden;
}

.bar span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: var(--teal);
}

/* No percentage known: a segment slides across. Transform-only, so it keeps moving while the
   page is busy working on the photo. */
.bar.is-indeterminate span {
  width: 35%;
  transition: none;
  animation: bar-slide 1.2s ease-in-out infinite;
}

@keyframes bar-slide {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(290%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bar.is-indeterminate span {
    width: 100%;
    animation: none;
    opacity: 0.5;
  }
}

.stage-wrap.is-busy {
  opacity: 0.6;
}

.result {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.result h2 {
  margin: 0;
  font-size: 18px;
}

.result-body {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px;
}

.result img {
  max-width: min(100%, 300px);
  height: auto;
  border: 1px solid var(--line);
  background: #fff;
}

.checks {
  flex: 1 1 180px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--mono);
  font-size: 15px;
}

.checks li {
  margin: 0 0 6px;
  padding-left: 26px;
  position: relative;
}

.checks li::before {
  position: absolute;
  left: 0;
  font-weight: 700;
}

.checks .ok::before {
  content: "✓";
  color: var(--teal);
}

.checks .bad {
  color: var(--bad);
}

.checks .bad::before {
  content: "✕";
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.result-actions .primary {
  flex: 1 1 200px;
}

.is-waiting {
  opacity: 0.55;
  pointer-events: none;
}

.error {
  margin: 14px 0 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--bad-tint);
  color: var(--bad);
  font-size: 15px;
}

[hidden] {
  display: none !important;
}

@media (min-width: 600px) {
  h1 {
    font-size: 34px;
  }

  .tool {
    padding: 22px;
  }

  .cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .zoom {
    flex: 1 1 220px;
  }
}

@media (max-width: 380px) {
  .custom {
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .btn {
    transition: background-color 0.15s, border-color 0.15s;
  }
}
