:root {
  --bg-deep: #0b1020;
  --bg-mid: #121830;
  --bg-glass: rgba(22, 28, 52, 0.62);
  --bg-glass-strong: rgba(28, 34, 62, 0.88);
  --border: rgba(180, 200, 255, 0.14);
  --border-strong: rgba(180, 200, 255, 0.28);
  --text: #e8ecf8;
  --text-dim: #9aa3c0;
  --text-faint: #6d7696;
  --accent-sakura: #f6a6c8;
  --accent-aqua: #9ae6ff;
  --accent-lilac: #c4a0ff;
  --accent-warm: #fff6c8;
  --danger: #ff7a9a;
  --success: #7dffa8;
  --pos-bg: rgba(120, 200, 240, 0.14);
  --pos-border: rgba(154, 230, 255, 0.45);
  --pos-text: #b8f0ff;
  --neg-bg: rgba(246, 166, 200, 0.14);
  --neg-border: rgba(246, 166, 200, 0.5);
  --neg-text: #ffd0e4;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --radius-sm: 12px;
  --header-h: 64px;
  --bar-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: system-ui, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP",
    "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Consolas",
    "Liberation Mono", monospace;
  --ease-spring: cubic-bezier(0.22, 1.2, 0.36, 1);
  --ease-out: cubic-bezier(0.22, 0.9, 0.3, 1);
  --focus: 0 0 0 3px rgba(154, 230, 255, 0.45);
  --side-w: 380px;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-deep);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  overflow-x: hidden;
  padding-top: calc(var(--header-h) + var(--safe-t));
  padding-bottom: calc(var(--bar-h) + var(--safe-b) + 12px);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

a {
  color: var(--accent-aqua);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: 10px;
}

#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: calc(var(--header-h) + var(--safe-t));
  padding: var(--safe-t) 14px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(
    180deg,
    rgba(11, 16, 32, 0.94) 0%,
    rgba(11, 16, 32, 0.78) 70%,
    rgba(11, 16, 32, 0) 100%
  );
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.brand-logo-wrap {
  display: inline-flex;
  flex-shrink: 0;
  filter: drop-shadow(0 0 8px rgba(154, 230, 255, 0.35));
  animation: logoBreathe 3.6s ease-in-out infinite;
}

.brand-logo-wrap svg {
  display: block;
}

