:root {
  --bg-0: #f6f8fb;
  --bg-1: #ecf1f7;
  --grid: rgba(30, 41, 59, 0.06);
  --glow: rgba(99, 102, 241, 0.1);
  --surface: rgba(255, 255, 255, 0.78);
  --border: rgba(15, 23, 42, 0.1);
  --text: #0f172a;
  --muted: #5b6b82;
  --btn-bg: #ffffff;
  --btn-border: rgba(15, 23, 42, 0.12);
  --btn-hover: #e9eef5;
  --btn-active: #dce4ee;
  --focus: #6366f1;
  --focus-outer: rgba(99, 102, 241, 0.18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-0: #0b1220;
    --bg-1: #0f172a;
    --grid: rgba(226, 232, 240, 0.07);
    --glow: rgba(56, 189, 248, 0.1);
    --surface: rgba(17, 24, 39, 0.58);
    --border: rgba(148, 163, 184, 0.16);
    --text: #e5e7eb;
    --muted: #a7b1c2;
    --btn-bg: rgba(30, 41, 59, 0.65);
    --btn-border: rgba(148, 163, 184, 0.22);
    --btn-hover: rgba(45, 55, 72, 0.75);
    --btn-active: rgba(55, 65, 81, 0.82);
    --focus: #60a5fa;
    --focus-outer: rgba(96, 165, 250, 0.22);
  }
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  line-height: 1.6;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 6vh 16px 10vh;
  background: radial-gradient(40rem 40rem at 15% 10%, var(--glow), transparent 60%),
    radial-gradient(36rem 36rem at 85% 90%, var(--glow), transparent 65%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1)),
    radial-gradient(circle at 1px 1px, var(--grid) 1px, transparent 1px);
  background-size: auto, auto, 100% 100%, 24px 24px;
  background-attachment: fixed, fixed, fixed, fixed;
}

.panel {
  width: min(820px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 12px 36px rgba(2, 6, 23, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 28px;
}

h2 {
  margin: 0 0 6px;
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.lead {
  text-align: center;
  color: var(--muted);
  margin-bottom: 16px;
}

.row {
  display: grid;
  gap: 18px;
  text-align: center;
}

.actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 6px 0;
}

button,
.file-btn {
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s ease, opacity 0.12s ease, box-shadow 0.12s ease;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button:hover:not(:disabled),
.file-btn:hover {
  background: var(--btn-hover);
}

button:active:not(:disabled),
.file-btn:active {
  background: var(--btn-active);
}

button:focus-visible,
.file-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--focus-outer);
}

/* ====== ÄNDRAT: kolumnlayout för Choose/Upload/filnamn ====== */
.file-input-wrap-col {
  display: flex;
  flex-direction: column;  /* stapla på höjden */
  align-items: center;     /* centrera horisontellt */
  gap: 10px;
}

#fileNote {
  color: var(--muted);
  font-size: 0.95rem;
}

#previewWrap:empty,
#outputs:empty,
#result:empty {
  display: none;
}

/* centrera preview/output */
#previewWrap, #outputs {
  text-align: center;
}

#outputs img, #previewWrap img {
  display: inline-block;
  margin: 10px auto;
}

img {
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-top: 10px;
  background: rgba(0, 0, 0, 0.03);
}

pre {
  margin: 8px auto 0;
  max-width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(148, 163, 184, 0.1);
  text-align: left;
  overflow: auto;
  font-size: 0.92rem;
}

.muted {
  color: var(--muted);
}

#status {
  margin-top: 2px;
}

#outputs > div {
  margin: 14px 0;
}

#modeSelect {
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s ease, box-shadow 0.12s ease;
  max-width: 160px;
  margin-left: 8px;
}

#modeSelect:hover {
  background: var(--btn-hover);
}

#modeSelect:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--focus-outer);
}

#status.error { color: #b91c1c; } /* röd text vid fel */
