/* ============================================
   YOKA T-SHIRT STUDIO — Style
   ============================================ */

:root {
  --bg: #fafaf8;
  --text: #2c2c2c;
  --text-light: #777;
  --accent: #e87c3e;
  --accent-hover: #d06a2f;
  --card-bg: #ffffff;
  --card-shadow: 0 2px 16px rgba(0,0,0,0.06);
  --card-hover-shadow: 0 6px 24px rgba(0,0,0,0.10);
  --radius: 16px;
  --radius-sm: 10px;
  --font: 'Inter', 'Noto Sans JP', -apple-system, sans-serif;
  --transition: 0.25s ease;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* --- Screen Management --- */
.screen {
  display: none;
  min-height: 100dvh;
  padding: 24px;
  animation: fadeIn 0.3s ease;
}
.screen.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- ① Top Screen --- */
.top-header {
  text-align: center;
  padding: 40px 0 28px;
}
.logo {
  margin: 0;
  line-height: 0;
}
.logo-img {
  display: inline-block;
  width: 480px;
  max-width: 90vw;
  height: auto;
}
.tagline {
  font-size: 1rem;
  color: var(--text-light);
  margin-top: 0;
  font-weight: 300;
}
.delivery-notice {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 24px;
  line-height: 1.6;
  text-align: center;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}
.top-footer-links {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 16px;
  padding-bottom: 8px;
}
.top-footer-links a {
  font-size: 0.75rem;
  color: var(--text-light);
  text-decoration: none;
  transition: color var(--transition);
}
.top-footer-links a:hover {
  color: var(--accent);
}

.entry-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 8px;
}

.entry-card {
  background: var(--card-bg);
  border: none;
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--card-shadow);
  transition: box-shadow var(--transition), transform var(--transition);
  font-family: inherit;
}
.entry-card:hover {
  box-shadow: var(--card-hover-shadow);
  transform: translateY(-3px);
}
.entry-card:active { transform: scale(0.98); }

.card-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
}
.card-icon-img {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-icon-img img {
  max-height: 100%;
  max-width: 72px;
  object-fit: contain;
}
.entry-card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.entry-card p {
  font-size: 0.85rem;
  color: var(--text-light);
  line-height: 1.6;
}

/* --- Screen Header (共通) --- */
.screen-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}
.screen-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
}

/* --- Buttons --- */
.btn-back {
  background: none;
  border: none;
  font-size: 0.95rem;
  color: var(--text-light);
  cursor: pointer;
  font-family: inherit;
  padding: 8px 0;
  transition: color var(--transition);
}
.btn-back:hover { color: var(--text); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 32px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.btn-secondary {
  background: none;
  border: 2px solid #ddd;
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: border-color var(--transition);
}
.btn-secondary:hover { border-color: var(--text); }

.btn-file {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
  margin-top: 8px;
  transition: background var(--transition);
}
.btn-file:hover { background: var(--accent-hover); }

/* --- ② Gallery --- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  max-width: 900px;
  margin: 0 auto;
}
.gallery-item {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--card-shadow);
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
  background-color: #d8d4cc;
  background-image:
    linear-gradient(45deg, rgba(0,0,0,0.06) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(0,0,0,0.06) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(0,0,0,0.06) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(0,0,0,0.06) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.gallery-item:hover {
  box-shadow: var(--card-hover-shadow);
  transform: scale(1.03);
}
.gallery-item.selected {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8px;
}
.gallery-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.gallery-cell .gallery-title {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  line-height: 1.3;
  word-break: break-word;
}
.gallery-action {
  text-align: center;
  margin-top: 24px;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

/* --- ② Upload --- */
.upload-area {
  max-width: 500px;
  margin: 0 auto;
}
.upload-placeholder {
  border: 2px dashed #ccc;
  border-radius: var(--radius);
  padding: 60px 24px;
  text-align: center;
  transition: border-color var(--transition), background var(--transition);
}
.upload-placeholder.dragover {
  border-color: var(--accent);
  background: rgba(232, 124, 62, 0.05);
}
.upload-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 12px;
}
.upload-placeholder p {
  color: var(--text-light);
  font-size: 0.95rem;
  line-height: 1.6;
}

.upload-preview {
  text-align: center;
}
.upload-preview img {
  max-width: 100%;
  max-height: 400px;
  border-radius: var(--radius-sm);
  box-shadow: var(--card-shadow);
}
.upload-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}

.upload-format-info {
  text-align: left;
  background: #f4f7fb;
  border: 1px solid #d8e4f0;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-top: 24px;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}
.format-info-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #2c5577;
  margin-bottom: 6px;
}
.upload-format-info ul {
  font-size: 0.8rem;
  line-height: 1.65;
  color: #3a4a5a;
  padding-left: 18px;
  margin: 4px 0 0;
}
.upload-format-info li { margin-bottom: 3px; }

