:root {
  --bg: #f3f3eb;
  --surface: #ffffff;
  --ink: #1d1d1b;
  --muted: #5b5b55;
  --line: #dcdcd2;
  --accent: #1d1d1b;
  --accent-ink: #ffffff;
  --focus: #2f6fdf;
  --warn-bg: #fff4d6;
  --warn-line: #e7c25a;
  --bad: #c4211b;
  --radius: 8px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1, h2 { margin: 0; line-height: 1.2; }
h2 { font-size: 16px; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .92em; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px;
  background: var(--ink); color: var(--bg); font-weight: 800; font-size: 13px; letter-spacing: .04em;
}
.brand-logo { display: flex; align-items: center; text-decoration: none; }
.brand-logo img { display: block; height: 40px; width: auto; max-width: 220px; }
.brand-text { border-left: 1px solid var(--line); padding-left: 14px; }
.brand h1 { font-size: 18px; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Knapper */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 8px 14px; border: 1px solid var(--ink); border-radius: 6px;
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { background: #3a3a36; }
.btn-small { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.icon-btn {
  width: 28px; height: 28px; padding: 0; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--muted); font: inherit; font-size: 15px; cursor: pointer; line-height: 1;
}
.icon-btn:hover:not(:disabled) { border-color: var(--line); color: var(--ink); background: var(--bg); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.link-btn { border: 0; background: none; padding: 4px 0; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; text-decoration: underline; }
.link-btn:hover { color: var(--ink); }

/* Layout */
.layout {
  display: grid; grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); gap: 24px;
  padding: 24px; max-width: 1800px; margin: 0 auto;
}
.panel { display: flex; flex-direction: column; gap: 24px; }
.panel > section, .card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
}
.panel > section > h2 { margin-bottom: 12px; }
.content { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head .hint { margin: 0; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* Farveliste */
.color-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.color { border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.color-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) 92px; gap: 6px; align-items: center; }
.color-tools { grid-column: 1 / -1; display: flex; align-items: center; gap: 2px; justify-content: flex-end; }
.swatch { width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
.swatch::-webkit-color-swatch-wrapper { padding: 2px; }
.swatch::-webkit-color-swatch { border: 0; border-radius: 4px; }
input[type="text"], input[type="number"], select, textarea {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0;
}
.hex { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.invalid { border-color: var(--bad) !important; background: #fff2f1; }
.role { display: inline-flex; align-items: center; cursor: pointer; margin-right: 4px; }
.role input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.role span {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--line); font-size: 12px; font-weight: 700; color: var(--muted);
}
.role input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.role input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.alphas { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.alpha { display: flex; align-items: center; gap: 6px; font-size: 13px; padding-left: 40px; }
.alpha-pct { width: 58px; }
.alpha-under { flex: 1 1 auto; max-width: 140px; }
.alpha-hex { white-space: nowrap; font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--muted); font-size: 12px; }
.add-alpha { margin: 4px 0 0 40px; }
.warn {
  margin-top: 8px; padding: 8px 10px; border: 1px solid var(--warn-line); background: var(--warn-bg);
  border-radius: 6px; font-size: 13px;
}
.warn .btn { display: flex; margin-top: 6px; }
.paste-box { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.paste-box label { font-size: 13px; color: var(--muted); }
.paste-box textarea { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

/* Visning */
.levels { border: 0; padding: 0; margin: 0 0 12px; display: flex; gap: 14px; flex-wrap: wrap; }
.levels legend { font-size: 13px; color: var(--muted); margin-bottom: 6px; padding: 0; }
.levels label, .check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.check { margin-top: 12px; }
.segmented { display: inline-flex; border: 1px solid var(--ink); border-radius: 6px; overflow: hidden; }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented span { display: block; padding: 6px 18px; font-weight: 600; font-size: 14px; }
.segmented input:checked + span { background: var(--ink); color: var(--bg); }
.segmented input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: -3px; }

/* Indhold */
.notice {
  display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
  background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--radius); padding: 12px 14px;
}
.notice p { margin: 0; font-size: 14px; }
#preview { min-height: 60px; }
#preview .ncm-cg { margin: 0; }
#export-code { width: 100%; min-height: 120px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; resize: vertical; }

.footer { max-width: 1800px; margin: 0 auto; padding: 0 24px 32px; color: var(--muted); font-size: 13px; }
.footer p { margin: 4px 0; max-width: 860px; }
.noscript { padding: 24px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
  .topbar { padding: 12px 16px; position: static; }
  .footer { padding: 0 16px 24px; }
}

/* Konvertér gammelt link (diskret, i footeren) */
.footer .link-btn { font-size: 13px; }
.convert-box { margin-top: 10px; max-width: 860px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.convert-box label { display: block; font-size: 13px; margin-bottom: 6px; }
.convert-row { display: flex; gap: 8px; }
.convert-row input { flex: 1 1 auto; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
#convert-result { margin-top: 4px; }
#notices:empty { display: none; }
@keyframes ncm-flash { from { box-shadow: 0 0 0 3px var(--focus); } to { box-shadow: 0 0 0 3px transparent; } }
#export.flash { animation: ncm-flash 1.2s ease-out; }

.hint-inline { color: var(--muted); font-size: 12px; }
.check { display: flex; flex-wrap: wrap; }