@keyframes logoBreathe {
  0%,
  100% {
    filter: drop-shadow(0 0 6px rgba(154, 230, 255, 0.28));
    transform: scale(1);
  }
  50% {
    filter: drop-shadow(0 0 14px rgba(246, 166, 200, 0.45));
    transform: scale(1.04);
  }
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.brand-title-sub {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.brand-title-main {
  font-size: clamp(0.98rem, 4.2vw, 1.12rem);
  font-weight: 750;
  letter-spacing: 0.02em;
  background: linear-gradient(120deg, var(--accent-aqua), var(--accent-sakura) 55%, var(--accent-lilac));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-sub {
  display: none;
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

@media (max-width: 719px) {
  .app-header {
    gap: 8px;
    padding-left: 10px;
    padding-right: 8px;
  }

  .brand-logo-wrap svg {
    width: 34px;
    height: 34px;
  }

  .header-actions .icon-btn {
    width: 40px;
    height: 40px;
  }
}

.btn-new-header {
  min-height: 36px;
  padding: 0 10px;
  border-radius: 12px;
  background: linear-gradient(
    135deg,
    rgba(154, 230, 255, 0.88),
    rgba(246, 166, 200, 0.88)
  );
  color: #12162a;
  font-weight: 700;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 4px 16px rgba(154, 230, 255, 0.22);
  transition: transform 0.18s var(--ease-spring);
  flex-shrink: 0;
}

@media (max-width: 380px) {
  .btn-new-header .btn-new-label {
    display: none;
  }

  .btn-new-header {
    width: 36px;
    padding: 0;
    justify-content: center;
  }
}

.btn-new-header:active {
  transform: scale(0.96);
}

.btn-new-header svg {
  width: 16px;
  height: 16px;
}

.btn.btn-new-inline {
  display: none;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  color: var(--text);
  transition: transform 0.2s var(--ease-spring), background 0.2s ease,
    color 0.2s ease;
  position: relative;
}

.icon-btn:hover {
  background: rgba(154, 230, 255, 0.1);
  color: var(--accent-aqua);
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn.is-active {
  color: var(--accent-sakura);
  background: rgba(246, 166, 200, 0.12);
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0 12px;
}

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

.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box:focus-within {
  border-color: rgba(154, 230, 255, 0.45);
  box-shadow: var(--shadow), 0 0 0 3px rgba(154, 230, 255, 0.18);
}

.search-box svg {
  flex-shrink: 0;
  color: var(--text-dim);
}

.search-box input {
  flex: 1;
  border: none;
  background: transparent;
  min-width: 0;
  padding: 12px 0;
}

.search-box input:focus {
  outline: none;
  box-shadow: none;
}

.search-box input::placeholder {
  color: var(--text-faint);
}

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

.chip-toggle,
.select-pill {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-glass);
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.18s var(--ease-spring), background 0.2s,
    border-color 0.2s, color 0.2s;
}

.chip-toggle:active,
.tag-chip:active {
  transform: scale(0.94);
}

.chip-toggle.is-on {
  color: var(--accent-warm);
  border-color: rgba(255, 246, 200, 0.45);
  background: rgba(255, 246, 200, 0.1);
}

.select-pill {
  appearance: none;
  padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 14px) calc(50% - 2px),
    calc(100% - 9px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.tag-filter-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.tag-filter-chip {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(20, 26, 48, 0.55);
  color: var(--text-dim);
  font-size: 0.8rem;
  transition: transform 0.18s var(--ease-spring), background 0.2s,
    border-color 0.2s, color 0.2s;
}

.tag-filter-chip.is-on {
  color: var(--accent-aqua);
  border-color: rgba(154, 230, 255, 0.5);
  background: rgba(154, 230, 255, 0.12);
}

/* Stats */
.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(28, 34, 62, 0.45);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  font-size: 0.8rem;
  color: var(--text-dim);
}

.stat-chip strong {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-chip .stat-label {
  color: var(--text-faint);
}

.stat-chip.is-fav {
  border-color: rgba(255, 246, 200, 0.28);
}

.stat-chip.is-fav strong {
  color: var(--accent-warm);
}

.stat-chip.is-tag strong {
  color: var(--accent-lilac);
}

/* Layout */
.main-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px 48px;
  color: var(--text-dim);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: rgba(18, 24, 48, 0.45);
  backdrop-filter: blur(10px);
}

.empty-illust {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
  opacity: 0.95;
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
  color: var(--text);
}

.empty-state p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Cards */
.prompt-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  transition: transform 0.35s var(--ease-out), opacity 0.35s var(--ease-out),
    border-color 0.25s, box-shadow 0.35s var(--ease-out);
  cursor: pointer;
  overflow: hidden;
}

.prompt-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(154, 230, 255, 0.05),
    transparent 45%,
    rgba(246, 166, 200, 0.05)
  );
  pointer-events: none;
  z-index: 0;
}

.prompt-card::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    135deg,
    rgba(154, 230, 255, 0),
    rgba(246, 166, 200, 0),
    rgba(196, 160, 255, 0)
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
  z-index: 1;
}

.prompt-card > * {
  position: relative;
  z-index: 2;
}

.prompt-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-4px);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.4),
    0 0 28px rgba(154, 230, 255, 0.12), 0 0 36px rgba(246, 166, 200, 0.1);
}

.prompt-card:hover::after {
  opacity: 1;
  background: linear-gradient(
    135deg,
    rgba(154, 230, 255, 0.65),
    rgba(246, 166, 200, 0.45),
    rgba(196, 160, 255, 0.55)
  );
}

.prompt-card.is-exiting {
  opacity: 0;
  transform: scale(0.96);
}

