/* ============================================================
   TIER MAKER — Design System
   Theme: Architectural Dark / Geometric Modern
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Inter:wght@300;400;500&display=swap');

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg-base:     #060606;
  --bg-surface:  #0E0E0E;
  --bg-elevated: #161616;
  --bg-hover:    #1E1E1E;

  --border:      #1F1F1F;
  --border-mid:  #2C2C2C;
  --border-hi:   #404040;

  --text-primary:   #EDEDED;
  --text-secondary: #666666;
  --text-muted:     #383838;

  --accent:          #D4307A;
  --accent-dim:      rgba(212,48,122,0.12);
  --accent-hover:    #E8356B;
  --accent-gradient: linear-gradient(135deg, #E8356B 0%, #8833CC 50%, #4499EE 100%);

  --danger:      #FF3B3B;
  --danger-dim:  rgba(255,59,59,0.1);
  --success:     #00CC66;

  /* Tier default colors */
  --tier-s: #FF3333;
  --tier-a: #FF8800;
  --tier-b: #FFD000;
  --tier-c: #33BB55;
  --tier-d: #4488FF;

  --header-h: 56px;
  --tray-w:   260px;
  --ad-w:     300px;
  --radius:   2px;

  --font-ui:   'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: var(--font-ui); cursor: pointer; border: none; background: none; }
input, textarea { font-family: var(--font-body); }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 0; }

/* ── Header ────────────────────────────────────────────────── */
.header {
  position: fixed; top: 2px; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: var(--bg-base);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0;
}
.app-layout { margin-top: calc(var(--header-h) + 2px) !important; }

/* ── 共有閲覧バナー ─────────────────────────────────────── */
.share-view-banner {
  position: fixed; top: calc(var(--header-h) + 2px); left: 0; right: 0;
  background: var(--accent-gradient);
  color: #fff;
  font-family: var(--font-ui); font-size: 12px; font-weight: 500;
  text-align: center;
  padding: 6px 16px;
  z-index: 99;
}
.share-view-banner.hidden { display: none; }
body.share-view .app-layout { margin-top: calc(var(--header-h) + 2px + 32px) !important; }

.header-logo {
  width: var(--tray-w);
  padding: 0 20px;
  display: flex; align-items: center; gap: 10px;
  border-right: 1px solid var(--border);
  height: 100%;
  flex-shrink: 0;
}
.header-logo-mark {
  font-family: var(--font-ui);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  flex: 1;
  display: flex; align-items: center; gap: 4px;
  padding: 0 16px;
}

.header-right {
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px;
  border-left: 1px solid var(--border);
  height: 100%;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  font-family: var(--font-ui); font-size: 13px; font-weight: 500;
  border-radius: var(--radius);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.btn-ghost {
  color: var(--text-secondary);
  background: transparent;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-ghost:disabled { opacity: 0.3; pointer-events: none; }

.btn-outline {
  color: var(--text-primary);
  border: 1px solid var(--border-mid);
  background: transparent;
}
.btn-outline:hover {
  border-color: transparent;
  background: linear-gradient(var(--bg-hover), var(--bg-hover)) padding-box,
              var(--accent-gradient) border-box;
}

.btn-accent {
  background: var(--accent-gradient); color: #fff;
  font-weight: 600;
}
.btn-accent:hover { background: var(--accent); }

.btn-danger {
  color: var(--danger);
  border: 1px solid var(--danger);
  background: transparent;
}
.btn-danger:hover { background: var(--danger-dim); }

.btn-sm { height: 26px; padding: 0 8px; font-size: 12px; }
.btn-icon { width: 32px; padding: 0; justify-content: center; }
.btn-icon.btn-sm { width: 26px; }

.kbd {
  display: inline-block;
  font-size: 10px; color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 1px 4px;
  line-height: 1.6;
}

/* ── Divider ───────────────────────────────────────────────── */
.divider-v {
  width: 1px; height: 20px;
  background: var(--border);
  margin: 0 4px; flex-shrink: 0;
}

/* ── Layout ────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  margin-top: var(--header-h);
  height: calc(100vh - var(--header-h));
}

/* ── Tray (left panel) ─────────────────────────────────────── */
.tray-panel {
  width: var(--tray-w);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  background: var(--bg-surface);
  overflow: hidden;
  flex-shrink: 0;
}

.tray-section {
  border-bottom: 1px solid var(--border);
}

.tray-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  font-family: var(--font-ui); font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-primary);
}

.tray-actions {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 12px;
}

