/* KATAchi design studio — glass / glow redesign (cyan × indigo brand) */
:root {
  --bg: #07090f;
  --panel: rgba(255, 255, 255, 0.035);
  --panel-solid: #10141f;
  --line: rgba(255, 255, 255, 0.09);
  --line-soft: rgba(255, 255, 255, 0.06);
  --text: #eef2fa;
  --muted: #93a0b8;
  --cyan: #39d5ff;
  --indigo: #6d6af8;
  --grad: linear-gradient(120deg, #39d5ff, #6d6af8);
  --danger: #ff5f7a;
  --r-lg: 18px;
  --r-md: 13px;
  --r-sm: 10px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --ease: cubic-bezier(.22, .8, .3, 1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 14px;
  letter-spacing: .01em;
  line-height: 1.6;
  display: flex; flex-direction: column;
  overflow-x: hidden;
}
/* ambient brand glow */
body::before, body::after {
  content: ""; position: fixed; z-index: -1; border-radius: 50%;
  filter: blur(110px); opacity: .16; pointer-events: none;
}
body::before { width: 520px; height: 520px; left: -140px; top: -160px; background: var(--cyan); }
body::after { width: 640px; height: 640px; right: -200px; bottom: -240px; background: var(--indigo); }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
img { display: block; }
.hidden { display: none !important; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .22); background-clip: content-box; border: 2px solid transparent; }

/* ---------- shared controls ---------- */
.ghost {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 7px 14px; color: var(--muted);
  transition: color .18s var(--ease), border-color .18s var(--ease), background .18s var(--ease);
}
.ghost:hover { color: var(--text); border-color: rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .04); }
.primary {
  position: relative;
  background: var(--grad); color: #051018; font-weight: 700;
  border-radius: var(--r-sm); padding: 10px 18px;
  box-shadow: 0 4px 18px rgba(57, 213, 255, .22);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), filter .18s var(--ease);
}
.primary:hover { transform: translateY(-1px); box-shadow: 0 8px 26px rgba(57, 213, 255, .32); filter: brightness(1.06); }
.primary:active { transform: translateY(0); }
.primary:disabled { opacity: .4; cursor: default; transform: none; box-shadow: none; filter: none; }

/* ---------- topbar ---------- */
#topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(9, 12, 20, .72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: relative; z-index: 5;
}
.brand { font-weight: 800; letter-spacing: .06em; font-size: 16px; display: flex; align-items: center; }
.brand::before {
  content: ""; width: 22px; height: 22px; margin-right: 10px;
  background: url(/static/assets/logo-mark.svg) center / contain no-repeat;
}
.brand span {
  font-weight: 700; font-size: 11.5px; margin-left: 10px; letter-spacing: .18em;
  color: transparent; background: var(--grad); -webkit-background-clip: text; background-clip: text;
}
.spacer { flex: 1; }
#username-label { color: var(--muted); font-size: 13px; }

main { flex: 1; min-height: 0; display: flex; }
.view { flex: 1; min-height: 0; }

/* ---------- login ---------- */
#view-login { display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card {
  width: 384px; max-width: 100%;
  background: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .025));
  border: 1px solid var(--line); border-radius: 22px;
  padding: 38px 32px 32px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: rise .5s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.auth-logo { font-size: 30px; font-weight: 800; letter-spacing: .05em; line-height: 1.15; }