.card-media {
  position: relative;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: #141a30;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.card-media-frame {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.card-media-frame img,
.card-media-frame .prompt-art-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-media-frame .prompt-art-svg {
  display: block;
}

.card-ratio-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 2;
  font-size: 0.65rem;
  font-weight: 650;
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(10, 14, 28, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
  backdrop-filter: blur(6px);
  font-variant-numeric: tabular-nums;
}

.card-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card-top {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.card-title {
  flex: 1;
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.fav-btn {
  width: 40px;
  height: 40px;
  margin: -6px -4px 0 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  color: var(--text-dim);
  position: relative;
  transition: transform 0.25s var(--ease-spring), color 0.2s;
  flex-shrink: 0;
}

.fav-btn.is-on {
  color: var(--accent-warm);
}

.fav-btn.is-pop {
  transform: scale(1.2);
}

.card-preview {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(180, 200, 255, 0.08);
  word-break: break-word;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.mini-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 7px;
  background: rgba(154, 230, 255, 0.08);
  color: var(--text-dim);
  border: 1px solid rgba(154, 230, 255, 0.16);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.mini-badge.is-sampler {
  background: rgba(196, 160, 255, 0.1);
  border-color: rgba(196, 160, 255, 0.22);
  color: #d8c4ff;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.mini-tag {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(196, 160, 255, 0.12);
  color: #d8c4ff;
  border: 1px solid rgba(196, 160, 255, 0.22);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 2px;
}

.card-actions-copy {
  display: flex;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.card-actions-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-left: 8px;
  margin-left: 2px;
  border-left: 1px solid var(--border);
  flex-shrink: 0;
}

.card-actions-tools .icon-btn {
  width: 36px;
  height: 36px;
}

.copy-pill {
  position: relative;
  overflow: hidden;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: transform 0.18s var(--ease-spring), background 0.2s,
    border-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.copy-pill svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.copy-pill.is-pos {
  background: var(--pos-bg);
  border: 1px solid var(--pos-border);
  color: var(--pos-text);
}

.copy-pill.is-neg {
  background: var(--neg-bg);
  border: 1px solid var(--neg-border);
  color: var(--neg-text);
}

.copy-pill:hover {
  transform: translateY(-1px);
}

.copy-pill.is-pos:hover {
  box-shadow: 0 0 14px rgba(154, 230, 255, 0.22);
}

.copy-pill.is-neg:hover {
  box-shadow: 0 0 14px rgba(246, 166, 200, 0.22);
}

.copy-pill.is-copied {
  color: var(--success);
  border-color: rgba(125, 255, 168, 0.55);
  background: rgba(125, 255, 168, 0.12);
}

.copy-pill .ripple,
.copy-btn .ripple {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  left: 50%;
  top: 50%;
  margin: -4px 0 0 -4px;
  background: rgba(125, 255, 168, 0.45);
  transform: scale(0);
  animation: ripple 0.55s var(--ease-out) forwards;
  pointer-events: none;
}

@keyframes ripple {
  to {
    transform: scale(14);
    opacity: 0;
  }
}

/* Side panel / tag builder (desktop) */
.side-panel {
  display: none;
}

.panel-card {
  border-radius: var(--radius);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 14px;
  box-shadow: var(--shadow);
}

.panel-card > h2,
.builder-root > h2 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.builder-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.builder-preview-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.builder-preview-block {
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid var(--border);
  overflow: hidden;
}

.builder-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 6px 10px;
  border-bottom: 1px solid rgba(180, 200, 255, 0.08);
}

.builder-preview-label {
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.builder-preview-block.is-pos .builder-preview-label {
  color: var(--pos-text);
}

.builder-preview-block.is-neg .builder-preview-label {
  color: var(--neg-text);
}

.builder-preview-text {
  margin: 0;
  padding: 10px;
  max-height: 96px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
}

.tag-category {
  margin-bottom: 14px;
}

.tag-category-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px;
  color: var(--accent-sakura);
}

.tag-category-head svg {
  flex-shrink: 0;
  opacity: 0.9;
}

.tag-category h3 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(16, 22, 42, 0.65);
  color: var(--text);
  position: relative;
  overflow: hidden;
  transition: transform 0.18s var(--ease-spring), background 0.2s,
    border-color 0.2s, box-shadow 0.2s;
}

.tag-chip .tag-en {
  font-size: 0.78rem;
  font-weight: 600;
}

.tag-chip .tag-ja {
  font-size: 0.65rem;
  color: var(--text-faint);
}

.tag-chip.is-selected {
  border-color: rgba(154, 230, 255, 0.55);
  background: rgba(154, 230, 255, 0.14);
  box-shadow: 0 0 0 1px rgba(154, 230, 255, 0.15),
    0 0 16px rgba(154, 230, 255, 0.12);
}

.tag-chip.is-bounce {
  animation: chipBounce 0.32s var(--ease-spring);
}

.tag-chip .chip-spark {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent-warm);
  pointer-events: none;
  animation: chipSpark 0.55s var(--ease-out) forwards;
}

@keyframes chipBounce {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(0.9);
  }
  70% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes chipSpark {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--sx), var(--sy)) scale(0.2);
  }
}

