* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: "Corbel", "Nirmala UI", "Yu Gothic UI", "Meiryo", sans-serif;
  background: #1e1e22;
  color: #e8e8ea;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.2px;
}

header {
  padding: 20px 32px 12px;
  border-bottom: 1px solid #2e2e34;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #1e1e22;
  z-index: 100;
}

footer {
  text-align: center;
  padding: 14px 32px;
  border-top: 1px solid #2e2e34;
  background: #1e1e22;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
}
footer a {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #8a8a92;
  font-size: 11px;
  text-decoration: none;
  letter-spacing: 0.5px;
  transition: color 0.15s, opacity 0.15s;
  opacity: 0.85;
}
footer a:hover {
  color: #6b8cff;
  opacity: 1;
}
footer img {
  height: 22px;
  width: auto;
  display: block;
}
header h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
header .sub {
  font-size: 12px;
  color: #8a8a92;
  margin-top: 4px;
}

main {
  padding: 24px 32px 80px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 880px;
  margin: 0 auto;
  margin-top: 88px;
  width: 100%;
}

.dropzone {
  border: 2px dashed #3a3a42;
  border-radius: 14px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s ease;
  background: #23232a;
}
.dropzone:hover,
.dropzone.drag {
  border-color: #6b8cff;
  background: #262733;
}
.dz-icon { font-size: 48px; margin-bottom: 12px; }
.dz-text { font-size: 16px; font-weight: 500; }
.dz-sub { font-size: 12px; color: #7a7a82; margin-top: 6px; }

.result {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) 1.2fr;
  gap: 24px;
}
.result.hidden { display: none; }

.preview {
  background: #23232a;
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.preview-stage {
  width: 100%;
  display: flex;
  justify-content: center;
}
.preview-stage img,
.preview-stage canvas {
  max-width: 100%;
  max-height: 480px;
  border-radius: 8px;
  object-fit: contain;
  background: #0f0f12;
  cursor: zoom-in;
  transition: transform 0.15s;
}
.preview-stage img:hover,
.preview-stage canvas:hover {
  transform: scale(1.01);
}
.hidden { display: none !important; }
.filename {
  font-size: 12px;
  color: #8a8a92;
  word-break: break-all;
  text-align: center;
}
.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}
.btn-row button {
  background: #6b8cff;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  font-family: inherit;
}
.btn-row button:hover:not(:disabled) {
  background: #5a7bee;
}
.btn-row button:disabled {
  background: #3a3a42;
  color: #6a6a72;
  cursor: default;
}
.btn-row button.ghost {
  background: transparent;
  border: 1px solid #3a3a42;
  color: #b5b5bd;
}
.btn-row button.ghost:hover:not(:disabled) {
  background: #2e2e34;
}
.btn-row button.batch {
  background: #3ea170;
  padding: 10px 24px;
}
.btn-row button.batch:hover:not(:disabled) {
  background: #348f61;
}
.batch-row {
  margin-top: 6px;
}
.batch-hint {
  font-size: 11px;
  color: #8a8a92;
  text-align: center;
  margin-top: 6px;
  line-height: 1.5;
}
.batch-hint strong {
  color: #b5d8c0;
  font-weight: 600;
}

.exif {
  background: #23232a;
  border-radius: 14px;
  padding: 20px 24px;
}
.exif h2 {
  font-size: 14px;
  font-weight: 600;
  color: #b5b5bd;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 14px;
}
.exif table {
  width: 100%;
  border-collapse: collapse;
}
.exif th,
.exif td {
  text-align: left;
  padding: 10px 6px;
  border-bottom: 1px solid #2e2e34;
  font-size: 14px;
}
.exif th {
  width: 42%;
  color: #8a8a92;
  font-weight: 500;
}
.exif td {
  color: #e8e8ea;
  font-family: "Consolas", "Menlo", monospace;
}

.exif label { cursor: pointer; }
.exif-check {
  accent-color: #6b8cff;
  margin-right: 4px;
  vertical-align: middle;
}

.settings {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #2e2e34;
}
.settings h3 {
  font-size: 12px;
  font-weight: 600;
  color: #b5b5bd;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}
.style-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  margin-bottom: 10px;
}
.style-options label {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.style-options input[type="radio"] { accent-color: #6b8cff; }

.overlay-options {
  background: #1a1a20;
  border-radius: 8px;
  padding: 12px;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.opt-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
}
.opt-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #b5b5bd;
}
.opt-row input[type="color"] {
  width: 32px;
  height: 24px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
}
.opt-row input[type="range"] {
  accent-color: #6b8cff;
  width: 110px;
}
.opt-row select {
  background: #23232a;
  color: #e8e8ea;
  border: 1px solid #3a3a42;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 12px;
  font-family: inherit;
}
#bgAlphaVal {
  font-size: 11px;
  color: #8a8a92;
  min-width: 30px;
}

