/* ═══════════════════════════════════════
   ZUROKU MAKER  —  Logo Grid Maker デザイン言語準拠
   ═══════════════════════════════════════ */

:root {
  --bg:          #eef0f4;
  --chrome:      #ffffff;
  --ink:         #14161c;
  --ink-2:       #4a5060;
  --muted:       #878e9c;
  --line:        #e6e8ef;
  --line-2:      #eef0f5;
  --field:       #f5f6fa;
  --accent:      #5b5bf0;
  --accent-2:    #8b5cf6;
  --accent-soft: #eeeefe;
  --warn:        #b5730a;
  --warn-bg:     #fff7e6;
  --shadow-sm:   0 1px 2px rgba(20,22,28,.06);
  --shadow-md:   0 6px 24px rgba(20,22,28,.10);
  --shadow-lg:   0 24px 60px rgba(20,22,28,.18);
  --r:           12px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  display: grid;
  grid-template-columns: 372px 1fr;
  grid-template-rows: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); }

/* ============ Sidebar ============ */
.sidebar {
  background: var(--chrome);
  border-right: 1px solid var(--line);
  height: 100vh;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.side-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line-2);
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}

.logo-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 14px rgba(91,91,240,.35);
  display: grid;
  place-items: center;
}
.logo-mark svg { width: 20px; height: 20px; }

.side-head h1 { font-size: 15.5px; margin: 0; font-weight: 700; letter-spacing: -.2px; }
.side-head p  { margin: 2px 0 0; font-size: 11px; color: var(--muted); font-weight: 500; }

.badge-priv {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  color: #16794a;
  background: #e7f7ee;
  border: 1px solid #c7ecd7;
  padding: 4px 8px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.badge-priv i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #21b36b;
  display: inline-block;
}

.side-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 14px 24px;
  min-height: 0;
}
.side-scroll::-webkit-scrollbar { width: 10px; }
.side-scroll::-webkit-scrollbar-thumb {
  background: #dcdfe8;
  border-radius: 99px;
  border: 3px solid var(--chrome);
}
.side-scroll::-webkit-scrollbar-thumb:hover { background: #c7cbd6; }

/* ── Accordion sections ── */
details.sec {
  border: 1px solid var(--line);
  border-radius: var(--r);
  margin-top: 10px;
  background: var(--chrome);
  overflow: hidden;
}
details.sec[open] { box-shadow: var(--shadow-sm); }

summary.sec-h {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
summary.sec-h::-webkit-details-marker { display: none; }
summary.sec-h:hover { background: var(--line-2); }

.sec-ico {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex: none;
}
.sec-ico svg { width: 16px; height: 16px; }

.sec-h .chev { color: var(--muted); transition: transform .2s ease; }
details.sec[open] .chev { transform: rotate(90deg); }

.sec-body { padding: 4px 14px 16px; }

/* ── Drop zone ── */
.drop {
  border: 2px dashed #cfd3de;
  border-radius: var(--r);
  padding: 26px 14px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: .18s;
  background: var(--field);
}
.drop:hover, .drop.drag {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink-2);
}
.drop .up-ico {
  width: 40px;
  height: 40px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  display: grid;
  place-items: center;
  color: var(--accent);
}
.drop strong { color: var(--ink); font-size: 13px; display: block; margin-bottom: 3px; font-weight: 600; }
.drop span   { font-size: 11px; }

/* ── Thumbnails ── */
.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.thumb {
  position: relative;
  background: #fff;
  border-radius: 9px;
  overflow: hidden;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  cursor: grab;
  transition: .14s;
  box-shadow: var(--shadow-sm);
}
.thumb:hover { border-color: var(--accent); box-shadow: 0 4px 12px rgba(91,91,240,.18); transform: translateY(-2px); }
.thumb.dragging { opacity: .35; transform: scale(.95); }
.thumb img { max-width: 85%; max-height: 85%; object-fit: contain; pointer-events: none; display: block; }
.thumb .x {
  position: absolute; top: 3px; right: 3px;
  width: 17px; height: 17px; border-radius: 50%;
  background: rgba(20,22,28,.6); color: #fff; border: none; font-size: 12px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: .14s; line-height: 1;
}
.thumb:hover .x { opacity: 1; }
.thumb .x:hover { background: #e5484d; }
.thumb .idx {
  position: absolute; bottom: 3px; left: 4px;
  font-size: 9px; color: #aab; font-weight: 600;
}

.img-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}
.reorder-hint { font-size: 10.5px; color: var(--muted); }

/* ── Controls ── */
.ctrl { margin-bottom: 14px; }
.ctrl:last-child { margin-bottom: 2px; }
.ctrl > label {
  display: block;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 6px;
  font-weight: 500;
}

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

select, input[type=number], input[type=text] {
  width: 100%;
  background: var(--field);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 11px;
  font-size: 13px;
  font-family: var(--font);
  transition: .15s;
  outline: none;
}
select:focus, input[type=number]:focus, input[type=text]:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: #b3b8c4; }
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%23878e9c' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-color: var(--field);
}

