:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #5d6875;
  --line: #d7dde5;
  --panel: #ffffff;
  --paper: #f4f7fa;
  --accent: #116d6e;
  --accent-ink: #ffffff;
  --shadow: 0 18px 44px rgba(23, 32, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input {
  font: inherit;
}

button,
.upload-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  white-space: nowrap;
}

.upload-button {
  min-height: 46px;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(17, 109, 110, 0.18);
}

.upload-button:hover {
  filter: brightness(1.04);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

#downloadButton {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  width: min(1440px, calc(100vw - 32px));
  margin: 16px auto;
  min-height: calc(100vh - 32px);
}

.workspace,
.settings {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.toolbar {
  min-height: 64px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  flex-wrap: wrap;
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  flex: 1;
  min-height: 0;
}

.panel {
  background: #fff;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
}

.panel-head {
  min-height: 66px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}

.panel-head h1,
.panel-head h2 {
  margin: 0 0 4px;
  font-size: 17px;
  line-height: 1.25;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.preview-zoom {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.preview-zoom label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 650;
}

.preview-zoom input {
  width: 100%;
}

.preview-zoom p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 360px;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 16px;
  background: #eef2f6;
}

.canvas-wrap.checker {
  background-color: #eef2f6;
  background-image:
    linear-gradient(45deg, #cfd6de 25%, transparent 25%),
    linear-gradient(-45deg, #cfd6de 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #cfd6de 75%),
    linear-gradient(-45deg, transparent 75%, #cfd6de 75%);
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
}

canvas {
  max-inline-size: 100%;
  max-block-size: calc(100vh - 180px);
  background: transparent;
  image-rendering: auto;
}

#resultCanvas {
  position: absolute;
  inset: 0 auto auto 0;
  max-inline-size: none;
  max-block-size: none;
}

.result-preview-frame {
  position: relative;
  overflow: visible;
}

.empty canvas {
  display: none;
}

#dropHint {
  margin: 0;
  color: var(--muted);
  text-align: center;
  padding: 28px;
  border: 1px dashed #9aa8b7;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.dragging #dropHint {
  border-color: var(--accent);
  color: var(--accent);
}

.settings {
  padding: 16px;
  align-self: stretch;
  min-height: 0;
  overflow: auto;
}

.brand-block {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 4px 0 18px;
  margin: 0 0 18px;
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.brand-block img {
  display: block;
  width: 66.666%;
  max-width: 210px;
  height: auto;
}

.brand-block p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.app-tagline {
  color: var(--ink) !important;
  font-size: 15px !important;
  font-weight: 700;
}

.format-note {
  max-width: 260px;
  padding: 10px 12px;
  border: 1px solid #d7dde5;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted) !important;
  font-size: 12px !important;
  line-height: 1.55 !important;
}

.guide-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.guide-links button {
  min-height: 32px;
  padding: 0 10px;
  border-color: #8cff2f;
  border-width: 2px;
  background: #fbfff7;
  color: var(--ink);
  font-size: 12px;
  box-shadow: 0 0 0 3px rgba(140, 255, 47, 0.16);
}

.guide-links button:hover {
  background: #f1ffe5;
}

.control-bar {
  display: block;
}

.setting-block {
  padding: 0 0 18px;
  margin: 0 0 18px;
  border-bottom: 1px solid var(--line);
}

.setting-block h2,
.setting-block label {
  display: block;
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 650;
}

.color-row,
.check-row {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 500 !important;
}

.color-row input {
  inline-size: 56px;
  block-size: 38px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.check-row {
  justify-content: flex-start;
}

.check-row input {
  inline-size: 18px;
  block-size: 18px;
}

.setting-block button {
  width: 100%;
}

.setting-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.action-block {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.action-block button {
  width: 100%;
  min-height: 42px;
}

.notice-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.notice-card ul {
  margin: 0;
  padding-left: 18px;
}

.notice-card li + li {
  margin-top: 6px;
}

.info-dialog {
  width: min(560px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 10px;
  color: var(--ink);
  background: transparent;
}

.info-dialog::backdrop {
  background: rgba(23, 32, 42, 0.48);
  backdrop-filter: blur(4px);
}

.dialog-panel {
  position: relative;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
}

.dialog-panel h2 {
  margin: 0 42px 12px 0;
  font-size: 18px;
  line-height: 1.3;
}

.dialog-panel ol,
.dialog-panel ul {
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.dialog-panel li + li {
  margin-top: 8px;
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  inline-size: 34px;
  block-size: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 999px;
  font-size: 20px;
  line-height: 1;
}

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

output {
  color: var(--accent);
  font-weight: 700;
}

.status {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

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

  .settings {
    order: -1;
  }
}

@media (min-width: 721px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    height: calc(100vh - 16px);
    min-height: 0;
    margin: 8px auto;
  }

  .toolbar {
    min-height: 54px;
    padding: 8px 12px;
  }

  .panel-head {
    min-height: 58px;
    padding: 10px 14px 8px;
  }

  .panel-head h1,
  .panel-head h2 {
    font-size: 16px;
  }

  .preview-zoom {
    gap: 4px;
    margin-top: 6px;
  }

  .preview-zoom p {
    font-size: 10px;
  }

  .canvas-wrap {
    min-height: 0;
    padding: 10px;
  }

  .settings {
    padding: 12px;
  }

  .brand-block {
    gap: 8px;
    padding-bottom: 12px;
    margin-bottom: 12px;
  }

  .brand-block img {
    max-width: 180px;
  }

  .format-note {
    padding: 8px 10px;
    font-size: 11px !important;
  }

  .setting-block {
    padding-bottom: 12px;
    margin-bottom: 12px;
  }

  .action-block {
    margin-top: 12px;
  }

  .notice-card {
    padding: 10px;
    font-size: 11px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin: 0;
    min-height: 100vh;
    gap: 0;
  }

  .workspace,
  .settings {
    display: contents;
    border-radius: 0;
    box-shadow: none;
  }

  .brand-block {
    order: 1;
    margin: 0;
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--line);
    background: #fff;
  }

  .brand-block img {
    width: min(66.666%, 220px);
    max-width: none;
  }

  .app-tagline {
    max-width: 300px;
    font-size: 15px !important;
  }

  .guide-links {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .guide-links button {
    min-width: 0;
    padding: 0 6px;
    font-size: 11px;
  }

  .toolbar {
    order: 2;
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    min-height: auto;
    gap: 10px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.96);
    border-top: 0;
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
  }

  .toolbar .upload-button,
  .toolbar button {
    width: 100%;
    min-width: 0;
    min-height: 52px;
    padding: 0 14px;
    font-size: 16px;
  }

  #downloadButton {
    font-weight: 700;
  }

  .stage-grid {
    order: 3;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 8px;
    background: var(--paper);
  }

  .panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
  }

  .panel-head {
    min-height: 58px;
    padding: 12px 14px 8px;
  }

  .panel-head h1,
  .panel-head h2 {
    font-size: 16px;
  }

  .canvas-wrap {
    min-height: 300px;
    padding: 12px;
  }

  .preview-zoom {
    margin-top: 8px;
  }

  .preview-zoom label {
    font-size: 12px;
  }

  .preview-zoom p {
    font-size: 10px;
  }

  canvas {
    max-block-size: none;
  }

  .control-bar {
    order: 4;
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 10px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: #eef2f6;
  }

  .setting-block {
    margin: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  .setting-block h2,
  .setting-block label {
    margin-bottom: 8px;
    font-size: 14px;
  }

  .setting-note {
    font-size: 12px;
  }

  .target-block {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
  }

  .target-block h2 {
    grid-column: 1 / -1;
  }

  .target-block .color-row {
    margin: 0;
  }

  .target-block button {
    width: auto;
    min-height: 38px;
  }

  .color-row input {
    inline-size: 48px;
    block-size: 36px;
  }

  .check-row {
    min-height: 36px;
  }

  .status {
    order: 5;
    padding: 12px;
    background: #fff;
    border-top: 1px solid var(--line);
    font-size: 13px;
  }

  .action-block {
    order: 6;
    margin: 0;
    padding: 12px;
    border-top: 1px solid var(--line);
    background: #fff;
  }

  .action-block button {
    min-height: 46px;
    font-size: 15px;
  }

  .notice-card {
    font-size: 11px;
  }

  .info-dialog {
    width: calc(100vw - 20px);
  }

  .dialog-panel {
    padding: 20px 18px;
  }

  .dialog-panel h2 {
    font-size: 17px;
  }

  .dialog-panel ol,
  .dialog-panel ul {
    font-size: 13px;
  }
}