.btn-upload {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; width: 100%;
  border: 1px dashed var(--border-mid);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-ui); font-size: 13px; font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
}
.btn-upload:hover {
  border-style: solid;
  border-color: transparent;
  background: linear-gradient(var(--bg-hover), var(--bg-hover)) padding-box,
              var(--accent-gradient) border-box;
}
.btn-upload.drag-over {
  border-style: solid;
  border-color: transparent;
  background: linear-gradient(var(--accent-dim), var(--accent-dim)) padding-box,
              var(--accent-gradient) border-box;
}

.search-input-wrap {
  position: relative;
  padding: 0 12px 10px;
}
.search-input {
  width: 100%; height: 34px; padding: 0 10px 0 32px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary); font-size: 13px;
  outline: none; transition: border-color 0.12s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-secondary); }
.search-icon {
  position: absolute; left: 22px; top: 50%; transform: translateY(-50%);
  color: var(--text-secondary); pointer-events: none;
}

.slots-section {
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.slots-list {
  padding: 4px 8px 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.slot-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  gap: 6px;
}
.slot-item.slot-empty { opacity: 0.5; }
.slot-info {
  display: flex; align-items: center; gap: 8px;
  min-width: 0; flex: 1;
}
.slot-num {
  font-family: var(--font-ui); font-size: 11px; font-weight: 700;
  color: var(--accent); width: 14px; flex-shrink: 0;
}
.slot-meta { min-width: 0; }
.slot-title {
  font-size: 11px; font-weight: 500; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100px;
}
.slot-date { font-size: 10px; color: var(--text-secondary); margin-top: 1px; }
.slot-empty-label { font-size: 11px; color: var(--text-muted); }
.slot-btns { display: flex; gap: 3px; flex-shrink: 0; }
.slot-btn {
  font-family: var(--font-ui); font-size: 10px; font-weight: 600;
  padding: 3px 6px; border-radius: var(--radius);
  border: 1px solid var(--border-mid);
  color: var(--text-secondary); background: var(--bg-surface);
  cursor: pointer; transition: all 0.15s;
}
.slot-btn:hover { border-color: var(--accent); color: var(--accent); }
.slot-btn-load {
  border-color: transparent;
  background: linear-gradient(var(--bg-surface), var(--bg-surface)) padding-box,
              var(--accent-gradient) border-box;
  color: var(--accent);
}
.slot-btn-load:hover {
  background: var(--accent-gradient) padding-box, var(--accent-gradient) border-box;
  color: #fff;
  border-color: transparent;
}
.slot-btn-del:hover { border-color: var(--danger); color: var(--danger); }

.tray-items {
  flex: 1; overflow-y: auto;
  padding: 8px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  align-content: start;
  min-height: 0;
}

.tray-item {
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: grab;
  border: 1px solid var(--border);
  position: relative;
  background: var(--bg-elevated);
  transition: border-color 0.12s, transform 0.12s;
}
.tray-item:hover {
  border-color: transparent;
  background: linear-gradient(var(--bg-elevated), var(--bg-elevated)) padding-box,
              var(--accent-gradient) border-box;
  transform: scale(1.03); z-index: 1;
}
.tray-item:active { cursor: grabbing; }
.tray-item img { width: 100%; height: 100%; object-fit: cover; }

.tray-item-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 3px 4px;
  font-size: 9px; font-family: var(--font-ui);
  color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.tray-item-text {
  width: 100%; aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-ui); font-size: 11px;
  color: var(--text-secondary); text-align: center;
  padding: 4px;
  word-break: break-word;
}

.tray-empty {
  grid-column: 1/-1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 24px;
  color: var(--text-muted);
  font-size: 12px; text-align: center;
}

/* ── Tier Board (center) ───────────────────────────────────── */
.board-panel {
  flex: 1; overflow-y: auto;
  background: var(--bg-base);
  display: flex; flex-direction: column;
  min-width: 0;
}

.board-inner {
  flex: 1; padding: 24px;
  display: flex; flex-direction: column; gap: 0;
}

.board-title-bar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px;
  position: relative;
}

.board-title-label {
  font-family: var(--font-ui); font-size: 10px; font-weight: 700;
  letter-spacing: 0.12em;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  flex-shrink: 0;
  user-select: none;
}