/* Segmented control */
.seg {
  display: flex;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.btn-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  transition: all .15s;
  white-space: nowrap;
  font-family: var(--font);
  border: none;
  background: none;
  cursor: pointer;
}
.btn-toggle svg { width: 11px; height: 11px; }
.btn-toggle:hover { color: var(--ink-2); }
.btn-toggle.active {
  background: var(--chrome);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

/* Size chip */
.size-chip {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: var(--field);
  border: 1px solid var(--line);
  padding: 5px 12px;
  border-radius: 99px;
  text-align: center;
  margin-top: 4px;
}

/* Stepper */
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper input { text-align: center; font-weight: 600; width: 50px; }
.stepper input::-webkit-inner-spin-button,
.stepper input::-webkit-outer-spin-button { display: none; }

/* Toggle switch */
.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--ink-2);
  font-weight: 500;
}
.toggle:hover { color: var(--ink); }
.toggle + .toggle { border-top: 1px solid var(--line-2); }
.sw {
  -webkit-appearance: none; appearance: none;
  width: 40px; height: 23px; border-radius: 99px;
  background: #d3d7e0; position: relative; cursor: pointer; transition: .2s; flex: none; margin: 0;
}
.sw:checked { background: var(--accent); }
.sw::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 19px; height: 19px; border-radius: 50%; background: #fff;
  transition: .2s; box-shadow: 0 1px 3px rgba(20,22,28,.3);
}
.sw:checked::after { transform: translateX(17px); }