.weight-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.weight-row .icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.weight-val {
  font-size: 0.7rem;
  color: var(--accent-aqua);
  min-width: 2.4em;
  text-align: center;
}

/* Bottom bar */
.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  min-height: calc(var(--bar-h) + var(--safe-b));
  padding: 8px 14px calc(8px + var(--safe-b));
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 8px;
  background: linear-gradient(
    0deg,
    rgba(11, 16, 32, 0.96) 0%,
    rgba(11, 16, 32, 0.78) 70%,
    rgba(11, 16, 32, 0) 100%
  );
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.bar-btn {
  flex: 1;
  max-width: 120px;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 16px;
  color: var(--text-dim);
  font-size: 0.68rem;
  transition: transform 0.2s var(--ease-spring), color 0.2s, background 0.2s;
}

.bar-btn:hover,
.bar-btn:focus-visible {
  color: var(--text);
  background: rgba(154, 230, 255, 0.08);
}

.fab {
  width: 58px;
  height: 58px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent-aqua), var(--accent-sakura));
  color: #12162a;
  box-shadow: 0 10px 28px rgba(154, 230, 255, 0.28);
  transform: translateY(-10px);
  transition: transform 0.25s var(--ease-spring);
}

.fab:active {
  transform: translateY(-10px) scale(0.94);
}

/* Overlay / sheet / modal */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(6, 8, 18, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  max-height: min(96vh, 100%);
  background: var(--bg-glass-strong);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: var(--shadow);
  transform: translateY(calc(100% + 24px));
  transition: transform 0.38s var(--ease-spring), visibility 0s linear 0.38s;
  visibility: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-b);
}

.sheet.is-open {
  transform: translateY(0);
  visibility: visible;
  transition: transform 0.38s var(--ease-spring), visibility 0s;
}

.sheet.is-dragging {
  transition: none;
}

.sheet-handle {
  display: flex;
  justify-content: center;
  padding: 10px 0 2px;
  flex-shrink: 0;
  touch-action: none;
  cursor: grab;
}

.sheet-handle span {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: rgba(180, 200, 255, 0.28);
}

.sheet-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sheet-header h2 {
  flex: 1;
  margin: 0;
  font-size: 1.05rem;
}

.sheet-body {
  overflow: auto;
  padding: 14px;
  flex: 1;
  overscroll-behavior: contain;
}

.sheet-footer {
  display: flex;
  gap: 8px;
  padding: 12px 14px calc(12px + var(--safe-b));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.btn {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.18s var(--ease-spring), background 0.2s;
}

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

.btn-primary {
  background: linear-gradient(
    135deg,
    rgba(154, 230, 255, 0.9),
    rgba(246, 166, 200, 0.9)
  );
  color: #12162a;
  border: none;
  font-weight: 700;
  flex: 1;
}

.btn-danger {
  color: var(--danger);
  border-color: rgba(255, 122, 154, 0.4);
  background: rgba(255, 122, 154, 0.08);
}

.btn-ghost {
  background: transparent;
}

.form-grid {
  display: grid;
  gap: 16px;
}

.form-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.14);
  border: 1px solid rgba(180, 200, 255, 0.08);
}

.form-section-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent-aqua);
}

.field label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.22);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: rgba(154, 230, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(154, 230, 255, 0.18),
    0 0 20px rgba(154, 230, 255, 0.1);
}

.field textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.45;
}

.mono-field {
  font-family: var(--mono);
  font-size: 0.82rem;
}

.field-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

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