.board-title-input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--border-mid);
  color: var(--text-primary);
  font-family: var(--font-ui); font-size: 20px; font-weight: 600;
  letter-spacing: -0.01em;
  padding: 4px 24px 4px 0;
  outline: none;
  cursor: text;
  transition: border-color 0.12s;
}
.board-title-input:hover {
  border-bottom-color: transparent;
  background-image: var(--accent-gradient);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 2px;
}
.board-title-input:focus {
  border-bottom-color: transparent;
  background-image: var(--accent-gradient);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 2px;
}
.board-title-input::placeholder { color: var(--text-muted); }

/* ホバー時に鉛筆アイコンを表示 */
.board-title-bar::after {
  content: '✏';
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  font-size: 13px; color: var(--text-muted);
  pointer-events: none; opacity: 0;
  transition: opacity 0.15s;
}
.board-title-bar:hover::after { opacity: 1; }
.board-title-input:focus ~ * { opacity: 0; }

/* ── Tier Row ──────────────────────────────────────────────── */
.tier-list {
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
}

.tier-row {
  display: flex;
  min-height: 80px;
  border-bottom: 1px solid var(--border);
  position: relative;
  transition: background 0.1s;
}
.tier-row:last-child { border-bottom: none; }
.tier-row.drag-target { background: var(--accent-dim); }

.tier-label-wrap {
  width: 80px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  border-right: 1px solid var(--border);
}

.tier-label {
  font-family: var(--font-ui); font-size: 22px; font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  width: 100%; padding: 8px;
  cursor: pointer; outline: none;
  border: none; background: transparent;
  color: #000;
  caret-color: #000;
}
.tier-label::selection { background: rgba(0,0,0,0.2); }

.tier-items-zone {
  flex: 1; padding: 8px;
  display: flex; flex-wrap: wrap; gap: 6px;
  align-content: flex-start;
  min-height: 80px;
}
.tier-items-zone.sortable-drag-over {
  background: var(--accent-dim);
  outline: 1px dashed var(--accent);
  outline-offset: -4px;
}

.tier-item {
  width: 68px; height: 68px;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: grab;
  border: 1px solid rgba(128,128,128,0.2);
  position: relative;
  background: var(--bg-elevated);
  flex-shrink: 0;
  transition: transform 0.1s, box-shadow 0.1s;
}
.tier-item:hover { transform: scale(1.05); z-index: 2; box-shadow: 0 4px 16px rgba(0,0,0,0.5); }
.tier-item:active { cursor: grabbing; }
.tier-item img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.tier-item-lbl {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 3px 3px;
  font-size: 8px; font-family: var(--font-ui);
  color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tier-item-text-only {
  width: 68px; height: 68px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-ui); font-size: 11px; font-weight: 500;
  color: var(--text-primary);
  text-align: center; padding: 6px;
  word-break: break-word;
  cursor: grab;
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  flex-shrink: 0;
}

.tier-row-controls {
  width: 28px; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px;
  padding: 4px 0;
  border-left: 1px solid var(--border);
  opacity: 0;
  transition: opacity 0.15s;
}
.tier-row:hover .tier-row-controls { opacity: 1; }

.tier-ctrl-btn {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  border-radius: var(--radius);
  font-size: 12px;
  transition: color 0.1s, background 0.1s;
}
.tier-ctrl-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.tier-ctrl-btn.danger:hover { color: var(--danger); }

/* Add tier button */
.add-tier-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; margin-top: 12px;
  border: 1px dashed var(--border-mid);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-family: var(--font-ui); font-size: 12px; font-weight: 500;
  letter-spacing: 0.05em;
  cursor: pointer; width: 100%;
  transition: all 0.15s;
}
.add-tier-btn:hover {
  border-style: solid;
  border-color: transparent;
  background: linear-gradient(var(--bg-hover), var(--bg-hover)) padding-box,
              var(--accent-gradient) border-box;
  color: var(--text-primary);
}

/* ── Ad Panel (right) ──────────────────────────────────────── */
.ad-panel {
  width: var(--ad-w);
  border-left: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
  display: flex; flex-direction: column;
  overflow-y: auto;
}