.auth-logo::before {
  content: ""; display: block; width: 48px; height: 48px; margin-bottom: 14px;
  background: url(/static/assets/logo-mark.svg) center / contain no-repeat;
  filter: drop-shadow(0 6px 18px rgba(57, 213, 255, .35));
}
.auth-logo span {
  display: block; font-size: 12.5px; font-weight: 700; margin-top: 6px; letter-spacing: .34em;
  color: transparent; background: var(--grad); -webkit-background-clip: text; background-clip: text;
}
.lead { color: var(--muted); margin: 16px 0 22px; line-height: 1.75; font-size: 13px; }
.tabs { display: flex; gap: 4px; background: rgba(0, 0, 0, .28); border-radius: var(--r-sm); padding: 4px; margin-bottom: 22px; }
.tabs button {
  flex: 1; padding: 8px 10px; color: var(--muted); border-radius: 7px; font-weight: 600; font-size: 13px;
  transition: color .18s var(--ease), background .18s var(--ease);
}
.tabs button.active { color: var(--text); background: rgba(255, 255, 255, .09); box-shadow: 0 2px 10px rgba(0, 0, 0, .25); }
#auth-form label { display: block; margin-bottom: 15px; color: var(--muted); font-size: 12px; letter-spacing: .04em; }
#auth-form input {
  width: 100%; margin-top: 7px; padding: 11px 14px;
  background: rgba(0, 0, 0, .3); border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--text); font-size: 14px;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
#auth-form input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(57, 213, 255, .14); }
#auth-submit { width: 100%; margin-top: 8px; padding: 12px; }
.form-error { color: var(--danger); font-size: 12px; margin-bottom: 12px; }

/* ---------- picker ---------- */
#view-picker { overflow-y: auto; }
.picker-inner { max-width: 1120px; margin: 0 auto; padding: 34px 28px 70px; }
.picker-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.picker-head h2 { font-size: 22px; font-weight: 800; letter-spacing: .02em; }
#category-tabs { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 26px; }
#category-tabs button {
  padding: 9px 18px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
  font-size: 13px; font-weight: 600;
  transition: all .18s var(--ease);
}
#category-tabs button:hover { color: var(--text); border-color: rgba(255, 255, 255, .3); transform: translateY(-1px); }
#category-tabs button.active {
  background: var(--grad); border-color: transparent; color: #051018; font-weight: 700;
  box-shadow: 0 4px 16px rgba(57, 213, 255, .28);
}
.picker-body { display: flex; gap: 26px; align-items: flex-start; }
#instance-grid {
  flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); gap: 14px;
}
.instance-card {
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--r-md);
  padding: 10px; cursor: pointer; text-align: center;
  transition: transform .2s var(--ease), border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.instance-card:hover { transform: translateY(-3px); border-color: rgba(255, 255, 255, .22); box-shadow: 0 10px 26px rgba(0, 0, 0, .35); }
.instance-card.active {
  border-color: transparent;
  background: linear-gradient(var(--panel-solid), var(--panel-solid)) padding-box,
              var(--grad) border-box;
  box-shadow: 0 8px 26px rgba(57, 213, 255, .2);
}
.instance-card img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: var(--r-sm); background: #fff; }
.instance-card .name { margin-top: 9px; font-size: 12px; color: var(--muted); transition: color .18s; }
.instance-card:hover .name, .instance-card.active .name { color: var(--text); }
#picker-options {
  width: 312px; background: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .02));
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px;
  position: sticky; top: 22px; box-shadow: var(--shadow);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  animation: rise .35s var(--ease);
}
#picker-preview { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; border-radius: var(--r-md); }
#picker-selected-name { margin: 14px 0 4px; font-weight: 700; font-size: 14px; }
.option-row { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 12px; }
.option-row .row-label { width: 100%; color: var(--muted); font-size: 11px; letter-spacing: .06em; }
.chip {
  padding: 6px 13px; border-radius: 9px; border: 1px solid var(--line); color: var(--muted); font-size: 12.5px;
  transition: all .16s var(--ease);
}
.chip:hover { color: var(--text); border-color: rgba(255, 255, 255, .3); }
.chip.active {
  border-color: var(--cyan); color: #b9ecff; background: rgba(57, 213, 255, .1);
  box-shadow: inset 0 0 0 1px rgba(57, 213, 255, .35);
}
#start-design { width: 100%; margin-top: 18px; padding: 12px; }