.copyright-notice {
  text-align: left;
  background: #fff8ee;
  border: 1px solid #f0d4b0;
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin-top: 20px;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}
.copyright-notice-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #b85a1a;
  margin-bottom: 8px;
}
.copyright-notice p {
  font-size: 0.82rem;
  line-height: 1.6;
  color: #5a3a1c;
  margin-bottom: 6px;
}
.copyright-notice ul {
  font-size: 0.78rem;
  line-height: 1.6;
  color: #5a3a1c;
  padding-left: 18px;
  margin: 6px 0 8px;
}
.copyright-notice li { margin-bottom: 2px; }
.copyright-notice a {
  color: #e87c3e;
  text-decoration: underline;
}
.copyright-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #f0d4b0;
  cursor: pointer;
  user-select: none;
}
.copyright-consent input[type="checkbox"] {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: #e87c3e;
}
.copyright-consent span {
  font-size: 0.82rem;
  line-height: 1.5;
  color: #2c2c2c;
}
.copyright-consent.typo-consent {
  border-top: none;
  padding: 12px 14px;
  margin-top: 16px;
  background: #fff8ee;
  border: 1px solid #f0d4b0;
  border-radius: var(--radius-sm);
}
.copyright-consent.typo-consent a {
  color: #e87c3e;
  text-decoration: underline;
}

/* --- ② TYPORAIT (Native) --- */
.typorait-native {
  max-width: 900px;
  margin: 0 auto;
}

.typo-upload-area {
  border: 2px dashed #ccc;
  border-radius: var(--radius);
  padding: 60px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: border-color var(--transition), background var(--transition);
}
.typo-upload-area.dragover {
  border-color: var(--accent);
  background: rgba(232, 124, 62, 0.05);
}
.typo-upload-area p {
  color: var(--text-light);
  font-size: 0.95rem;
  margin: 12px 0;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.8rem;
  margin-top: 12px;
}

/* -- Crop Overlay -- */
#crop-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.95);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.crop-title {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 1px;
  color: #888;
}
#crop-container {
  position: relative;
  overflow: hidden;
  background: #111;
  touch-action: none;
  border: 1px solid #444;
  border-radius: var(--radius-sm);
}
#crop-img {
  position: absolute;
  transform-origin: 0 0;
  user-select: none;
  -webkit-user-drag: none;
}
#crop-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255,255,255,0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.1) 1px, transparent 1px);
  background-size: 33.33% 33.33%;
}
.crop-hint {
  font-size: 0.75rem;
  color: #666;
  letter-spacing: 1px;
}
.crop-btn-row {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}
.crop-btn-row .btn-secondary {
  color: #ccc;
  border-color: #555;
}
.crop-btn-row .btn-secondary:hover {
  border-color: #aaa;
}

/* -- Step 2: Message -- */
.typo-message-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 32px;
  align-items: start;
}
.typo-cropped-preview {
  text-align: center;
}
#typo-cropped-canvas {
  width: 100%;
  max-width: 300px;
  border-radius: var(--radius-sm);
  box-shadow: var(--card-shadow);
  background: #eee;
}
.typo-cropped-preview .btn-sm {
  display: inline-block;
  margin: 8px 4px 0;
}

.typo-message-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.typo-message-panel input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #e0e0e0;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-family: inherit;
  transition: border-color var(--transition);
}
.typo-message-panel input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

/* -- Step 3: Adjust -- */
.typo-adjust-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 32px;
  align-items: start;
}
.typo-result-preview {
  text-align: center;
}
#typo-result-canvas {
  max-width: 100%;
  max-height: 70vh;
  border-radius: var(--radius-sm);
  box-shadow: var(--card-shadow);
}

.typo-adjust-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.typo-adjust-panel .control-group > label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-light);
}

/* Font grid */
.typo-font-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.typo-font-btn {
  background: var(--card-bg);
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 8px 4px 4px;
  text-align: center;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
}
.typo-font-btn span {
  display: block;
  font-size: 1rem;
  line-height: 1.3;
}
.typo-font-btn small {
  display: block;
  font-size: 0.55rem;
  letter-spacing: 1px;
  color: var(--text-light);
  margin-top: 2px;
}
.typo-font-btn:hover { border-color: var(--text); }
.typo-font-btn.active {
  border-color: var(--accent);
  background: rgba(232, 124, 62, 0.06);
}

/* Param value display */
.typo-param-val {
  float: right;
  font-weight: 400;
  font-size: 0.7rem;
  color: var(--accent);
  letter-spacing: 0;
  text-transform: none;
}

.typo-range-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-light);
}
.typo-range-row .slider {
  flex: 1;
}

.typo-toggles {
  display: flex;
  gap: 10px;
}