.ad-label {
  padding: 10px 14px;
  font-family: var(--font-ui); font-size: 10px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.ad-slot {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.ad-slot-placeholder {
  height: 250px;
  background: var(--bg-elevated);
  border: 1px dashed var(--border-mid);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 11px;
  font-family: var(--font-ui);
}

/* ── Footer (affiliate disclosure) ────────────────────────── */
.footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
}
.footer-text {
  font-size: 11px; color: var(--text-secondary); line-height: 1.6;
}
.footer-links {
  display: flex; gap: 16px;
}
.footer-links a {
  font-size: 11px; color: var(--text-secondary);
  font-family: var(--font-ui);
  transition: color 0.12s;
}
.footer-links a:hover { color: var(--text-primary); }

/* ── Auth Badge ────────────────────────────────────────────── */
.auth-btn {
  display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  font-family: var(--font-ui); font-size: 13px; font-weight: 500;
  color: var(--text-primary);
  background: transparent;
  cursor: pointer;
  transition: all 0.12s;
}
.auth-btn:hover { border-color: var(--border-hi); background: var(--bg-hover); }

.auth-avatar {
  width: 24px; height: 24px;
  border-radius: 50%; object-fit: cover;
  border: 1px solid var(--border-mid);
}

.user-menu {
  position: absolute; top: calc(var(--header-h) + 4px); right: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  min-width: 180px;
  z-index: 200;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}
.user-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  font-family: var(--font-ui); font-size: 13px; color: var(--text-primary);
  cursor: pointer;
  transition: background 0.1s;
  border: none; background: transparent; width: 100%; text-align: left;
}
.user-menu-item:hover { background: var(--bg-hover); }
.user-menu-item.danger { color: var(--danger); }
.user-menu-divider { height: 1px; background: var(--border); }
.user-menu.hidden { display: none; }

/* ── Accent Stripe (brand) ──────────────────────────────── */
body::before {
  content: '';
  display: block;
  position: fixed; top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent-gradient);
  z-index: 999;
}

/* ── Design Toolbar ─────────────────────────────────────── */
.design-toolbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 14px;
  margin-bottom: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
}
.design-toolbar::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent-gradient);
  border-radius: var(--radius) 0 0 var(--radius);
}
.design-group {
  display: flex; align-items: center; gap: 8px;
}
.design-label {
  font-family: var(--font-ui); font-size: 10px; font-weight: 700;
  color: var(--text-primary); letter-spacing: .08em;
  text-transform: uppercase; white-space: nowrap;
}
.design-divider {
  width: 1px; height: 20px;
  background: var(--border-mid); flex-shrink: 0;
}

/* ── Theme Switcher ─────────────────────────────────────── */
.theme-switcher {
  display: flex; align-items: center; gap: 2px;
}
.theme-btn {
  height: 24px; padding: 0 8px;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-ui); font-size: 10px; font-weight: 700;
  cursor: pointer; transition: all 0.15s;
  letter-spacing: .06em;
  white-space: nowrap;
}
.theme-btn:hover {
  border-color: transparent;
  background: linear-gradient(var(--bg-hover), var(--bg-hover)) padding-box,
              var(--accent-gradient) border-box;
  color: var(--text-primary);
}
.theme-btn.active { background: var(--accent-gradient); border-color: transparent; color: #fff; }

/* ── BG Color Switcher ──────────────────────────────────── */
.bg-switcher {
  display: flex; align-items: center; gap: 5px;
}
.bg-btn {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-hi);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  padding: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15);
}
.bg-btn:hover { border-color: var(--accent); transform: scale(1.15); }
.bg-btn.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), inset 0 0 0 1px rgba(0,0,0,0.15); }

