:root {
  --bg: #101114;
  --panel: #181a1f;
  --text: #e7e8ec;
  --muted: #9b9ea8;
  --accent: #8d7dff;
  --border: #2a2d36;
  --danger: #ff6b7a;
  --radius: 8px;
  --controls-w: 332px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
}

body {
  min-height: 100dvh;
  overflow: auto;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.brand img {
  display: block;
  width: 22px;
  height: 22px;
}

.tagline {
  margin: 0;
  color: var(--muted);
  flex: 1;
}

.top-actions {
  margin-left: auto;
}

.workspace {
  display: flex;
  flex: 1;
  min-height: 0;
}

.preview-pane {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  background:
    radial-gradient(ellipse at 30% 20%, #1a1c24 0%, transparent 55%),
    radial-gradient(ellipse at 80% 80%, #14161c 0%, transparent 50%),
    var(--bg);
  overflow: hidden;
}

.drop-hint {
  text-align: center;
  padding: 2rem 1.25rem;
  color: var(--text);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.drop-hint p {
  margin: 0.35rem 0;
}

.drop-hint .muted,
.muted {
  color: var(--muted);
}

.preview-pane.dragover {
  outline: 2px dashed var(--accent);
  outline-offset: -8px;
}

#preview {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* display:block above must not defeat the hidden attribute */
#preview[hidden] {
  display: none;
}

.error {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  margin: 0;
  padding: 0.65rem 0.85rem;
  background: #2a1518;
  color: var(--danger);
  border-radius: var(--radius);
  border: 1px solid #5a2430;
}

.controls {
  width: var(--controls-w);
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 0.65rem 0.75rem 1.25rem;
}

.presets {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.presets > label {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: none;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.row select,
.format select {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.45rem;
  font: inherit;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 6px;
  padding: 0.4rem 0.65rem;
  font: inherit;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: #fff;
}

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

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

.btn.primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn.tiny {
  padding: 0.2rem 0.45rem;
  font-size: 0.75rem;
}

.btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

.section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  background: #14161b;
}

.section > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
}

.section > summary::-webkit-details-marker {
  display: none;
}

.section[open] > summary {
  border-bottom: 1px solid var(--border);
}

.section > *:not(summary) {
  margin: 0.55rem 0.65rem;
}

.swaps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.matrix {
  display: grid;
  grid-template-columns: 3.2rem repeat(3, 1fr);
  gap: 0.3rem 0.25rem;
  align-items: center;
  font-size: 0.72rem;
}

.matrix-head,
.matrix-label {
  color: var(--muted);
}

.slider-cell {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.slider-cell input[type="range"],
.slider input[type="range"],
.quality input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.slider-cell .val,
.slider .val,
.quality .val {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.72rem;
}

.slider {
  display: grid;
  grid-template-columns: 5.5rem 1fr 2.2rem;
  align-items: center;
  gap: 0.35rem;
}

.slider > span:first-child {
  color: var(--muted);
  font-size: 0.8rem;
}

.tint-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.tint-row input[type="color"] {
  width: 2.2rem;
  height: 1.6rem;
  padding: 0;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
}

.export-bar {
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 0.7rem 1rem 0.85rem;
}

.export-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

.format {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
}

.quality {
  flex: 1;
  max-width: 280px;
  grid-template-columns: 3.5rem 1fr 2rem;
}

.export-meta {
  margin-top: 0.45rem;
}

.export-note,
.exif-note,
.export-scale,
.export-progress {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.export-scale,
.export-progress {
  color: var(--text);
}

.credit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0.85rem 1rem 1.1rem;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.credit a {
  color: var(--text);
  text-decoration: none;
}

.credit a:hover {
  color: var(--accent);
}

.credit-mark {
  display: inline-flex;
  align-items: center;
  line-height: 0;
}

.credit-mark span {
  display: inline-block;
  width: 22px;
  height: 22px;
  background-color: #fff;
  -webkit-mask: url("/images/griffin.svg") center / contain no-repeat;
  mask: url("/images/griffin.svg") center / contain no-repeat;
  transition: background-color 0.3s ease;
}

.credit-mark:hover span {
  background-color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  .credit-mark span {
    transition: none;
  }
}

@media (max-width: 760px) {
  .workspace {
    flex-direction: column;
  }

  .preview-pane {
    flex: none;
    height: 60vh;
    min-height: 280px;
  }

  .controls {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: none;
  }

  .tagline {
    flex-basis: 100%;
    order: 3;
  }

  .top-actions {
    margin-left: 0;
  }
}
