/* ============ CSS Custom Properties / Design Tokens ============ */
:root,
html[data-theme="light"] {
  --bg: #f7f5f3;
  --bg-panel: #ffffff;
  --bg-inset: #f0eeec;
  --bg-hover: #e8e5e2;
  --text: #1a1614;
  --text-sub: #7a726a;
  --text-muted: #a89e94;
  --border: #e2ddd8;
  --border-hover: #cfc8c0;
  --accent: #c7553b;
  --accent-hover: #b44a32;
  --accent-light: rgba(199, 85, 59, 0.08);
  --accent-text: #ffffff;
  --accent-secondary: #d4845a;
  --danger: #dc3545;
  --success: #2d8a56;
  --shadow-sm: 0 1px 2px rgba(26, 22, 20, 0.04);
  --shadow: 0 1px 3px rgba(26, 22, 20, 0.06), 0 1px 2px rgba(26, 22, 20, 0.04);
  --shadow-md: 0 4px 12px rgba(26, 22, 20, 0.08), 0 1px 3px rgba(26, 22, 20, 0.05);
  --shadow-lg: 0 8px 24px rgba(26, 22, 20, 0.1), 0 2px 8px rgba(26, 22, 20, 0.06);
  --checker-a: #e5e2de;
  --checker-b: #f5f3f0;
  --grid-line: rgba(0, 0, 0, .18);
  --grid-line-5: rgba(0, 0, 0, .40);
  --grid-line-10: rgba(0, 0, 0, .65);
  --board-bg: #ffffff;
  --board-label: #5a524a;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font-sans: 'Inter', "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

html[data-theme="dark"] {
  --bg: #0f0e0d;
  --bg-panel: #1a1816;
  --bg-inset: #141211;
  --bg-hover: #242120;
  --text: #ece8e4;
  --text-sub: #9a928a;
  --text-muted: #6a6258;
  --border: #2a2724;
  --border-hover: #3a3632;
  --accent: #d4724e;
  --accent-hover: #e0815c;
  --accent-light: rgba(212, 114, 78, 0.12);
  --accent-text: #0f0e0d;
  --accent-secondary: #c49060;
  --danger: #e55b6a;
  --success: #3da86a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
  --checker-a: #1e1c1a;
  --checker-b: #141211;
  --grid-line: rgba(255, 255, 255, .15);
  --grid-line-5: rgba(255, 255, 255, .30);
  --grid-line-10: rgba(255, 255, 255, .50);
  --board-bg: #1a1816;
  --board-label: #9a928a;
}

/* ============ Reset & Base ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html {
  height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  letter-spacing: -0.01em;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

h2 {
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

small {
  color: var(--text-sub);
  display: block;
  font-size: 0.75rem;
  line-height: 1.4;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.7rem 0;
}

.hint {
  color: var(--text-sub);
  font-size: 0.72rem;
  line-height: 1.5;
}

/* ============ Animations ============ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes progressIndeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}

body > * {
  animation: fadeIn 0.4s ease-out both;
}

body > main { animation-delay: 0.1s; }
body > footer { animation-delay: 0.2s; }

/* ============ Header ============ */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1.25rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background var(--transition), border-color var(--transition);
}

html[data-theme="dark"] .app-header {
  background: rgba(26, 24, 22, 0.85);
}

.app-title {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.logo-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.subtitle {
  color: var(--text-sub);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-inset);
  color: var(--text-sub);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.theme-toggle:hover {
  border-color: var(--border-hover);
  color: var(--text);
  background: var(--bg-hover);
  transform: scale(1.04);
}

.theme-toggle:active {
  transform: scale(0.96);
}

.icon-sun, .icon-moon {
  position: absolute;
  transition: opacity 0.3s, transform 0.3s;
}

html[data-theme="light"] .icon-sun { opacity: 1; transform: rotate(0deg); }
html[data-theme="light"] .icon-moon { opacity: 0; transform: rotate(-90deg); }
html[data-theme="dark"] .icon-sun { opacity: 0; transform: rotate(90deg); }
html[data-theme="dark"] .icon-moon { opacity: 1; transform: rotate(0deg); }

/* ============ Layout ============ */
.layout {
  display: flex;
  gap: 1.25rem;
  padding: 1.25rem;
  flex: 1;
  align-items: flex-start;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

.sidebar {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: sticky;
  top: 68px;
  max-height: calc(100vh - 68px - 1.25rem);
  overflow-y: auto;
  padding-bottom: 1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 5px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.content {
  flex: 1;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ============ Panel ============ */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}

html[data-theme="dark"] .panel {
  background: rgba(26, 24, 22, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}

.step-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1;
}

/* ============ Drop Zone ============ */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  text-align: center;
  padding: 1.5rem 1rem;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.82rem;
  position: relative;
  overflow: hidden;
}

.drop-zone::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-light), transparent);
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}

