/* ---- 背景グラデーション ---- */
#bg-grad {
  position: fixed;
  z-index: -1;
  width: 100vw; height: 100vh;
  top: 0; left: 0;
  background: linear-gradient(120deg, #e6e6fa 0%, #e1e9ff 50%, #f9eaff 100%);
}

/* ---- 全体 ---- */
body {
  margin: 0;
  font-family: 'Inter', 'Noto Sans JP', Arial, sans-serif;
  background: transparent;
  color: #212135;
  min-height: 100vh;
  letter-spacing: 0.01em;
}
a {
  color: #7c3aed;
  text-decoration: none;
}
a:hover { text-decoration: underline; }
button, input, select {
  font-family: inherit;
  font-size: 1em;
  outline: none;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
input[type="number"] { -moz-appearance: textfield; }

/* ---- ヘッダー ---- */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f4f0ffcc;
  box-shadow: 0 1px 8px #cab6f050;
  padding: 0.4em 1.5em 0.4em 1.1em;
  position: sticky;
  top: 0; left: 0; z-index: 4;
  min-height: 54px;
}
.header-left { display: flex; align-items: center; gap: 0.7em; }
.logo {
  font-size: 1.7em;
  background: linear-gradient(95deg, #b993f8 40%, #47d4ff 100%);
  border-radius: 10px;
  padding: 0.07em 0.27em;
}
header h1 {
  font-size: 1.22em;
  font-weight: 700;
  letter-spacing: 0.03em;
  margin: 0;
  color: #6538b9;
}
.header-right {
  display: flex; gap: 0.7em; align-items: center;
}
.ghost-btn {
  background: #f9eaff;
  color: #7c3aed;
  border: 1px solid #d5caf7;
  border-radius: 0.7em;
  font-weight: 700;
  font-size: 1.05em;
  cursor: pointer;
  padding: 0.4em 1.12em;
  transition: background 0.14s;
}
.ghost-btn:hover { background: #ebdfff; }
#webstore-btn {
  border: none; background: #38b6ff22; color: #1986be;
  padding: 0.41em 1.25em;
  border-radius: 0.7em;
  font-weight: 700;
  margin-left: 0.2em;
  transition: background 0.16s;
}
#webstore-btn:hover { background: #38b6ff50; color: #0f597c; }

/* ---- レイアウト ---- */
#main-container {
  display: flex;
  height: calc(100vh - 82px - 44px);
  max-width: 1100px;
  margin: 1.5em auto 0 auto;
  box-shadow: 0 4px 24px #b993f810;
  border-radius: 1.3em;
  background: #fff7ffb2;
  min-height: 560px;
  overflow: hidden;
}
#sidebar {
  min-width: 230px; max-width: 330px;
  background: #ede4fa42;
  border-right: 1px solid #e1dbfb;
  padding: 1.2em 0.2em 1.4em 0.6em;
  display: flex;
  flex-direction: column;
  gap: 0.6em;
  overflow-y: auto;
}
.sidebar-header {
  font-weight: 700; font-size: 1.14em; margin-bottom: 0.8em; color: #6538b9;
  letter-spacing: 0.05em;
}
#box-list { display: flex; flex-direction: column; gap: 0.4em; }