.thumb-picker {
  display: flex;
  align-items: center;
  gap: 12px;
}

.thumb-preview {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  background: #1a2140;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.thumb-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.detail-actions .copy-pill {
  min-height: 40px;
  padding: 0 14px;
  font-size: 0.8rem;
}

.detail-block {
  margin-bottom: 14px;
}

.detail-block h3 {
  margin: 0 0 6px;
  font-size: 0.78rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.detail-text {
  margin: 0;
  padding: 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.88rem;
  line-height: 1.45;
  font-family: var(--mono);
}

.params-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 0.82rem;
}

.params-list div {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border);
}

.params-list span {
  display: block;
  color: var(--text-faint);
  font-size: 0.7rem;
  margin-bottom: 2px;
}

/* Toast */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bar-h) + var(--safe-b) + 16px);
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: min(92vw, 360px);
}

.toast {
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(28, 34, 62, 0.92);
  border: 1px solid var(--border-strong);
  color: var(--text);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transition: opacity 0.28s var(--ease-out), transform 0.28s var(--ease-spring);
  text-align: center;
  font-size: 0.88rem;
}

.toast.is-show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Modal dialog */
.modal {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 70;
  width: min(92vw, 420px);
  padding: 18px;
  border-radius: 20px;
  background: var(--bg-glass-strong);
  border: 1px solid var(--border);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: var(--shadow);
  transform: translate(-50%, -46%) scale(0.92);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.32s var(--ease-spring), opacity 0.25s ease;
}

.modal.is-open {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.modal h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.modal p {
  margin: 0 0 14px;
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

/* Particles */
.particle-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-warm);
  opacity: 0;
  animation: particleFly 0.7s var(--ease-out) forwards;
}

@keyframes particleFly {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(0.2);
  }
}

.ios-hint {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Desktop */
@media (min-width: 720px) {
  body {
    padding-bottom: 24px;
  }

  .bottom-bar {
    display: none;
  }

  .toast-host {
    bottom: 24px;
  }

  .brand-sub {
    display: block;
  }

  .brand-title {
    flex-direction: row;
    align-items: baseline;
    gap: 0.35em;
    flex-wrap: wrap;
  }

  .brand-title-sub {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: linear-gradient(120deg, var(--accent-aqua), var(--accent-sakura));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }

  .brand-title-main {
    font-size: 1.05rem;
  }

  .btn-new-header {
    display: none;
  }

  .btn.btn-new-inline {
    display: inline-flex;
    min-height: 48px;
    padding: 0 16px;
    border-radius: 14px;
    background: linear-gradient(
      135deg,
      rgba(154, 230, 255, 0.9),
      rgba(246, 166, 200, 0.9)
    );
    color: #12162a;
    font-weight: 700;
    font-size: 0.88rem;
    border: none;
    white-space: nowrap;
    box-shadow: 0 6px 18px rgba(154, 230, 255, 0.2);
    flex-shrink: 0;
  }

  .main-layout {
    grid-template-columns: minmax(0, 1fr) var(--side-w);
    gap: 20px;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }

  .side-panel {
    display: block;
    width: var(--side-w);
    position: sticky;
    top: calc(var(--header-h) + 12px);
    max-height: calc(100vh - var(--header-h) - 24px);
    align-self: start;
  }

  .side-panel .panel-card {
    max-height: calc(100vh - var(--header-h) - 24px);
    overflow: auto;
    overscroll-behavior: contain;
  }

  .sheet {
    left: 50%;
    right: auto;
    width: min(640px, 92vw);
    transform: translate(-50%, calc(100% + 10vh));
    border-radius: 24px;
    border-bottom: 1px solid var(--border);
    max-height: min(90vh, 900px);
    bottom: 3vh;
  }

  .sheet.is-open {
    transform: translate(-50%, 0);
  }
}

@media (min-width: 1100px) {
  .app-shell {
    padding: 0 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .brand-logo-wrap {
    animation: none;
    filter: drop-shadow(0 0 8px rgba(154, 230, 255, 0.3));
  }
}

@media (max-width: 719px) {
  .card-media-frame {
    padding-bottom: 0 !important;
    height: clamp(150px, 42vw, 200px);
  }
}
