:root {
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Noto Sans JP",
    sans-serif;
  color: #17243a;
  background: #fff;
  font-size: 16px;
  --blue: #165dcc;
  --border: #dce3ed;
  --muted: #536279;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select {
  font: inherit;
}
button,
select,
input[type="text"],
input[type="number"] {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: inherit;
  padding: 10px 13px;
}
button {
  cursor: pointer;
  font-weight: 600;
}
button:hover {
  background: #eef4ff;
  border-color: #a8bfe2;
}
button:disabled {
  cursor: wait;
  opacity: 0.55;
}
button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}
button.primary:hover {
  background: #104da9;
}
a {
  color: inherit;
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
canvas:focus-visible,
a:focus-visible {
  outline: 3px solid #ef9c13;
  outline-offset: 3px;
}
input[type="range"] {
  accent-color: var(--blue);
  width: 100%;
  min-height: 38px;
  cursor: pointer;
}
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
  vertical-align: middle;
}
input[type="color"] {
  width: 40px;
  height: 32px;
  border: 1px solid var(--border);
  padding: 2px;
  background: white;
}
label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin: 16px 0 7px;
}
select,
input[type="text"],
input[type="number"] {
  width: 100%;
}
h1,
h2,
p {
  margin: 0;
}
h1 {
  font-size: clamp(1.65rem, 3vw, 2.2rem);
  letter-spacing: -0.04em;
  line-height: 1.3;
}
h2 {
  font-size: 1rem;
}
p {
  line-height: 1.7;
}
main {
  max-width: 1540px;
  margin: auto;
  padding: 32px 32px 20px;
}
.top {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.brand-mark {
  display: grid;
  place-items: center;
  background: var(--blue);
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 20px;
}
.free {
  font-size: 0.875rem;
  color: var(--muted);
}
#install {
  margin-left: auto;
}
.intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.intro p:not(.eyebrow) {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 9px;
}
.eyebrow {
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  margin-bottom: 7px;
}
.local-badge {
  font-size: 0.875rem;
  font-weight: 600;
  color: #155949;
  background: #eaf6f0;
  padding: 8px 14px;
  border-radius: 30px;
  white-space: nowrap;
}
.privacy {
  margin: 22px 0;
  color: #225548;
  background: #f1f8f4;
  border: 1px solid #d3e8dc;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.875rem;
}
.privacy span {
  margin-right: 6px;
}
.upload {
  margin: 30px 0 50px;
  text-align: center;
  padding: 60px 20px;
  border: 2px dashed #c7d5e8;
  background: #f8faff;
  border-radius: 16px;
}
.upload.drag {
  border-color: var(--blue);
  background: #edf3ff;
}
.upload-icon {
  color: var(--blue);
  font-size: 36px;
  background: #e9f0ff;
  width: 68px;
  height: 68px;
  margin: 0 auto 20px;
  border-radius: 16px;
  line-height: 68px;
}
.upload h2 {
  font-size: 1.35rem;
  margin-bottom: 8px;
}
.upload p {
  color: var(--muted);
  font-size: 0.875rem;
}
.upload button {
  margin: 22px 0 12px;
  padding: 12px 36px;
}
.small {
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.65;
  margin-top: 10px;
  overflow-wrap: anywhere;
}
.sourcebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 18px;
}
.sourcebar strong {
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}
.sourcebar p {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 4px;
}
.button-row {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.workspace {
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr) 280px;
  gap: 18px;
  align-items: start;
}
.panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  background: #fff;
  min-width: 0;
}
.panel-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 18px;
}
.step {
  display: grid;
  place-items: center;
  color: var(--blue);
  background: #ecf2ff;
  width: 25px;
  height: 25px;
  border-radius: 7px;
  font-size: 0.8125rem;
  font-weight: 700;
  flex-shrink: 0;
}
.meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-left: auto;
}
.preset-list {
  max-height: 660px;
  overflow: auto;
  scrollbar-width: thin;
}
.group-title {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  margin: 17px 0 7px;
  letter-spacing: 0.03em;
}
.group-title:first-child {
  margin-top: 0;
}
.preset-btn {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  padding: 9px 10px;
  display: block;
  margin: 3px 0;
  font-size: 0.875rem;
  min-height: 58px;
  font-weight: 500;
}
.preset-btn small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 3px;
}
.preset-btn[aria-pressed="true"] {
  background: #edf3ff;
  border-color: #bfd2f7;
  color: #154d9d;
}
.stage {
  min-height: 360px;
  height: 460px;
  background: #f0f3f8;
  border-radius: 10px;
  padding: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.frame {
  position: relative;
  box-shadow: 0 4px 20px #14244325;
  background-color: white;
  background-image: conic-gradient(
    #e3e5e8 25%,
    transparent 0 50%,
    #e3e5e8 0 75%,
    transparent 0
  );
  background-size: 16px 16px;
  flex-shrink: 0;
}
canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
canvas:active {
  cursor: grabbing;
}
.safe-area {
  position: absolute;
  border: 2px dashed #f6c64a;
  background: #ffc40009;
  pointer-events: none;
  box-shadow: 0 0 0 1px #17243a70;
}
.safe-area span {
  position: absolute;
  top: 5px;
  left: 5px;
  background: #17243ada;
  color: white;
  padding: 3px 6px;
  border-radius: 3px;
  font-size: 0.6875rem;
  max-width: calc(100% - 10px);
}
.hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 12px 0;
}
.zoom-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.zoom-row label {
  white-space: nowrap;
  margin: 0;
}
.zoom-row output {
  min-width: 46px;
  font-size: 0.8125rem;
  text-align: right;
}
.tools {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 10px;
}
.tools button {
  padding: 8px 3px;
  font-size: 0.8125rem;
}
.guide-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.guide-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  margin: 16px 0 0;
}
.output-info {
  background: #f6f8fb;
  border-radius: 10px;
  padding: 14px;
  margin: 20px 0 14px;
}
dl {
  margin: 0;
}
dl div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.8125rem;
  margin: 0 0 12px;
}
dl div:last-child {
  margin: 0;
}
dt {
  color: var(--muted);
}
dd {
  margin: 0;
  text-align: right;
  font-weight: 600;
}
.savings {
  font-size: 0.8125rem;
  color: #17604d;
  margin-top: 12px;
}
.full {
  width: 100%;
  margin-top: 8px;
}
#qualityValue {
  float: right;
}
.batch {
  margin-top: 24px;
}
.batch-heading {
  display: flex;
  align-items: center;
  gap: 12px;
}
.batch-heading > div {
  flex: 1;
}
.batch-heading h2 {
  font-size: 1.2rem;
}
.batch-heading p:not(.eyebrow) {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 6px;
}
.batch-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 22px 0;
}
.batch-item {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.batch-item label {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 0.8125rem;
  cursor: pointer;
}
.batch-item label small {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
  margin-top: 4px;
}
.batch-item button {
  font-size: 0.75rem;
  padding: 8px;
  min-width: 44px;
}
.batch-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.batch-footer span {
  font-size: 0.875rem;
  color: var(--muted);
}
progress {
  width: 100%;
  margin-top: 15px;
  accent-color: var(--blue);
}
#batchStatus {
  font-size: 0.875rem;
  margin-top: 10px;
}
.help {
  font-size: 0.875rem;
  line-height: 1.8;
  margin: 30px 0;
  color: var(--muted);
}
summary {
  cursor: pointer;
  min-height: 44px;
  padding: 10px 0;
  color: #263954;
  font-weight: 600;
}
.help p {
  margin-top: 12px;
}
.help ol {
  padding-left: 22px;
}
footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding: 20px 32px;
  font-size: 0.8125rem;
  color: var(--muted);
}
.message {
  padding: 14px 18px;
  border: 1px solid #f1beb8;
  background: #fff1ee;
  color: #8f291d;
  border-radius: 10px;
  margin-bottom: 18px;
}
.mobile-only {
  display: none;
}
[hidden] {
  display: none !important;
}
@media (min-width: 1450px) {
  .workspace {
    grid-template-columns: 250px minmax(0, 1fr) 300px;
  }
  .stage {
    height: 540px;
  }
}
@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 190px minmax(0, 1fr) 240px;
    gap: 12px;
  }
  .panel {
    padding: 14px;
  }
  main {
    padding: 24px 18px;
  }
  .stage {
    height: 380px;
    min-height: 300px;
    padding: 14px;
  }
  .batch-list {
    grid-template-columns: repeat(3, 1fr);
  }
  .tools {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 800px) {
  .top {
    padding: 15px 16px;
    gap: 10px;
    flex-wrap: wrap;
  }
  .brand {
    font-size: 0.875rem;
  }
  .free {
    font-size: 0.75rem;
  }
  main {
    padding: 24px 16px 10px;
  }
  .intro {
    align-items: flex-start;
  }
  .local-badge {
    display: none;
  }
  .intro p:not(.eyebrow) {
    font-size: 0.8125rem;
  }
  .privacy {
    font-size: 0.8125rem;
    margin: 18px 0;
  }
  .upload {
    padding: 38px 12px;
    margin: 20px 0 30px;
  }
  .upload h2 {
    font-size: 1.15rem;
  }
  .workspace {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }
  .panel {
    width: 100%;
    padding: 18px;
  }
  .preset-list {
    display: none;
  }
  .mobile-only {
    display: block;
  }
  .sourcebar {
    align-items: flex-start;
    flex-direction: column;
  }
  .sourcebar .button-row {
    width: 100%;
  }
  .sourcebar button {
    flex: 1;
  }
  .stage {
    height: 370px;
    padding: 14px;
  }
  .editor {
    order: 2;
  }
  .presets {
    order: 1;
  }
  .output {
    order: 3;
  }
  .tools {
    grid-template-columns: repeat(2, 1fr);
  }
  .batch-heading {
    flex-wrap: wrap;
  }
  .batch-heading > div {
    flex-basis: 100%;
  }
  .batch-list {
    grid-template-columns: repeat(2, 1fr);
  }
  .batch-item {
    flex-wrap: wrap;
  }
  .batch-item button {
    width: 100%;
  }
  .batch-footer {
    align-items: stretch;
    flex-direction: column;
  }
  .batch-footer button {
    width: 100%;
  }
  footer {
    padding: 18px 16px;
    flex-wrap: wrap;
  }
  #install {
    font-size: 0.75rem;
    padding: 8px;
  }
  .safe-area span {
    font-size: 0.625rem;
  }
}
@media (max-width: 400px) {
  .batch-list {
    grid-template-columns: 1fr;
  }
  .batch-item {
    flex-wrap: nowrap;
  }
  .batch-item button {
    width: auto;
  }
  .stage {
    height: 330px;
  }
  .meta {
    font-size: 0.6875rem;
  }
}
@media (prefers-reduced-motion: no-preference) {
  button {
    transition:
      background 0.15s,
      border-color 0.15s;
  }
}
/* WebKitの長いselect選択肢が親のスクロール幅へ影響することを防ぐ。 */
@media (max-width: 800px) {
  .presets {
    overflow: hidden;
  }
  #presetSelect {
    min-width: 0;
    max-width: 100%;
  }
}


/* Pro版への案内 */
.pro-ad {
  width: 100%;
  max-width: 420px;
  margin: 34px auto 24px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(23, 36, 58, 0.08);
  text-align: center;
}
.pro-ad-label {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 0.8125rem;
  font-weight: 700;
}
.pro-ad a {
  display: block;
  text-decoration: none;
}
.pro-ad img {
  display: block;
  width: 100%;
  max-width: 300px;
  height: auto;
  margin: 0 auto;
  border-radius: 9px;
}
.pro-ad-copy {
  margin-top: 12px;
  color: #17243a;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.5;
}
.pro-ad-link {
  display: inline-block;
  margin-top: 7px;
  color: var(--blue);
  font-size: 0.8125rem;
  font-weight: 700;
}
@media (max-width: 480px) {
  .pro-ad {
    max-width: 340px;
    padding: 12px;
  }
  .pro-ad img {
    max-width: 280px;
  }
}
