:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --text: #1f2328;
  --muted: #5c636b;
  --border: #dcdad5;
  --accent: #1f4e79;
  --accent-text: #ffffff;
  --error-bg: #fdecec;
  --error-border: #d64545;
  --warn-bg: #fff6e0;
  --warn-border: #d29b1d;
  --info-bg: #eaf2fb;
  --info-border: #4a7fb5;
  --radius: 10px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17191c;
    --panel: #212428;
    --text: #e8e6e3;
    --muted: #a3a8ae;
    --border: #3a3e44;
    --accent: #6ea8de;
    --accent-text: #0d1b29;
    --error-bg: #3a1f1f;
    --warn-bg: #3a3020;
    --info-bg: #1f2c3a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

.site-header, .layout, .site-footer {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px;
}

.site-header { padding-top: 32px; padding-bottom: 16px; }
.site-header h1 { margin: 0 0 4px; font-size: 1.75rem; }
.tagline { margin: 0; color: var(--muted); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.field { margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-row .field { margin-bottom: 12px; }

label, .label { display: block; font-weight: 600; margin-bottom: 6px; }
label.check { font-weight: 400; display: flex; align-items: center; gap: 8px; min-height: 40px; }

input[type="text"], select {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

input[type="text"] { font-size: 1.05rem; }
input[type="text"]:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

input[type="color"] {
  width: 64px; height: 40px; padding: 2px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
}

.hint { margin: 6px 0 0; font-size: 0.875rem; color: var(--muted); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; }

.options { border-top: 1px solid var(--border); padding-top: 12px; }
.options summary { cursor: pointer; font-weight: 600; margin-bottom: 12px; }

.messages { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.messages:empty { display: none; }
.msg {
  padding: 10px 12px;
  border-radius: 8px;
  border-left: 4px solid;
  font-size: 0.925rem;
}
.msg-error { background: var(--error-bg); border-color: var(--error-border); }
.msg-warn  { background: var(--warn-bg);  border-color: var(--warn-border); }
.msg-info  { background: var(--info-bg);  border-color: var(--info-border); }

.link-button {
  display: inline-block;
  margin-left: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.placeholder {
  min-height: 320px;
  display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--border); border-radius: var(--radius);
  color: var(--muted); text-align: center; padding: 20px;
}

.canvas-wrap {
  display: flex; justify-content: center;
  padding: 12px;
  border-radius: 8px;
  background: #ffffff;
}
.canvas-wrap.checker {
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #ddd 25%, transparent 25%),
    linear-gradient(-45deg, #ddd 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ddd 75%),
    linear-gradient(-45deg, transparent 75%, #ddd 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.canvas-wrap canvas { max-width: 100%; height: auto; }

.encoded { margin: 16px 0; }
.encoded code {
  display: block;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  word-break: break-all;
}
.meta { display: block; margin-top: 4px; font-size: 0.8rem; color: var(--muted); }

.buttons { display: flex; flex-wrap: wrap; gap: 8px; }
button {
  font: inherit;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.link-button { border: 0; padding: 0; background: none; color: var(--accent); }

.status { min-height: 1.5em; margin: 8px 0 0; font-size: 0.9rem; color: var(--muted); }

.checklist {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--info-bg);
  font-size: 0.9rem;
}
.checklist ul { margin: 6px 0 0; padding-left: 20px; }
.checklist li { margin-bottom: 4px; }

.site-footer { padding-top: 24px; padding-bottom: 40px; color: var(--muted); font-size: 0.875rem; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

[hidden] { display: none !important; }