/* Input with unit */
.inp-unit {
  display: flex;
  align-items: center;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.inp-unit:focus-within {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.inp-unit input {
  flex: 1;
  border: none;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  padding: 8px 10px;
}
.inp-unit input:focus { box-shadow: none; border-color: transparent; background: transparent; }
.inp-unit span {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 0 10px;
  background: var(--line-2);
  align-self: stretch;
  display: flex;
  align-items: center;
  border-left: 1px solid var(--line);
}

/* Margin widget */
.margin-widget {
  display: grid;
  grid-template-columns: 1fr 56px 1fr;
  grid-template-rows: auto 56px auto;
  gap: 5px;
  align-items: center;
  justify-items: center;
  margin-top: 8px;
}
.mw-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.mw-lbl {
  font-size: 10px; font-weight: 600; color: var(--muted);
  letter-spacing: .04em; text-transform: uppercase;
}
.mw-inp {
  width: 48px; text-align: center;
  background: var(--field); border: 1px solid var(--line);
  border-radius: 8px; color: var(--ink);
  font-size: 12.5px; font-weight: 600; padding: 6px 4px;
  outline: none; transition: border-color .15s, box-shadow .15s;
  font-family: var(--font);
}
.mw-inp:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-soft); }
.mw-inp::-webkit-inner-spin-button,
.mw-inp::-webkit-outer-spin-button { display: none; }
.mw-icon { width: 42px; height: 42px; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.mw-icon svg { width: 38px; height: 38px; }

/* Color controls */
.color-ctrl {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 10px;
  transition: border-color .15s;
  cursor: pointer;
  width: 100%;
}
.color-ctrl:hover { border-color: var(--accent); background: #fff; }
.color-ctrl input[type=color] {
  width: 22px; height: 22px; border: none; border-radius: 5px;
  background: none; cursor: pointer; padding: 0; flex-shrink: 0;
  outline: none; box-shadow: none;
}
.color-ctrl input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.color-ctrl input[type=color]::-webkit-color-swatch { border: 1px solid var(--line); border-radius: 4px; }
.clr-code { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .04em; }

/* Count badge */
.count-badge {
  font-size: 11px; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); border: 1px solid rgba(91,91,240,.2);
  padding: 2px 8px; border-radius: 99px;
}

/* ── Page tab bar ── */
.page-tab-bar {
  display: flex;
  gap: 6px;
  margin: 10px 0 0;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 4px;
}
.page-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: .15s;
  font-family: var(--font);
}
.page-tab:hover { color: var(--ink-2); }
.page-tab.active {
  background: var(--chrome);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* ── Pager ── */
.pager {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px 8px;
}
.pager button {
  width: 28px; height: 28px;
  border: 1px solid var(--line); background: var(--chrome);
  color: var(--ink-2); border-radius: 7px; cursor: pointer;
  font-size: 11px; transition: .12s;
  display: flex; align-items: center; justify-content: center;
}
.pager button:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.pager button:disabled { opacity: .35; cursor: not-allowed; }
.pager span { font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 0 4px; white-space: nowrap; }

/* ── JS-generated thumbnail classes ── */
.img-thumb {
  position: relative;
  background: #fff;
  border-radius: 9px;
  overflow: hidden;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  cursor: grab;
  transition: .14s;
  box-shadow: var(--shadow-sm);
}
.img-thumb:hover { border-color: var(--accent); box-shadow: 0 4px 12px rgba(91,91,240,.18); transform: translateY(-2px); }
.img-thumb.drag-over { border-color: var(--accent); transform: scale(.95); box-shadow: 0 0 0 3px var(--accent-soft); }
.img-thumb img { max-width: 85%; max-height: 85%; object-fit: contain; pointer-events: none; display: block; }

.img-thumb-num {
  position: absolute; top: 3px; left: 3px;
  font-size: 8.5px; font-weight: 700;
  background: rgba(20,22,28,.55); color: #fff;
  padding: 1px 4px; border-radius: 4px;
  line-height: 1.4; backdrop-filter: blur(4px);
}
.img-thumb-del {
  position: absolute; top: 3px; right: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(229,72,77,.75); color: #fff; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  opacity: .55; transition: .14s; cursor: pointer; line-height: 1;
  border: none;
}
.img-thumb:hover .img-thumb-del { opacity: 1; }
.img-thumb-del:hover { background: #e5484d; transform: scale(1.1); }

.img-thumb-drag {
  position: absolute; bottom: 3px; right: 4px;
  font-size: 12px; color: rgba(20,22,28,.4);
  line-height: 1; cursor: grab; user-select: none;
  transition: color .14s;
}
.img-thumb:hover .img-thumb-drag { color: rgba(91,91,240,.7); }
.img-thumb.dragging { opacity: .4; transform: scale(.95); }
.img-thumb.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  transform: scale(.97);
}

/* ── num-btn (stepper ± buttons) ── */
.num-btn {
  width: 36px; height: 38px; flex: none;
  border: 1px solid var(--line); background: var(--field);
  color: var(--ink-2); border-radius: 10px; font-size: 18px;
  cursor: pointer; transition: .12s; line-height: 1; font-family: var(--font);
  display: flex; align-items: center; justify-content: center;
}
.num-btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.num-btn:active { transform: scale(.94); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; border: none; border-radius: 11px; padding: 12px;
  font-size: 13.5px; font-weight: 600; cursor: pointer; transition: .15s; font-family: var(--font);
}
.btn svg { width: 16px; height: 16px; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 6px 16px rgba(91,91,240,.32);
}
.btn.primary:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 8px 22px rgba(91,91,240,.4); }
.btn.primary:active { transform: translateY(0); }
.btn.soft {
  background: var(--field); color: var(--ink); border: 1px solid var(--line);
}
.btn.soft:hover { background: #fff; border-color: #d0d4de; box-shadow: var(--shadow-sm); }
.btn.ghost { background: transparent; color: var(--ink-2); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--field); }
.btn.sm { padding: 9px; font-size: 12px; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Dock ── */
.dock {
  flex: none;
  border-top: 1px solid var(--line);
  background: var(--chrome);
  padding: 14px;
  box-shadow: 0 -6px 20px rgba(20,22,28,.05);
}
.dock-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }

/* ============ Main ============ */
.main { height: 100vh; display: flex; flex-direction: column; min-height: 0; }

.topbar {
  flex: none;
  padding: 16px 26px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--chrome);
}
.topbar h2 { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: -.1px; }
.topbar .dot-sep { color: var(--line); }
.meta {
  color: var(--ink-2); font-size: 12px; font-weight: 500;
  background: var(--field); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 99px;
}
.top-spacer { flex: 1; }
.kbd { font-size: 11px; color: var(--muted); }

/* ── View mode toggle ── */
.view-mode-seg {
  display: flex;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
}
.vm-btn {
  width: 30px; height: 28px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  background: none; border: none; cursor: pointer; transition: .14s;
}
.vm-btn:hover { color: var(--ink-2); }
.vm-btn.active {
  background: var(--chrome);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.stage-wrap {
  flex: 1;
  overflow: auto;
  padding: 34px;
  display: grid;
  place-items: center;
  min-height: 0;
  background:
    radial-gradient(circle at 1px 1px, #dfe2ea 1px, transparent 0);
  background-size: 22px 22px;
  background-color: var(--bg);
  position: relative;
}

/* Empty state */
.empty {
  text-align: center;
  color: var(--muted);
  max-width: 380px;
  position: absolute;
  z-index: 2;
}
.empty .art {
  width: 96px; height: 96px; margin: 0 auto 22px;
  border-radius: 24px; background: var(--chrome);
  box-shadow: var(--shadow-md); display: grid; place-items: center; color: var(--accent);
}
.empty .art svg { width: 44px; height: 44px; }
.empty h3 { color: var(--ink); font-size: 17px; margin: 0 0 8px; font-weight: 700; }
.empty p  { font-size: 13px; line-height: 1.7; margin: 0 0 20px; }
.empty .cta {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border: none; padding: 11px 20px; border-radius: 11px;
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  box-shadow: 0 6px 16px rgba(91,91,240,.3); font-family: var(--font); transition: .15s;
}
.empty .cta:hover { transform: translateY(-1px); filter: brightness(1.05); }
.empty .steps { display: flex; gap: 18px; justify-content: center; margin-top: 26px; }
.empty .step { font-size: 11px; color: var(--muted); }
.empty .step b {
  display: block; width: 26px; height: 26px; margin: 0 auto 7px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); line-height: 26px; font-weight: 700;
  font-size: 12px; text-align: center;
}

#preview-canvas {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 80px);
  border-radius: 4px;
  box-shadow:
    0 0 0 1px rgba(20,22,28,.06),
    var(--shadow-md),
    var(--shadow-lg);
  position: relative;
  z-index: 1;
}

/* ============ Loading overlay ============ */
.overlay {
  position: fixed; inset: 0;
  background: rgba(20,22,28,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; backdrop-filter: blur(8px);
}
.overlay-card {
  background: var(--chrome); border: 1px solid var(--line);
  border-radius: var(--r); padding: 40px 60px;
  text-align: center; box-shadow: var(--shadow-lg);
}
.ov-spinner {
  width: 38px; height: 38px;
  border: 2.5px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto 18px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ov-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }

/* ── Global scrollbar ── */
* { scrollbar-width: thin; scrollbar-color: #dcdfe8 transparent; }

@media (max-width: 860px) {
  body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow: auto; }
  .sidebar { height: auto; }
  .main { height: auto; }
}