/* ---------- workspace ---------- */
#view-workspace { display: flex; min-height: 0; }
#sidebar {
  width: 256px; min-width: 256px; border-right: 1px solid var(--line-soft);
  background: rgba(10, 13, 21, .6); padding: 16px 12px; overflow-y: auto;
}
#new-design { width: 100%; margin-bottom: 16px; padding: 11px; }
.conv-item {
  padding: 10px; border-radius: var(--r-md); cursor: pointer; display: flex; gap: 11px;
  align-items: center; border: 1px solid transparent; position: relative; margin-bottom: 4px;
  transition: background .16s var(--ease), border-color .16s var(--ease);
}
.conv-item:hover { background: rgba(255, 255, 255, .045); }
.conv-item.active { background: rgba(255, 255, 255, .055); border-color: var(--line); }
.conv-item.active::before {
  content: ""; position: absolute; left: -1px; top: 12px; bottom: 12px; width: 3px;
  border-radius: 4px; background: var(--grad);
}
.conv-item img { width: 42px; height: 42px; object-fit: contain; border-radius: var(--r-sm); background: #fff; flex-shrink: 0; }
.conv-item .placeholder {
  width: 42px; height: 42px; border-radius: var(--r-sm); background: rgba(255, 255, 255, .06);
  display: flex; align-items: center; justify-content: center; color: var(--muted); flex-shrink: 0;
}
.conv-item .meta { min-width: 0; flex: 1; }
.conv-item .title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.conv-item .menu-btn { opacity: 0; color: var(--muted); padding: 4px 6px; border-radius: 6px; transition: opacity .15s; }
.conv-item .menu-btn:hover { background: rgba(255, 255, 255, .08); color: var(--text); }
.conv-item:hover .menu-btn { opacity: 1; }
.conv-menu {
  position: absolute; right: 8px; top: 44px; z-index: 20; min-width: 130px;
  background: rgba(22, 27, 40, .95); border: 1px solid var(--line); border-radius: var(--r-sm);
  overflow: hidden; box-shadow: var(--shadow);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.conv-menu button { display: block; width: 100%; text-align: left; padding: 9px 15px; font-size: 12.5px; transition: background .14s; }
.conv-menu button:hover { background: rgba(255, 255, 255, .07); }
.conv-menu .danger { color: var(--danger); }

/* ---------- chat ---------- */
#chat-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#chat-messages { flex: 1; overflow-y: auto; padding: 26px 30px; display: flex; flex-direction: column; gap: 18px; }
.bubble {
  max-width: 76%; padding: 12px 16px; border-radius: var(--r-lg);
  line-height: 1.75; white-space: pre-wrap; word-break: break-word; font-size: 13.5px;
  animation: bubbleIn .3s var(--ease);
}
@keyframes bubbleIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.bubble.user {
  align-self: flex-end;
  background: linear-gradient(120deg, rgba(57, 213, 255, .16), rgba(109, 106, 248, .2));
  border: 1px solid rgba(98, 150, 255, .3);
  border-bottom-right-radius: 6px;
}
.bubble.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, .045);
  border: 1px solid var(--line-soft);
  border-bottom-left-radius: 6px;
  position: relative; margin-left: 42px;
}
.bubble.assistant::before {
  content: ""; position: absolute; left: -42px; top: 2px;
  width: 30px; height: 30px; border-radius: 22%;
  background: url(/static/assets/favicon.svg) center / contain no-repeat;
  box-shadow: 0 4px 14px rgba(57, 213, 255, .28);
}
.bubble .imgs { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 10px; }
.bubble .imgs img {
  width: 112px; height: 112px; object-fit: contain; border-radius: var(--r-sm); background: #fff;
  cursor: zoom-in; transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.bubble .imgs img:hover { transform: scale(1.04); box-shadow: 0 8px 22px rgba(0, 0, 0, .4); }
.bubble.waiting { color: var(--muted); display: flex; align-items: center; gap: 10px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; background: #58a9ff; }
.dots i:nth-child(3) { animation-delay: .4s; background: var(--indigo); }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: scale(.9); } 40% { opacity: 1; transform: scale(1.1); } }