/* ── Modals ────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-backdrop.hidden { display: none; }

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  width: min(560px, 92vw);
  max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: 0 16px 48px rgba(0,0,0,0.8);
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-family: var(--font-ui); font-size: 15px; font-weight: 600;
  letter-spacing: -0.01em;
}
.modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  border-radius: var(--radius);
  font-size: 18px; line-height: 1;
  cursor: pointer;
  transition: color 0.1s, background 0.1s;
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }

.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* Music search results */
.music-results {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-top: 12px;
}
.music-result-item {
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.12s;
  background: var(--bg-surface);
}
.music-result-item:hover { border-color: var(--accent); }
.music-result-item.selected { border-color: var(--accent); background: var(--accent-dim); }
.music-result-img { aspect-ratio: 1; width: 100%; object-fit: cover; }
.music-result-info { padding: 6px 8px; }
.music-result-title { font-family: var(--font-ui); font-size: 11px; font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.music-result-artist { font-size: 10px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.music-apple-link { font-size: 9px; color: var(--text-muted); text-decoration: none; display: inline-block; margin-top: 3px; margin-right: 6px; }
.music-apple-link:hover { color: var(--accent); }
.music-amazon-link { font-size: 9px; color: #FF9900; text-decoration: none; display: inline-block; margin-top: 3px; }
.music-amazon-link:hover { color: #e68a00; text-decoration: underline; }

/* Amazon badge on tier/tray items */
.tier-item { position: relative; }
.amazon-badge {
  display: none;
  position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  background: #FF9900; color: #fff;
  font-size: 8px; font-weight: 700; font-family: var(--font-ui);
  padding: 1px 4px; border-radius: 3px;
  text-decoration: none; white-space: nowrap;
  z-index: 10; pointer-events: auto;
}
.tier-item:hover .amazon-badge { display: block; }

/* ── Share Dropdown ─────────────────────────────────────── */
.share-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  min-width: 160px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  z-index: 200;
}
.share-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  font-family: var(--font-ui); font-size: 13px; color: var(--text-primary);
  cursor: pointer;
  transition: background 0.1s;
}
.share-menu-item:hover { background: var(--bg-hover); }
.share-menu-divider { height: 1px; background: var(--border); }
.share-menu.hidden { display: none; }

/* Tier color picker */
.color-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px;
  margin-top: 8px;
}
.color-swatch {
  aspect-ratio: 1; border-radius: var(--radius);
  cursor: pointer; border: 2px solid transparent;
  transition: transform 0.1s, border-color 0.1s;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { border-color: #fff; }

/* RGB color picker */
.color-picker-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.tier-color-picker-input {
  width: 40px; height: 40px;
  padding: 3px; border: 1px solid var(--border-mid);
  border-radius: var(--radius); background: transparent;
  cursor: pointer; appearance: none; -webkit-appearance: none;
  flex-shrink: 0;
}
.tier-color-picker-input::-webkit-color-swatch-wrapper { padding: 0; }
.tier-color-picker-input::-webkit-color-swatch { border: none; border-radius: 1px; }
.color-picker-label {
  font-size: 11px; color: var(--text-secondary);
  font-family: var(--font-ui);
}

/* ── Toast Notifications ───────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 500;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  font-family: var(--font-ui); font-size: 13px; color: var(--text-primary);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  animation: slideIn 0.2s ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--accent); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Sortable ghost ────────────────────────────────────────── */
.sortable-ghost { opacity: 0.3; }
.sortable-chosen { cursor: grabbing; }

/* ── Affiliate disclosure banner ───────────────────────────── */
.affiliate-banner {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 6px 24px;
  font-size: 11px; color: var(--text-secondary);
  text-align: center;
}

/* ── Tooltip ───────────────────────────────────────────────── */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--bg-elevated); border: 1px solid var(--border-mid);
  color: var(--text-primary); font-size: 11px; font-family: var(--font-ui);
  padding: 4px 8px; border-radius: var(--radius);
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity 0.15s;
  z-index: 50;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ── Export preview overlay ────────────────────────────────── */
.export-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 400;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  gap: 20px;
}
.export-overlay.hidden { display: none; }
.export-preview-img {
  max-width: 90vw; max-height: 70vh;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
}
.export-actions { display: flex; gap: 10px; }

/* ── Admin styles ──────────────────────────────────────────── */
.admin-layout {
  display: flex;
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
}

.admin-sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  padding: 20px 0;
}

.admin-nav-section {
  padding: 0 12px 12px;
  margin-bottom: 4px;
}
.admin-nav-label {
  font-family: var(--font-ui); font-size: 10px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 8px 6px;
}
.admin-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  font-family: var(--font-ui); font-size: 13px; color: var(--text-secondary);
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
  transition: color 0.1s, background 0.1s;
}
.admin-nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.admin-nav-item.active { background: var(--accent-dim); color: var(--accent); }

.admin-content {
  flex: 1; padding: 28px; overflow-y: auto;
}

.admin-page { display: none; }
.admin-page.active { display: block; }

.admin-h1 {
  font-family: var(--font-ui); font-size: 22px; font-weight: 700;
  letter-spacing: -0.02em; margin-bottom: 24px;
}
.admin-h2 {
  font-family: var(--font-ui); font-size: 15px; font-weight: 600;
  letter-spacing: -0.01em; margin-bottom: 14px;
}

.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-value {
  font-family: var(--font-ui); font-size: 28px; font-weight: 700;
  letter-spacing: -0.03em; color: var(--text-primary);
}
.stat-label {
  font-size: 12px; color: var(--text-secondary);
  margin-top: 4px;
}

.data-table {
  width: 100%; border-collapse: collapse;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.data-table th {
  font-family: var(--font-ui); font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-secondary);
  padding: 10px 14px; text-align: left;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 14px;
  font-size: 13px; color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }

