:root {
  --bg: #ffffff;
  --paper: #ffffff;
  --ink: #111111;
  --muted: #7b7b7b;
  --line: #e8e8e8;
  --accent: #111111;
  --upload: #ededed;
  --danger: #b02020;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
}

.page {
  width: min(640px, calc(100% - 24px));
  margin: 0 auto;
  padding: 12px 0 24px;
}

.sample-strip {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.sample-card,
.panel,
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.sample-card {
  position: relative;
  margin: 0;
  aspect-ratio: 1.45 / 1;
  overflow: hidden;
}

.sample-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sample-arrow {
  position: absolute;
  display: grid;
  place-items: center;
  color: #111111;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.sample-arrow {
  top: 50%;
  left: 50%;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  font-size: 24px;
  z-index: 2;
}

.panel {
  padding: 12px;
}

.form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.upload {
  display: inline-flex;
  min-width: 0;
  flex: 0 0 auto;
  cursor: pointer;
}

.upload input {
  display: none;
}

.upload-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--upload);
  color: #111111;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.upload-trigger .material-symbols-outlined {
  font-size: 24px;
}

.file-name {
  flex: 1 1 auto;
  min-width: 0;
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfbfb;
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

button {
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  padding: 13px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  text-transform: lowercase;
}

button:hover {
  opacity: 0.88;
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.status,
.error {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.92rem;
}

.status {
  background: #f6f6f6;
  color: #333333;
  min-height: 54px;
}

#status-text {
  min-height: 1.2em;
}

.progress {
  margin-top: 8px;
  width: 100%;
  height: 8px;
  overflow: hidden;
  background: #e8e8e8;
  border-radius: 999px;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: #111111;
  transition: width 0.7s ease;
}

.error {
  background: #fff0f0;
  color: var(--danger);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.card {
  padding: 12px;
}

.frame {
  position: relative;
  min-height: 280px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #fafafa;
  border-radius: 18px;
  border: 1px solid var(--line);
}

.frame-clickable {
  cursor: pointer;
}

.frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

#output-preview {
  cursor: zoom-in;
}

.placeholder {
  padding: 20px;
  color: var(--muted);
  text-align: center;
  text-transform: lowercase;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 56px 16px 88px;
  background: rgba(255, 255, 255, 0.97);
}

.lightbox-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.lightbox-close,
.lightbox-download {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
  background: #111111;
  color: #ffffff;
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

.lightbox-close {
  top: 14px;
  right: 14px;
  border: 0;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.lightbox-download {
  bottom: 18px;
  left: 50%;
  padding: 0 18px;
  transform: translateX(-50%);
  font-size: 0.95rem;
  font-weight: 700;
}

@media (max-width: 860px) {
  .page {
    width: min(640px, calc(100% - 12px));
    padding: 6px 0 16px;
  }

  .sample-strip,
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .sample-arrow {
    width: 36px;
    height: 36px;
    font-size: 20px;
  }

  .panel,
  .card {
    border-radius: 16px;
  }

  .sample-card,
  .frame {
    border-radius: 14px;
  }

  .frame {
    min-height: 180px;
  }

  .form {
    gap: 8px;
  }

  button {
    padding: 12px 14px;
  }
}
