:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #18202a;
  --muted: #687383;
  --line: #d9e0ea;
  --soft-line: #e9edf3;
  --accent: #2f6fed;
  --accent-ink: #ffffff;
  --accent-hover: #245dce;
  --shadow: 0 18px 50px rgba(26, 37, 55, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  min-height: 100vh;
}

.panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  box-shadow: inset 0 -8px 20px rgba(0, 0, 0, 0.12);
}

.home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
  text-decoration: none;
}

.home-link:hover,
.home-link:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.15;
}

h2 {
  font-size: 19px;
  line-height: 1.2;
}

.brand p,
.toolbar p,
.tile-label span,
.status {
  color: var(--muted);
}

.dropzone {
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 172px;
  border: 2px dashed #b8c5d6;
  border-radius: var(--radius);
  background: #f9fbfd;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.dropzone:hover,
.dropzone.is-dragging {
  background: #eef5ff;
  border-color: var(--accent);
  transform: translateY(-1px);
}

.dropzone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-title {
  font-size: 18px;
  font-weight: 760;
}

.drop-subtitle {
  color: var(--muted);
  font-size: 13px;
}

.control-group {
  display: grid;
  gap: 16px;
  padding-top: 6px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
}

.field > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

input[type="text"],
select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

input[type="text"]:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.14);
}

input[type="range"] {
  accent-color: var(--accent);
}

.color-controls {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 8px;
}

.color-controls input {
  width: 48px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 4px;
}

.secondary-action {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 760;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.secondary-action:hover:not(:disabled) {
  border-color: var(--accent);
  background: #eef5ff;
}

.secondary-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.nested-options {
  display: grid;
  gap: 12px;
  margin-left: 28px;
  padding-left: 14px;
  border-left: 2px solid var(--soft-line);
}

.nested-options[hidden] {
  display: none;
}

.mini-upload {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px dashed #b8c5d6;
  border-radius: var(--radius);
  background: #f9fbfd;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 720;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.mini-upload:hover,
.mini-upload.is-dragging {
  background: #eef5ff;
  border-color: var(--accent);
}

.mini-upload input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.mini-upload small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 560;
}

.check-row,
.grid-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 680;
}

.check-row input,
.grid-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.check-row input:disabled,
.check-row input:disabled + span {
  opacity: 0.5;
}

.primary-action {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  font-weight: 780;
  transition: background 0.18s ease, transform 0.18s ease;
}

.primary-action:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.primary-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.status {
  min-height: 44px;
  font-size: 13px;
}

.copyright {
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  display: grid;
  align-content: start;
  gap: 24px;
  padding: 28px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
}

.preview-tile,
.file-list {
  background: var(--panel);
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
}

.preview-tile {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.preview-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background-color: #eef2f7;
}

.grid-bg {
  background-image:
    linear-gradient(rgba(104, 115, 131, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(104, 115, 131, 0.16) 1px, transparent 1px);
  background-size: 24px 24px;
}

.grid-bg.is-off {
  background-image: none;
}

.preview-stage::after {
  content: "";
  position: absolute;
  inset: 18%;
  border: 1px dashed rgba(24, 32, 42, 0.28);
  pointer-events: none;
}

.preview-stage[data-shape="round"]::after,
.preview-stage[data-shape="adaptive"]::after {
  border-radius: 50%;
}

.preview-stage[data-shape="ios"] canvas {
  border-radius: 24%;
}

.preview-stage canvas {
  display: block;
  width: min(72%, 240px);
  height: min(72%, 240px);
  box-shadow: 0 12px 28px rgba(26, 37, 55, 0.18);
}

.preview-stage[data-shape="round"] canvas,
.preview-stage[data-shape="adaptive"] canvas {
  border-radius: 50%;
}

.tile-label {
  display: grid;
  gap: 2px;
}

.tile-label strong {
  font-size: 14px;
}

.tile-label span {
  font-size: 12px;
}

.file-list {
  display: grid;
  gap: 14px;
  padding: 18px;
}

#fileList {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
}

.file-pack {
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fbfcfe;
}

.file-pack strong {
  display: block;
  margin-bottom: 6px;
}

.file-pack span {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1120px) {
  .preview-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 780px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .controls,
  .workspace {
    padding: 20px;
  }

  .brand-row {
    align-items: flex-start;
  }

  .toolbar {
    align-items: flex-start;
  }

  #fileList {
    grid-template-columns: 1fr;
  }
}

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

  .toolbar {
    flex-direction: column;
  }
}