.drop-zone:hover,
.drop-zone:focus-visible {
  border-color: var(--accent);
}

.drop-zone:hover::after,
.drop-zone:focus-visible::after {
  opacity: 1;
}

.drop-zone.dragover {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-light);
  transform: scale(1.01);
}

.drop-zone.dragover::after {
  opacity: 1;
}

.drop-zone-inner {
  position: relative;
  z-index: 1;
}

.drop-icon-svg {
  display: block;
  margin: 0 auto 0.5rem;
  opacity: 0.4;
  transition: opacity var(--transition);
}

.drop-zone:hover .drop-icon-svg {
  opacity: 0.6;
}

.drop-text {
  font-size: 0.8rem;
  color: var(--text-sub);
  margin-bottom: 0.3rem;
  line-height: 1.5;
}

.thumb {
  max-width: 100%;
  max-height: 140px;
  border-radius: var(--radius-xs);
  margin-top: 0.6rem;
  border: 1px solid var(--border);
  object-fit: contain;
}

.file-info {
  font-size: 0.72rem;
  color: var(--text-sub);
  margin-top: 0.5rem;
  word-break: break-all;
}

/* ============ Form Elements ============ */
.grid-size-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.times {
  padding-bottom: 0.55rem;
  color: var(--text-muted);
  font-weight: 500;
}

.num-field {
  flex: 1;
  font-size: 0.72rem;
  color: var(--text-sub);
  font-weight: 500;
}

.num-field input {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.6rem;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-inset);
  color: var(--text);
  transition: all var(--transition);
}

.num-field input:hover {
  border-color: var(--border-hover);
}

.num-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.82rem;
  margin: 0.45rem 0;
  cursor: pointer;
  transition: color var(--transition);
}

.check-row:hover { color: var(--text); }

.check-row input[type="checkbox"] {
  margin-top: 0.2rem;
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-inset);
}

.radio-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-hover);
}

.radio-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-light);
}

.radio-card input[type="radio"] {
  margin-top: 0.15rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.radio-content {
  min-width: 0;
}

.radio-content strong {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
}

.radio-content small {
  font-size: 0.72rem;
  margin-top: 0.1rem;
}

.options-group {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.preset-row {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.65rem;
}

.preset-btn {
  flex: 1;
  min-width: 42px;
  padding: 0.38rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-inset);
  color: var(--text-sub);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: var(--font-sans);
  font-weight: 500;
  transition: all var(--transition);
}

.preset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.preset-btn:active {
  transform: scale(0.95);
}

.slider-row {
  display: block;
  font-size: 0.78rem;
  color: var(--text-sub);
  margin: 0.4rem 0 0.6rem 1.6rem;
}

.slider-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  margin-top: 0.3rem;
}

/* ============ Zoom & Buttons ============ */
.zoom-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.zoom-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.zoom-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-inset);
  color: var(--text-sub);
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
}

.zoom-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.zoom-btn:active {
  transform: scale(0.92);
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.primary-btn,
.secondary-btn {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: all var(--transition);
  letter-spacing: -0.01em;
}

.primary-btn {
  background: var(--accent);
  color: var(--accent-text);
  border: 1px solid var(--accent);
}

.primary-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.primary-btn:not(:disabled):hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.primary-btn:not(:disabled):active {
  transform: translateY(0) scale(0.98);
  box-shadow: var(--shadow-sm);
}

.secondary-btn {
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--border);
}

.secondary-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.secondary-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
  transform: translateY(-1px);
}

.secondary-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

/* ============ Board ============ */
.board-wrap {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
  height: min(68vh, 760px);
  position: relative;
  transition: border-color var(--transition), background var(--transition);
}

html[data-theme="dark"] .board-wrap {
  background: rgba(26, 24, 22, 0.7);
}

.board-wrap canvas {
  display: block;
  margin: 0 auto;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  color: var(--text-sub);
  text-align: center;
  padding: 2rem;
  animation: fadeInUp 0.6s ease-out both;
  animation-delay: 0.3s;
}