#composer {
  border-top: 1px solid var(--line-soft); padding: 14px 24px 16px;
  background: rgba(9, 12, 20, .7);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
#upload-previews { display: flex; gap: 9px; margin-bottom: 10px; }
#upload-previews:empty { margin-bottom: 0; }
.up-chip { position: relative; animation: bubbleIn .25s var(--ease); }
.up-chip img { width: 58px; height: 58px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); }
.up-chip button {
  position: absolute; top: -7px; right: -7px; width: 19px; height: 19px; border-radius: 50%;
  background: var(--danger); color: #fff; font-size: 11px; line-height: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
}
.composer-row { display: flex; gap: 10px; align-items: flex-end; }
#attach-btn {
  font-size: 17px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  transition: border-color .16s, background .16s, transform .16s;
}
#attach-btn:hover { border-color: rgba(255, 255, 255, .3); background: rgba(255, 255, 255, .05); transform: translateY(-1px); }
#chat-input {
  flex: 1; resize: none; max-height: 140px; padding: 11px 16px;
  background: rgba(0, 0, 0, .32); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-md);
  font: inherit; font-size: 13.5px; line-height: 1.65;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
#chat-input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(57, 213, 255, .13); }
#send-btn { padding: 11px 22px; }
.hint { color: var(--muted); font-size: 11px; margin-top: 9px; opacity: .8; }

