:root {
  --text: #0f172a;
  --muted: #64748b;
  --line: rgba(15, 23, 42, 0.12);
  --panel: rgba(255, 255, 255, 0.86);
  --accent: #2563eb;
  --ok: #15803d;
  --bad: #b91c1c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), transparent 32rem),
    linear-gradient(180deg, #f8fafc, #eef2ff);
}

.shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.manage-shell { width: min(1280px, calc(100% - 32px)); }

.top-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 18px;
}

.back-link {
  display: inline-block;
  color: #334155;
  text-decoration: none;
}

.back-link:hover { color: var(--accent); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(18px);
  padding: clamp(22px, 4vw, 40px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 { margin: 0 0 10px; font-size: clamp(28px, 5vw, 44px); line-height: 1; }
p { color: var(--muted); line-height: 1.6; }
code { background: rgba(15, 23, 42, 0.06); padding: 2px 5px; }

.form { display: grid; gap: 18px; margin-top: 28px; }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.optional-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 14px; }

label { display: grid; gap: 7px; }
label span, summary { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; }

input,
select {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  padding: 0 12px;
  font: inherit;
  color: var(--text);
  outline: none;
}

select { cursor: pointer; }
input:read-only { color: var(--muted); background: rgba(15, 23, 42, 0.04); }
input:focus, select:focus { border-color: rgba(37, 99, 235, 0.65); }
input[type="color"] { padding: 4px; }

.dropzone {
  border: 1px dashed rgba(37, 99, 235, 0.45);
  background: rgba(37, 99, 235, 0.05);
  padding: 18px;
}

.dropzone input { padding: 10px 0 0; height: auto; border: 0; background: transparent; }

button {
  height: 50px;
  border: 0;
  background: #0f172a;
  color: white;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover { background: #1e293b; }
button:disabled { opacity: 0.55; cursor: wait; }

.secondary-button {
  background: white;
  color: var(--text);
  border: 1px solid var(--line);
}
.secondary-button:hover { background: #f8fafc; }

.danger-button {
  background: #b91c1c;
  color: white;
}
.danger-button:hover { background: #991b1b; }

.compact-action {
  min-width: 0;
  height: 40px;
  padding: 0 12px;
}

.hidden-file-input {
  display: none;
}

.manage-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.manage-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(100%, 420px);
}

.search { min-width: 0; }

.manage-summary {
  margin-top: 22px;
  color: var(--muted);
  font-weight: 700;
}

.sketch-list {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.group-editor-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.group-editor-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
  padding: 14px;
}

.sketch-editor-card {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
  padding: 14px;
}

.sketch-editor-card.dirty {
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: inset 4px 0 0 rgba(37, 99, 235, 0.75);
}

.sketch-preview {
  display: block;
  min-height: 140px;
  background-color: rgba(15, 23, 42, 0.08);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  border: 1px solid var(--line);
}

.sketch-editor-form { display: grid; gap: 14px; }

.editor-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.editor-heading strong { font-size: 18px; }
.editor-heading small { color: var(--muted); word-break: break-all; }

.editor-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.upload-grid .wide-field { grid-column: span 1; }

.editor-grid label { min-width: 0; }
.editor-grid input { height: 40px; }
.wide-field { grid-column: span 3; }

.editor-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.open-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.save-button { min-width: 130px; }
.empty-manage {
  border: 1px dashed var(--line);
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.status {
  margin-top: 20px;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.04);
  padding: 16px;
  color: #334155;
}
.status.success { border-color: rgba(21, 128, 61, 0.35); color: var(--ok); background: rgba(21, 128, 61, 0.06); }
.status.error { border-color: rgba(185, 28, 28, 0.35); color: var(--bad); background: rgba(185, 28, 28, 0.06); }

@media (max-width: 900px) {
  .manage-intro, .manage-actions { display: grid; align-items: stretch; }
  .sketch-editor-card { grid-template-columns: 1fr; }
  .sketch-preview { min-height: 220px; }
  .editor-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wide-field { grid-column: span 2; }
}

@media (max-width: 760px) {
  .grid, .optional-grid, .editor-grid { grid-template-columns: 1fr; }
  .wide-field { grid-column: span 1; }
  .editor-heading, .editor-actions { align-items: stretch; flex-direction: column; }
}