.badge {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 7px;
  border-radius: var(--radius);
  font-family: var(--font-ui); font-size: 10px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.badge-pending  { background: rgba(255,200,0,0.15); color: #FFD000; }
.badge-resolved { background: rgba(0,204,102,0.15); color: var(--success); }
.badge-dismissed{ background: var(--bg-hover); color: var(--text-secondary); }
.badge-banned   { background: var(--danger-dim); color: var(--danger); }

/* 管理画面フィルターボタン アクティブ状態 */
.filter-btn.active {
  border-color: transparent;
  background: linear-gradient(var(--bg-hover), var(--bg-hover)) padding-box,
              var(--accent-gradient) border-box;
  color: var(--text-primary);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --tray-w: 200px; --ad-w: 0px; }
  .ad-panel { display: none; }
}
@media (max-width: 640px) {
  :root { --tray-w: 100%; }

  .header-logo { width: auto; padding: 0 12px; }
  .header-actions { padding-right: 8px; gap: 4px; }
  .btn { font-size: 12px; padding: 0 10px; height: 30px; }
  .btn-icon { width: 30px; }

  .app-layout {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - var(--header-h));
  }

  .tray-panel {
    width: 100%;
    flex-direction: column;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow: visible;
    flex-shrink: 0;
  }

  .tray-items {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    height: 88px;
    padding: 8px;
    gap: 6px;
  }

  .tray-item, .tray-item-text {
    width: 70px !important;
    height: 70px !important;
    flex-shrink: 0;
    aspect-ratio: unset;
  }

  .tray-empty {
    min-width: 160px;
  }

  .slots-section { display: none; }

  .board-panel {
    flex: 1;
    width: 100%;
    overflow-y: auto;
  }

  .board-inner { padding: 12px; }

  .tier-label {
    width: 48px;
    min-width: 48px;
    font-size: 18px;
  }

  .design-toolbar { flex-wrap: wrap; gap: 8px; }

  .ad-panel { display: none; }
}

/* ── Legal pages ───────────────────────────────────────────── */
.legal-page {
  max-width: 720px; margin: calc(var(--header-h) + 40px) auto 60px;
  padding: 0 24px;
}
.legal-h1 {
  font-family: var(--font-ui); font-size: 28px; font-weight: 700;
  letter-spacing: -0.02em; margin-bottom: 8px;
}
.legal-date { font-size: 12px; color: var(--text-secondary); margin-bottom: 32px; }
.legal-h2 {
  font-family: var(--font-ui); font-size: 15px; font-weight: 600;
  letter-spacing: 0.02em; text-transform: uppercase;
  border-top: 1px solid var(--border); padding-top: 20px;
  margin: 28px 0 12px;
}
.legal-p { font-size: 13px; color: var(--text-secondary); line-height: 1.8; margin-bottom: 12px; }
.legal-ul { padding-left: 20px; margin-bottom: 12px; }
.legal-ul li { font-size: 13px; color: var(--text-secondary); line-height: 1.8; margin-bottom: 4px; }

.legal-eyebrow {
  font-family: var(--font-ui); font-size: 10px; font-weight: 700;
  letter-spacing: 0.2em;
  background: var(--accent-gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}
.legal-lead {
  color: var(--text-primary); font-size: 14px; line-height: 1.9;
  padding: 16px; margin-bottom: 8px;
  border-left: 3px solid transparent;
  background: linear-gradient(var(--bg-surface), var(--bg-surface)) padding-box,
              var(--accent-gradient) border-box;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.legal-sub {
  display: block; font-size: 11px; color: var(--text-muted);
  margin-top: 3px;
}

/* ── Legal Footer ──────────────────────────────────────────── */
.legal-footer {
  border-top: 1px solid var(--border);
  padding: 24px;
  margin-top: 60px;
}
.legal-footer-inner {
  max-width: 720px; margin: 0 auto;
  display: flex; align-items: center; gap: 24px;
  flex-wrap: wrap;
}
.legal-footer-logo {
  font-family: var(--font-ui); font-size: 18px; font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  flex-shrink: 0;
}
.legal-footer-nav {
  display: flex; gap: 16px; flex: 1;
}
.legal-footer-nav a {
  font-family: var(--font-ui); font-size: 12px;
  color: var(--text-secondary);
  transition: color 0.15s;
}
.legal-footer-nav a:hover { color: var(--text-primary); }
.legal-footer-copy {
  font-size: 11px; color: var(--text-muted);
  margin-left: auto;
}

/* ── Stema disclosure (required) ──────────────────────────── */
.stema-notice {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  font-size: 11px; color: var(--text-secondary);
}
.stema-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
}