/* ---------- design panel ---------- */
#panel-resizer {
  width: 7px; flex-shrink: 0; cursor: col-resize; position: relative; z-index: 4;
  transition: background .15s var(--ease);
}
#panel-resizer::after {
  content: ""; position: absolute; left: 2px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 44px; border-radius: 3px; background: rgba(255, 255, 255, .14);
  transition: background .15s var(--ease), height .15s var(--ease);
}
#panel-resizer:hover, #panel-resizer.dragging {
  background: rgba(57, 213, 255, .1);
}
#panel-resizer:hover::after, #panel-resizer.dragging::after {
  background: var(--grad); height: 70px;
}
#design-panel {
  width: 348px; min-width: 348px; border-left: 1px solid var(--line-soft);
  background: rgba(10, 13, 21, .6); padding: 18px; overflow-y: auto;
}
#product-card {
  display: flex; gap: 13px; align-items: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .025));
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 13px; margin-bottom: 12px;
}
#product-card img { width: 56px; height: 56px; object-fit: contain; border-radius: var(--r-sm); background: #fff; }
#product-card .name { font-weight: 700; font-size: 13px; }
#product-card .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
#print-info { margin-bottom: 12px; }
#print-info:empty { margin-bottom: 0; }
.pi-line { font-size: 12px; color: var(--text); padding: 2px 4px; }
.pi-line::before { content: "◆ "; font-size: 8px; vertical-align: 2px; color: var(--cyan); }
.pi-line.muted { color: var(--muted); font-size: 11px; }
.pi-line.muted::before { color: var(--muted); }
#design-toolbar { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; }
#design-toolbar button { font-size: 12.5px; padding: 8px 14px; }
#edit-actions { display: flex; gap: 8px; }
#preview-box {
  background: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .02));
  border: 1px solid var(--line); border-radius: var(--r-lg);
  min-height: 280px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden; box-shadow: var(--shadow);
}
#preview-box > img { width: 100%; height: auto; cursor: zoom-in; background: #fff; }
#preview-box .empty { color: var(--muted); text-align: center; line-height: 2; font-size: 12px; padding: 34px; }
#steps-strip { display: flex; gap: 9px; margin-top: 14px; flex-wrap: wrap; }
.step-thumb {
  position: relative; cursor: pointer; border-radius: var(--r-md); padding: 2px;
  transition: transform .16s var(--ease);
}
.step-thumb:hover { transform: translateY(-2px); }
.step-thumb img { width: 64px; height: 64px; object-fit: contain; border-radius: var(--r-sm); background: #fff; display: block; }
.step-thumb.active { background: var(--grad); box-shadow: 0 4px 16px rgba(57, 213, 255, .3); }
.step-thumb .lbl {
  position: absolute; left: 6px; bottom: 6px; background: rgba(3, 6, 12, .75); color: #dfe9ff;
  font-size: 9px; font-weight: 700; letter-spacing: .04em; padding: 1px 6px; border-radius: 6px;
  backdrop-filter: blur(4px);
}

/* ---------- edit mode ---------- */
#edit-stage { position: relative; width: 100%; user-select: none; touch-action: none; }
#edit-stage .base { width: 100%; display: block; }
.edit-box {
  position: absolute; border: 2px dashed rgba(57, 213, 255, .65);
  background: rgba(57, 213, 255, .05); pointer-events: none; border-radius: 4px;
}
.edit-region { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.edit-region polygon {
  fill: rgba(57, 213, 255, .06);
  stroke: rgba(57, 213, 255, .65); stroke-width: 2; stroke-dasharray: 10 7;
  vector-effect: non-scaling-stroke;
}
.motif { position: absolute; cursor: grab; border: 1.5px dashed transparent; border-radius: 4px; }
.motif:hover, .motif.dragging { border-color: var(--indigo); }
.motif.dragging { cursor: grabbing; }
.motif img, .motif .m-canvas { width: 100%; display: block; pointer-events: none; }
.m-label {
  position: absolute; left: 50%; bottom: -22px; transform: translateX(-50%);
  background: rgba(5, 8, 15, .88); color: var(--cyan); font-size: 10px; font-weight: 600;
  padding: 2px 9px; border-radius: 8px; white-space: nowrap; pointer-events: none;
  border: 1px solid rgba(57, 213, 255, .25);
}
.m-handle {
  position: absolute; right: -9px; bottom: -9px; width: 17px; height: 17px;
  border-radius: 50%; background: var(--grad); border: 2.5px solid #0a0d15;
  cursor: nwse-resize; touch-action: none;
  box-shadow: 0 2px 10px rgba(57, 213, 255, .4);
}
.edit-hint { color: var(--muted); font-size: 11px; text-align: center; padding: 10px 0 4px; }

/* ---------- lightbox / toast ---------- */
#lightbox {
  position: fixed; inset: 0; background: rgba(4, 6, 11, .82); z-index: 100;
  display: flex; align-items: center; justify-content: center; cursor: zoom-out; padding: 34px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: fadeIn .2s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
#lightbox img {
  max-width: 92vw; max-height: 92vh; border-radius: var(--r-lg); background: #fff;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .6);
  animation: rise .25s var(--ease);
}
#toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); z-index: 110;
  background: rgba(20, 25, 38, .92); border: 1px solid var(--line); color: var(--text);
  padding: 11px 20px; border-radius: var(--r-md); font-size: 13px; max-width: 80vw;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  animation: toastIn .3s var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
#toast.error { border-color: rgba(255, 95, 122, .5); box-shadow: 0 10px 34px rgba(255, 95, 122, .18); }

/* ---------- narrow screens ---------- */
@media (max-width: 980px) {
  #view-workspace { flex-direction: column; overflow-y: auto; }
  #sidebar { width: 100%; min-width: 0; max-height: 190px; border-right: none; border-bottom: 1px solid var(--line-soft); }
  #panel-resizer { display: none; }
  #design-panel { width: 100% !important; min-width: 0 !important; border-left: none; border-top: 1px solid var(--line-soft); }
  #chat-messages { min-height: 300px; }
  .picker-body { flex-direction: column; }
  #picker-options { width: 100%; position: static; }
  body::before, body::after { display: none; }
}