.empty-illustration {
  margin-bottom: 0.5rem;
  opacity: 0.7;
}

.empty-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.empty-desc {
  font-size: 0.82rem;
  color: var(--text-sub);
  line-height: 1.6;
}

/* ============ Progress ============ */
.convert-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.progress-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-inset);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 33%;
  background: var(--accent);
  border-radius: 2px;
  animation: progressIndeterminate 1.2s ease-in-out infinite;
}

.progress-text {
  font-size: 0.75rem;
  color: var(--text-sub);
  white-space: nowrap;
}

/* ============ Palette ============ */
.palette-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}

.palette-head h2 { margin-bottom: 0; }

.stats {
  font-size: 0.78rem;
  color: var(--text-sub);
}

.stats strong {
  color: var(--text);
  font-weight: 600;
}

.palette-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.4rem;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.6rem;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 0.78rem;
  transition: all var(--transition);
  animation: fadeIn 0.3s ease-out both;
}

.palette-item:hover {
  border-color: var(--border-hover);
  background: var(--bg-hover);
}

.swatch {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  border: 1px solid rgba(0,0,0,.15);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

html[data-theme="dark"] .swatch {
  border-color: rgba(255,255,255,.12);
}

.palette-item .meta {
  min-width: 0;
  flex: 1;
}

.palette-item .name {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.palette-item .count {
  color: var(--text-sub);
  font-size: 0.7rem;
}

/* ============ Affiliate Section ============ */
.affiliate-panel {
  animation: fadeInUp 0.4s ease-out both;
}

.affiliate-header {
  margin-bottom: 1rem;
}

.affiliate-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.3rem;
}

.affiliate-title-row h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.affiliate-subtitle {
  font-size: 0.78rem;
  color: var(--text-sub);
}

.affiliate-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.summary-card {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  text-align: center;
  transition: all var(--transition);
}

.summary-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.summary-card .summary-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  display: block;
  line-height: 1.2;
}

.summary-card .summary-label {
  font-size: 0.72rem;
  color: var(--text-sub);
  margin-top: 0.2rem;
  display: block;
}

.affiliate-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.affiliate-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  text-decoration: none;
  color: var(--text);
  animation: fadeIn 0.3s ease-out both;
}

.affiliate-item:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.affiliate-item .af-swatch {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  border: 1px solid rgba(0,0,0,.12);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

html[data-theme="dark"] .affiliate-item .af-swatch {
  border-color: rgba(255,255,255,.1);
}

.affiliate-item .af-info {
  flex: 1;
  min-width: 0;
}

.affiliate-item .af-name {
  display: block;
  font-weight: 500;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.affiliate-item .af-count {
  font-size: 0.72rem;
  color: var(--text-sub);
}

.affiliate-item .af-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: color var(--transition), transform var(--transition);
}

.affiliate-item:hover .af-arrow {
  color: var(--accent);
  transform: translateX(2px);
}

.affiliate-set-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  transition: all var(--transition);
  margin-bottom: 0.75rem;
}

.affiliate-set-link:hover {
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.affiliate-disclaimer {
  margin-top: 0.5rem;
  font-style: italic;
}

/* ============ Print Section ============ */
.print-panel {
  animation: fadeInUp 0.4s ease-out both;
}

.print-header {
  margin-bottom: 1rem;
}

.print-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.3rem;
}

.print-title-row h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.print-subtitle {
  font-size: 0.78rem;
  color: var(--text-sub);
}