.typo-style-grid {
  display: flex;
  gap: 8px;
}
.typo-style-btn {
  width: 48px;
  height: 48px;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  background: none;
  padding: 0;
  transition: border-color 0.2s;
}
.typo-style-btn.active {
  border-color: var(--accent);
}
.style-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 20px;
  font-weight: 700;
  border: 1px solid rgba(0,0,0,0.1);
}
.style-transparent {
  background: repeating-conic-gradient(#e0e0e0 0% 25%, #fff 0% 50%) 50% / 12px 12px;
}
.typo-extract-mode {
  display: flex;
  gap: 6px;
}
.typo-extract-mode .size-btn {
  font-size: 11px;
  letter-spacing: 0.5px;
  padding: 6px 16px;
  width: auto;
  min-width: 70px;
  height: auto;
}
.typo-msg-pos {
  display: flex;
  gap: 6px;
}
.typo-msg-pos .size-btn {
  width: 44px;
  height: 44px;
  font-size: 0.8rem;
}

.typo-adjust-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.typo-loading {
  text-align: center;
  color: var(--accent);
  font-weight: 500;
  padding: 20px;
}

@media (max-width: 720px) {
  .typo-message-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .typo-adjust-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

/* --- ③ Customize --- */
.customize-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 32px;
  max-width: 900px;
  margin: 0 auto;
  align-items: start;
}

.preview-container {
  text-align: center;
}
#tshirt-canvas {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  box-shadow: var(--card-shadow);
  background: #f0f0ec;
  cursor: grab;
  touch-action: none;
}
#tshirt-canvas:active { cursor: grabbing; }

.preview-hint {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 10px;
}

.customize-controls {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.control-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 10px;
  color: var(--text-light);
}

.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.color-group-label {
  font-size: 11px;
  color: #888;
  width: 100%;
  margin-top: 4px;
}
.color-group-label:first-child {
  margin-top: 0;
}
.body-note {
  font-size: 11px;
  color: #999;
  text-align: left;
  margin: 0 0 4px 0;
}
.current-color-name {
  font-weight: 400;
  font-size: 13px;
  color: #666;
  margin-left: 8px;
}
.order-price-display {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  margin-top: 8px;
}
.color-swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.active { border-color: var(--accent); }

.size-picker {
  display: flex;
  gap: 8px;
}
.size-btn {
  width: 48px;
  height: 48px;
  border: 2px solid #ddd;
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
}
.size-btn:hover { border-color: var(--text); }
.size-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.slider {
  width: 100%;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: #ddd;
  outline: none;
}
.slider::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.image-size-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.image-pos-inputs {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 4px;
}
.size-input-pair {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--text-light);
}
.size-input-pair label {
  font-size: 0.8rem;
  margin-bottom: 0;
  min-width: auto;
}
.input-cm {
  width: 64px;
  padding: 6px 8px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: inherit;
  text-align: right;
  transition: border-color var(--transition);
}
.input-cm:focus {
  outline: none;
  border-color: var(--accent);
}
.size-input-lock {
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.8;
  user-select: none;
  transition: opacity var(--transition);
}
.size-input-lock:hover { opacity: 1; }
.size-input-lock.unlocked { opacity: 0.4; }

.btn-reset-defaults {
  display: block;
  margin-top: 10px;
  padding: 8px 14px;
  background: none;
  border: 1px solid #d8d8d8;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-light);
  cursor: pointer;
  font-family: inherit;
  transition: border-color var(--transition), color var(--transition);
}
.btn-reset-defaults:hover {
  border-color: var(--text);
  color: var(--text);
}
.btn-reset-defaults::before {
  content: '↺ ';
  margin-right: 2px;
}

.btn-toggle {
  background: #e0e0e0;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  color: var(--text);
}
.btn-toggle.active {
  background: var(--accent);
  color: #fff;
}

.btn-next {
  margin-top: 8px;
  width: 100%;
}

/* --- ④ Order --- */
.order-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 40px;
  max-width: 900px;
  margin: 0 auto;
  align-items: start;
}

.order-preview {
  text-align: center;
  position: sticky;
  top: 24px;
}
#order-preview-canvas {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  box-shadow: var(--card-shadow);
  background: #f0f0ec;
}
.order-spec {
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--text-light);
}
.order-spec p { margin: 4px 0; }

.order-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
}
.required { color: var(--accent); }

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #e0e0e0;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color var(--transition);
  background: var(--card-bg);
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-order {
  width: 100%;
  padding: 16px;
  font-size: 1.1rem;
  margin-top: 8px;
}

/* --- ⑤ Complete --- */
.complete-content {
  text-align: center;
  max-width: 500px;
  margin: 0 auto;
  padding-top: 48px;
}
.complete-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #4caf50;
  color: #fff;
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}
.complete-content h2 {
  font-size: 1.4rem;
  margin-bottom: 12px;
}
.complete-message {
  color: var(--text-light);
  line-height: 1.7;
  margin-bottom: 24px;
}
#complete-preview-canvas,
#complete-preview-img {
  max-width: 240px;
  height: auto;
  border-radius: var(--radius-sm);
  box-shadow: var(--card-shadow);
  background: #f0f0ec;
}
.order-summary {
  text-align: left;
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin: 24px 0;
  box-shadow: var(--card-shadow);
  font-size: 0.9rem;
}
.order-summary p { margin: 6px 0; }

#btn-new-order {
  margin-top: 8px;
}

/* --- Responsive --- */
@media (max-width: 720px) {
  .screen { padding: 16px; }

  .top-header { padding: 28px 0 20px; }
  .logo-img { width: 90vw; }

  .entry-cards {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .entry-card { padding: 28px 20px; }

  .customize-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .order-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .order-preview {
    position: static;
  }
}