/* ---- サイドバーBOXリスト ---- */
.box-card {
  background: #f7f4ff;
  border-radius: 0.8em;
  padding: 0.45em 0.8em 0.45em 1.0em;
  display: flex; align-items: center;
  justify-content: space-between;
  gap: 0.4em;
  border: 1.3px solid #e2d5fb;
  box-shadow: 0 1px 6px #dec7f825;
  transition: box-shadow 0.13s, border 0.14s, background 0.13s;
  cursor: pointer;
  min-height: 44px;
}
.box-card.selected, .box-card:hover {
  border: 1.5px solid #bb91f8;
  box-shadow: 0 2px 9px #d8bbfb23;
  background: #ece6ff;
}
.box-title {
  font-weight: 700;
  color: #613bd7;
  font-size: 1.06em;
  margin-right: 0.7em;
  outline: none;
}
.box-title:focus {
  border-bottom: 2px solid #7c3aed;
  background: #e6dfff;
}
.box-btns {
  display: flex; gap: 0.6em;
}
.box-btn {
  font-size: 0.97em;
  border: none;
  background: #f9eaff;
  color: #7c3aed;
  border-radius: 0.7em;
  cursor: pointer;
  font-weight: 700;
  padding: 0.18em 0.9em;
  transition: background 0.14s;
}
.box-btn.edit { background: #edf5fe; color: #2698dd; }
.box-btn.edit:hover { background: #d7eafd; }
.box-btn.delete { background: #fff3f4; color: #ff3a63; }
.box-btn.delete:hover { background: #ffdde8; }

/* ---- メイン ---- */
#content-area {
  flex: 1;
  padding: 2.2em 2.3em 1.4em 2.3em;
  overflow-y: auto;
}
.card {
  border-radius: 1.1em;
  background: #fff6ffde;
  box-shadow: 0 1px 6px #ceb9f622;
  padding: 2.2em 1.5em 1.4em 1.5em;
}

/* ---- モーダル ---- */
#modal-backdrop {
  display: none;
  position: fixed; z-index: 10;
  left: 0; top: 0; width: 100vw; height: 100vh;
  background: #6457e840;
}
#modal-backdrop.active { display: block; animation: fadeInBg 0.2s; }
@keyframes fadeInBg { from { opacity:0; } to { opacity:1; } }
#modal-window {
  display: none;
  position: fixed; z-index: 20;
  left: 50%; top: 55%;
  transform: translate(-50%,-50%) scale(0.96);
  min-width: 320px; max-width: 92vw;
  background: #fff;
  border-radius: 1.3em;
  box-shadow: 0 8px 40px #ac8bee39;
  padding: 0;
  opacity: 0;
  transition: opacity 0.13s, transform 0.16s;
}
#modal-window.active {
  display: block;
  opacity: 1;
  transform: translate(-50%,-50%) scale(1);
  animation: fadeInWin 0.23s;
}
@keyframes fadeInWin { from{opacity:0;transform:translate(-50%,-48%) scale(0.95);} to{opacity:1;transform:translate(-50%,-50%) scale(1);} }
.modal-card {
  padding: 2.0em 1.7em 1.3em 1.7em;
  min-width: 312px;
}
.modal-card h2 { font-size: 1.2em; color: #6836b5; margin-bottom: 1.0em; }
.form-row { margin-bottom: 1.0em; display: flex; align-items: center; gap: 0.75em; }
.form-row label { flex: 1 0 110px; font-weight: 600; color: #4b2397; }
.form-row input, .form-row select {
  border: 1px solid #ccc1e6;
  border-radius: 0.5em;
  padding: 0.32em 0.9em;
  background: #f9f6ff;
  font-size: 1.04em;
  margin-right: 0.3em;
}
.form-row input:focus, .form-row select:focus {
  border-color: #ab8cf2;
  background: #f0ebff;
}
.form-row button {
  background: #eae8f7; color: #673adf;
  border: 1px solid #cfc2ee;
  border-radius: 0.7em;
  padding: 0.25em 0.97em;
  cursor: pointer; font-weight: 700;
  font-size: 0.97em;
  margin-left: 0.6em;
}
.form-row button:hover { background: #e4deff; }
#add-item-btn { font-size: 0.93em; margin-left: 1em; }
.item-list-row { flex-direction: column; align-items: flex-start; }
#item-list { width: 100%; margin: 0.3em 0 0.2em 0; display: flex; flex-direction: column; gap: 0.39em; }
.item-entry {
  display: flex; align-items: center; gap: 0.43em; width: 100%;
}
.item-entry input { font-size: 0.99em; }
.item-remove-btn {
  color: #ff4671; background: #fff1f3;
  font-size: 1.19em; padding: 0.06em 0.51em;
  border-radius: 0.8em;
  border: 1px solid #ffb5d2;
  margin-left: 0.4em;
}
.item-remove-btn:hover { background: #ffe2ec; }
.item-img-preview {
  width: 32px; height: 32px; margin: 0 0.3em;
  border-radius: 0.5em; background: #eee;
  object-fit: contain;
  box-shadow: 0 1px 6px #eac0fa18;
}

/* ---- モーダル詳細アイテム ---- */
.items-grid {
  display: flex; flex-wrap: wrap; gap: 0.68em; margin-top: 0.2em;
}
.item-detail-card {
  display: flex; align-items: center; gap: 0.39em;
  border: 1px solid #e2d2fa;
  border-radius: 0.7em;
  background: #f9f6ff;
  padding: 0.24em 0.9em 0.22em 0.35em;
  min-width: 120px;
}
.item-detail-card img {
  width: 32px; height: 32px; border-radius: 0.4em; object-fit: contain;
  background: #e6e6fa;
}
.item-detail-meta { display: flex; flex-direction: column; }
.item-detail-name { font-weight: 700; color: #5d27b6; }
.item-detail-count { color: #333; font-size: 1.06em; }

/* ---- FAB ---- */
#fab-add {
  position: fixed;
  right: 3vw; bottom: 54px;
  z-index: 14;
  background: linear-gradient(110deg, #8e59e6 60%, #46cefe 100%);
  color: #fff;
  border: none;
  border-radius: 50%;
  box-shadow: 0 4px 18px #8e59e62b;
  width: 60px; height: 60px;
  font-size: 2.1em; font-weight: 900;
  cursor: pointer;
  transition: box-shadow 0.14s, background 0.14s, transform 0.12s;
  outline: none;
}
#fab-add:hover { background: linear-gradient(110deg, #a788f7 20%, #28baff 100%); box-shadow: 0 8px 30px #7d5cf86e; transform: scale(1.06);}
#fab-add:active { background: #36b2ec; }

/* ---- 通知 ---- */
#notify {
  position: fixed;
  bottom: 18px; left: 50%; transform: translateX(-50%);
  min-width: 120px;
  padding: 0.7em 2.2em;
  background: #7c3aed;
  color: #fff;
  border-radius: 1.5em;
  font-weight: 700;
  font-size: 1.08em;
  box-shadow: 0 2px 18px #a988e03c;
  opacity: 0; pointer-events: none;
  z-index: 111;
  transition: opacity 0.23s;
}
#notify.show { opacity: 1; }

/* ---- フッター ---- */
footer {
  width: 100vw;
  min-height: 42px;
  background: #ece6ffb6;
  color: #8a64be;
  font-weight: 700;
  text-align: center;
  font-size: 1.08em;
  padding: 0.5em 0 0.7em 0;
  box-shadow: 0 -1px 8px #b893f81e;
  letter-spacing: 0.02em;
  position: fixed; left: 0; bottom: 0; z-index: 5;
}
footer a { color: #5f19a6; }
footer a:hover { color: #1783ea; text-decoration: underline; }

/* ---- JSON出力/読込ボタン ---- */
.json-btns {
  display: flex;
  gap: 1.1em;
  justify-content: center;
  margin: 1.7em 0 0 0;
}
.json-btns .ghost-btn {
  font-size: 1.08em;
  background: #f9eaff;
  color: #7c3aed;
  border: 1px solid #d5caf7;
  padding: 0.42em 1.2em;
}
@media (max-width:700px) {
  .json-btns {
    flex-direction: column;
    gap: 0.7em;
    margin: 1.2em 0 0 0;
  }
}

/* ---- ポップアップモーダル ---- */
.pop-modal {
  display: none;
  position: fixed;
  left:0; top:0; width:100vw; height:100vh;
  background: #483ca340;
  z-index: 101;
}
.pop-modal.active { display: block; animation: fadeInBg 0.2s; }
.pop-modal-content {
  position: absolute; left:50%; top:50%; transform:translate(-50%,-50%);
  background: #fff;
  border-radius: 1.1em;
  min-width: 270px; max-width: 93vw;
  padding: 1.7em 1.6em 1.3em 1.6em;
  box-shadow: 0 8px 36px #a47deb3e;
}
.pop-modal-close {
  font-size: 1.25em;
  color: #7c3aed;
  position: absolute;
  right: 1.1em; top: 1.0em;
  cursor: pointer;
}

/* ---- スマホレスポンシブ ---- */
@media (max-width: 900px) {
  #main-container {
    max-width: 98vw; min-width: 0;
    border-radius: 0.7em;
    margin: 0.8em auto 0 auto;
    min-height: 520px;
  }
  #content-area {
    padding: 1.1em 1.1em 1.4em 1.1em;
  }
  .modal-card { padding: 1.2em 0.7em 1.1em 0.7em; min-width: 0;}
}
@media (max-width: 700px) {
  #main-container {
    flex-direction: column;
    min-height: 360px;
    border-radius: 0;
    height: auto;
    margin: 0.3em auto 0 auto;
  }
  #sidebar {
    min-width: 0; max-width: none; width: 100vw;
    flex-direction: row;
    overflow-x: auto; overflow-y: visible;
    border-radius: 0; border-right: none;
    border-bottom: 1.5px solid #e1dbfb;
    padding: 0.8em 0.2em 0.8em 0.6em;
    gap: 0.7em;
  }
  .sidebar-header {
    font-size: 1.05em; margin-bottom: 0; margin-right: 0.9em;
  }
  #box-list { flex-direction: row; gap: 0.5em; }
  .box-card { min-width: 122px; font-size: 0.98em; padding: 0.3em 0.5em 0.3em 0.7em;}
  #content-area { padding: 1.2em 0.4em 1.2em 0.6em; }
  .modal-card { padding: 1.0em 0.2em 1.1em 0.2em; }
  .items-grid { gap: 0.47em;}
}
@media (max-width: 430px) {
  .modal-card { padding: 0.5em 0.05em 0.8em 0.05em; }
  .pop-modal-content { padding: 0.7em 0.3em 0.8em 0.3em; }
}

/* ---- スクロールバー消し・微調整 ---- */
::-webkit-scrollbar { width: 7px; background: #ede4fa10; }
::-webkit-scrollbar-thumb { background: #e9e1ff60; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #b993f870; }