.print-options {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.print-options .primary-btn,
.print-options .secondary-btn {
  margin-top: 0;
}

.print-preview-info {
  padding: 0.6rem 0.75rem;
  background: var(--bg-inset);
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
}

/* ============ Print Styles ============ */
@media print {
  body {
    background: white !important;
    color: black !important;
  }

  .app-header, .sidebar, .app-footer,
  .affiliate-panel, .print-panel,
  .board-wrap, .palette-panel,
  .convert-progress {
    display: none !important;
  }

  .print-output {
    display: block !important;
  }
}

.print-output {
  display: none;
}

/* ============ Footer ============ */
.app-footer {
  padding: 1rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.7rem;
  text-align: center;
  border-top: 1px solid var(--border);
  transition: color var(--transition), border-color var(--transition);
}

/* ============ Responsive ============ */
@media (max-width: 960px) {
  .layout {
    flex-direction: column;
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .sidebar {
    width: 100%;
    position: static;
    max-height: none;
    overflow-y: visible;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 0.75rem;
  }

  .board-wrap {
    height: 55vh;
  }

  .affiliate-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .layout {
    padding: 0.5rem;
    gap: 0.5rem;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }

  .app-header {
    padding: 0.5rem 0.75rem;
  }

  h1 { font-size: 0.95rem; }

  .panel {
    padding: 0.85rem;
    border-radius: var(--radius-sm);
  }

  .board-wrap {
    height: 50vh;
    border-radius: var(--radius-sm);
  }

  .palette-list {
    grid-template-columns: 1fr;
  }

  .affiliate-summary {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============ Scrollbar (Global) ============ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* ============ Focus Visible ============ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ============ 制作ガイド ============ */
.craft-guide-panel { animation: fadeInUp .4s ease both; }
.craft-guide-header { margin-bottom: 1rem; }
.craft-guide-title-row {
  display: flex; align-items: center; gap: .5rem; margin-bottom: .25rem;
}
.craft-guide-title-row h2 { font-size: 1.05rem; font-weight: 600; }
.craft-guide-subtitle { font-size: .82rem; color: var(--text-sub); }

.cg-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .75rem;
}
.cg-card {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  display: flex; flex-direction: column; gap: .25rem;
  transition: border-color .2s, box-shadow .2s;
}
.cg-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.cg-card-label {
  font-size: .72rem; color: var(--text-sub); text-transform: uppercase;
  letter-spacing: .04em; font-weight: 500;
}
.cg-card-value {
  font-size: 1.15rem; font-weight: 700; color: var(--text);
}
.cg-stars { display: flex; gap: 1px; }
.cg-star { font-size: 1.2rem; color: var(--text-sub); opacity: .35; }
.cg-star.filled { color: var(--accent); opacity: 1; }

/* ============ 制作チェックモード ============ */
.checkmode-panel { animation: fadeInUp .4s ease both; }
.checkmode-panel.cm-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.checkmode-header { margin-bottom: 1rem; }
.checkmode-title-row {
  display: flex; align-items: center; gap: .6rem; margin-bottom: .3rem;
}
.checkmode-title-row h2 { margin-bottom: 0; font-size: 1rem; }
.checkmode-subtitle { font-size: .78rem; color: var(--text-sub); }

.checkmode-controls {
  display: flex; flex-wrap: wrap; gap: .5rem;
  margin-bottom: .85rem;
}
.checkmode-controls .primary-btn,
.checkmode-controls .secondary-btn {
  margin-top: 0;
  width: auto;
  flex: 1 1 180px;
}

.checkmode-progress { margin-bottom: .75rem; }
.cm-progress-bar {
  height: 10px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
}
.cm-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
  border-radius: 5px;
  transition: width .25s ease;
}
.cm-progress-text {
  font-size: .78rem;
  color: var(--text-sub);
  margin-top: .35rem;
}
.cm-progress-text strong { color: var(--text); font-weight: 700; }

.board-wrap.check-mode {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.board-wrap.check-mode canvas {
  cursor: crosshair;
  touch-action: none;
}

/* ============ SNS共有 ============ */
.share-panel { animation: fadeInUp .4s ease both; }
.share-header { margin-bottom: 1rem; }
.share-title-row {
  display: flex; align-items: center; gap: .5rem; margin-bottom: .25rem;
}
.share-title-row h2 { font-size: 1.05rem; font-weight: 600; }
.share-subtitle { font-size: .82rem; color: var(--text-sub); }

.share-card-preview {
  margin-bottom: 1rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #1a1614;
}
.share-card-preview canvas {
  display: block;
  width: 100%;
  height: auto;
}

.share-actions {
  display: flex; flex-wrap: wrap; gap: .5rem;
}

.share-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1rem;
  border-radius: var(--radius);
  font-size: .82rem; font-weight: 600;
  border: none; cursor: pointer;
  transition: transform .15s, box-shadow .2s, opacity .2s;
  text-decoration: none;
}
.share-btn:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.share-btn:active { transform: translateY(0); }

.share-btn-twitter {
  background: #000000; color: #ffffff;
}
.share-btn-line {
  background: #06c755; color: #ffffff;
}
.share-btn-download {
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--border);
}
.share-btn-download:hover {
  border-color: var(--accent);
}

/* ============ Selection ============ */
::selection {
  background: var(--accent);
  color: var(--accent-text);
}
