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

body {
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f7fa;
  color: #1e293b;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

/* ===== APP SHELL ===== */
.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
}

@media (min-width: 769px) {
  .app { padding: 24px; }
}

.app-header {
  text-align: center;
  margin-bottom: 24px;
}

.app-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
}

.subtitle {
  font-size: 13px;
  color: #64748b;
}

/* ===== UPLOAD ===== */
.upload-area {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: #fff;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: #4361ee;
  background: #f0f4ff;
}

.upload-content svg {
  color: #94a3b8;
  margin-bottom: 12px;
}

.upload-main {
  font-size: 15px;
  font-weight: 600;
  color: #475569;
}

.upload-sub {
  font-size: 13px;
  color: #94a3b8;
  margin-top: 4px;
}

/* ===== TOOLBAR ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.image-info {
  font-size: 13px;
  color: #64748b;
}

/* ===== LAYOUT ===== */
.workspace-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (min-width: 769px) {
  .workspace-layout {
    flex-direction: row;
    gap: 24px;
  }
}

/* ===== SETTINGS ===== */
.settings-panel {
  width: 100%;
}

@media (min-width: 769px) {
  .settings-panel {
    width: 280px;
    flex-shrink: 0;
  }
}

.setting-section {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.setting-section h2 {
  font-size: 14px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 12px;
}

.setting-row {
  margin-bottom: 12px;
}

.setting-row:last-child {
  margin-bottom: 0;
}

.setting-row > label {
  display: block;
  font-size: 12px;
  color: #64748b;
  margin-bottom: 4px;
}

.setting-row select,
.setting-row textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: #1e293b;
  background: #fff;
  appearance: auto;
}

.setting-row textarea {
  resize: vertical;
  min-height: 60px;
}

.setting-row input[type='color'] {
  width: 100%;
  height: 36px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  padding: 2px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.toggle input[type='checkbox'] {
  width: 18px;
  height: 18px;
  accent-color: #4361ee;
}

.toggle-label {
  font-size: 14px;
  color: #334155;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.range-row input[type='range'] {
  flex: 1;
  accent-color: #4361ee;
}

.range-row span {
  font-size: 12px;
  color: #64748b;
  min-width: 40px;
  text-align: right;
  white-space: nowrap;
}

/* ===== PREVIEW ===== */
.preview-area {
  flex: 1;
  min-width: 0;
}

.preview-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

@media (min-width: 600px) {
  .preview-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .preview-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1400px) {
  .preview-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.preview-card {
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.card-header {
  margin-bottom: 10px;
}

.preset-name {
  display: block;
  width: 100%;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 3px 6px;
  background: transparent;
  font-family: inherit;
  color: #1e293b;
  margin-bottom: 2px;
}

.preset-name:hover,
.preset-name:focus {
  border-color: #e2e8f0;
  background: #f8fafc;
  outline: none;
}

.preset-size {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #94a3b8;
  padding-left: 6px;
}

.preset-size input {
  width: 52px;
  padding: 2px 4px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 12px;
  text-align: center;
  font-family: inherit;
  color: #475569;
}

.preset-size input:focus {
  outline: none;
  border-color: #4361ee;
}

.canvas-wrapper {
  margin-bottom: 10px;
  border-radius: 6px;
  overflow: hidden;
  background: #e2e8f0;
  position: relative;
  touch-action: none;
}

.canvas-wrapper canvas {
  display: block;
  width: 100%;
  cursor: grab;
}

.canvas-wrapper canvas:active {
  cursor: grabbing;
}

.drag-hint {
  position: absolute;
  bottom: 6px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.7);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  transition: opacity 0.3s;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: #4361ee;
  color: #fff;
}

.btn-primary:hover {
  background: #3651d4;
}

.btn-secondary {
  background: #e2e8f0;
  color: #475569;
}

.btn-secondary:hover {
  background: #cbd5e1;
}

.btn-lg {
  padding: 12px 32px;
  font-size: 15px;
}

.btn-download {
  width: 100%;
  padding: 8px 12px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.btn-download:hover {
  background: #e2e8f0;
}

.download-bar {
  text-align: center;
  padding: 16px 0 8px;
}

.setting-hint {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
}

.zoom-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  padding: 0 2px;
}

.zoom-row .zoom-label {
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
}

.zoom-row input[type='range'] {
  flex: 1;
  accent-color: #4361ee;
}

.zoom-row .zoom-val {
  font-size: 11px;
  color: #64748b;
  min-width: 32px;
  text-align: right;
}

/* ===== GUIDE ===== */
.guide-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-family: inherit;
  color: #64748b;
  cursor: pointer;
  transition: background 0.15s;
}

.guide-toggle:hover {
  background: #f1f5f9;
}

.guide-panel {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.8;
  color: #475569;
}

.guide-panel h3 {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
  margin: 12px 0 4px;
}

.guide-panel h3:first-child {
  margin-top: 0;
}

.guide-panel ul {
  padding-left: 18px;
  margin: 0;
}

.guide-panel li {
  margin-bottom: 2px;
}

.guide-panel kbd {
  display: inline-block;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  padding: 0 5px;
  font-size: 12px;
  font-family: inherit;
}

/* ===== SAVE MODAL (iPhone・アプリ内ブラウザ用) ===== */
.save-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  z-index: 100;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

body.save-modal-open {
  overflow: hidden;
}

.save-modal-inner {
  background: #fff;
  border-radius: 12px;
  max-width: 520px;
  margin: 0 auto 32px;
  padding: 20px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.save-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.save-modal-head h3 {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.save-modal-hint {
  font-size: 12px;
  color: #64748b;
  line-height: 1.7;
  margin-bottom: 16px;
}

.save-modal-item {
  margin-bottom: 20px;
}

.save-modal-item:last-child {
  margin-bottom: 0;
}

.save-modal-label {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 6px;
}

.save-modal-item img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.save-modal-share {
  width: 100%;
  margin-top: 8px;
}