.align-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 12px;
  color: #b5b5bd;
}
.align-row label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.align-row input[type="radio"] { accent-color: #6b8cff; }
.align-label {
  color: #8a8a92;
}

.font-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-size: 12px;
}
.font-row select {
  background: #23232a;
  color: #e8e8ea;
  border: 1px solid #3a3a42;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: inherit;
  flex: 1;
  max-width: 220px;
}

.history {
  background: #23232a;
  border-radius: 12px;
  padding: 12px 16px;
}
.history.hidden { display: none; }
.history-label {
  font-size: 11px;
  color: #8a8a92;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}
.history-strip {
  display: flex;
  gap: 8px;
  overflow: hidden;
}
.history-item {
  position: relative;
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: #0f0f12;
  transition: border-color 0.15s, transform 0.15s;
}
.history-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.history-item:hover {
  border-color: #6b8cff;
  transform: translateY(-2px);
}
.history-item.active {
  border-color: #6b8cff;
}
.history-strip.selecting .history-item {
  cursor: pointer;
}
.history-item.selected {
  border-color: #3ea170;
  box-shadow: 0 0 0 2px rgba(62, 161, 112, 0.35);
}
.history-check {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(15, 15, 20, 0.85);
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  font-weight: 700;
}
.history-item.selected .history-check {
  background: #3ea170;
}

.batch-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #2e2e34;
  flex-wrap: wrap;
}
.batch-count {
  font-size: 12px;
  color: #b5b5bd;
  margin-right: auto;
}
.batch-actions button {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.batch-actions button.ghost {
  background: transparent;
  border: 1px solid #3a3a42;
  color: #b5b5bd;
}
.batch-actions button.ghost:hover {
  background: #2e2e34;
}
.batch-actions button.batch {
  background: #3ea170;
  color: #fff;
}
.batch-actions button.batch:hover {
  background: #348f61;
}
.history-item.batch-selected {
  border-color: #6bffa0;
  box-shadow: 0 0 0 2px rgba(107, 255, 160, 0.25);
}
.history-item.batch-processing::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(107, 140, 255, 0.55);
  animation: pulse 0.8s ease-in-out infinite;
}
.history-item.batch-done::after {
  content: '✓';
  position: absolute;
  inset: 0;
  background: rgba(107, 255, 160, 0.5);
  color: #fff;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 0.9; }
}
.history-close {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(15, 15, 20, 0.85);
  color: #fff;
  font-size: 12px;
  line-height: 14px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.15s;
}
.history-item:hover .history-close {
  opacity: 1;
}

details {
  margin-top: 18px;
  font-size: 12px;
}
details summary {
  cursor: pointer;
  color: #6b8cff;
  padding: 6px 0;
  user-select: none;
}
details pre {
  background: #15151a;
  padding: 12px;
  border-radius: 8px;
  max-height: 280px;
  overflow: auto;
  font-size: 11px;
  color: #b5b5bd;
  margin-top: 8px;
}

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

/* 拡大オーバーレイ */
.zoom-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  animation: fadeIn 0.15s ease-out;
}
.zoom-overlay.hidden { display: none; }
.zoom-overlay img {
  max-width: 96vw;
  max-height: 92vh;
  object-fit: contain;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  border-radius: 4px;
}
.zoom-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: #b5b5bd;
  font-size: 12px;
  background: rgba(15, 15, 20, 0.7);
  padding: 6px 14px;
  border-radius: 20px;
  pointer-events: none;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* トースト通知 */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translate(-50%, -10px);
  background: #23232a;
  color: #e8e8ea;
  border-left: 4px solid #6b8cff;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  font-size: 13px;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 70vw;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast.error { border-left-color: #ff6b6b; }
.toast.success { border-left-color: #3ea170; }
.toast.hidden { display: none; }

/* Web版ヘッダー */
.header-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.header-menu {
  position: relative;
}
.menu-btn {
  background: transparent;
  color: #b5b5bd;
  border: 1px solid #3a3a42;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.menu-btn:hover { background: #2e2e34; }
.dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #23232a;
  border: 1px solid #3a3a42;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  min-width: 160px;
  z-index: 500;
  overflow: hidden;
}
.dropdown.hidden { display: none; }
.dropdown button {
  display: block;
  width: 100%;
  background: transparent;
  color: #e8e8ea;
  border: none;
  padding: 10px 14px;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.dropdown button:hover { background: #2e2e34; }

/* モーダル */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease-out;
}
.modal.hidden { display: none; }
.modal-content {
  background: #23232a;
  border-radius: 12px;
  padding: 24px 28px;
  min-width: 320px;
  max-width: 520px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.modal-content h3 {
  font-size: 16px;
  margin-bottom: 14px;
  color: #e8e8ea;
}
.modal-content #modalBody {
  font-size: 13px;
  color: #b5b5bd;
  line-height: 1.7;
  white-space: pre-wrap;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}
.modal-actions button {
  background: #6b8cff;
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.modal-actions button:hover { background: #5a7bee; }
