/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Tokens ── */
:root {
  --page-bg:     #eef0f6;
  --panel-bg:    #ffffff;
  --panel-bg2:   #f5f7fc;
  --border:      #d4d9e8;
  --border-dim:  #e8eaf4;
  --title-bg:    #f0f3fa;
  --accent:      #4a6ee8;
  --accent-hover:#3a5ed8;
  --accent-light:#eef1ff;
  --text:        #1c2438;
  --text-2:      #3a4560;
  --text-dim:    #8090b0;
  --enhanced:    #1a8a40;
  --success:     #1a8a40;
  --fail:        #8090a8;
  --destroy:     #d02020;
  --slot-on:     #4a6ee8;
  --slot-off:    #d4d9e8;
}

/* ── Base ── */
body {
  background: var(--page-bg);
  font-family: '맑은 고딕','Malgun Gothic','굴림체','굴림',sans-serif;
  color: var(--text);
  min-height: 100vh;
}

/* ── Site notice bar ── */
.site-notice {
  background: var(--accent-light);
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  font-size: 13px;
  text-align: center;
  padding: 8px 24px;
  white-space: pre-wrap;
}

/* ── Header ── */
.page-header {
  background: #1a2234;
  border-bottom: 3px solid var(--accent);
  padding: 16px 24px;
  margin-bottom: 20px;
}
.header-inner { text-align: center; }
.header-title {
  font-size: 22px;
  font-weight: bold;
  color: #ffffff;
  letter-spacing: 5px;
}
.header-sub {
  font-size: 11px;
  color: #6878a0;
  letter-spacing: 6px;
  margin-top: 4px;
}

/* ── Grid ── */
.simulator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 0 20px 28px;
  align-items: start;
  max-width: 900px;
  margin: 0 auto;
}

.panel-result { grid-column: 1 / -1; }

.result-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.result-left  { display: flex; flex-direction: column; gap: 12px; }
.result-right { display: flex; flex-direction: column; }

@media (max-width: 640px) {
  .simulator-grid { grid-template-columns: 1fr; padding: 0 12px 20px; }
  .result-inner   { grid-template-columns: 1fr; }
}

/* ── Panel ── */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,.07);
  overflow: hidden;
}
.panel-title {
  background: var(--title-bg);
  color: var(--text);
  text-align: center;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 3px;
  border-bottom: 1px solid var(--border);
}
.panel-body { padding: 14px; }

/* ── Cat tabs ── */
.cat-tabs { display: flex; gap: 5px; margin-bottom: 10px; }
.cat-btn {
  flex: 1;
  background: var(--panel-bg2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 0;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  border-radius: 20px;
  transition: all .15s;
}
.cat-btn:hover  { border-color: var(--accent); color: var(--accent); }
.cat-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Search ── */
.search-wrap { position: relative; margin-bottom: 8px; }
#item-search {
  width: 100%;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 32px 8px 11px;
  font-family: inherit;
  font-size: 12px;
  outline: none;
  border-radius: 6px;
  transition: border-color .15s;
}
#item-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(74,110,232,.1); }
#item-search::placeholder { color: var(--text-dim); }
.search-clear-btn {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  color: var(--text-dim); cursor: pointer;
  font-size: 14px; padding: 2px 4px; line-height: 1;
}
.search-clear-btn:hover { color: var(--text); }

/* ── Item grid list ── */
.item-list-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  max-height: 360px;
  overflow-y: auto;
  padding: 2px 1px;
}
.item-grid-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  cursor: pointer;
  border-radius: 5px;
  border: 1px solid var(--border-dim);
  background: var(--panel-bg2);
  transition: all .12s;
}
.item-grid-cell:hover { background: var(--accent-light); border-color: var(--accent); }
.item-grid-cell img { width: 40px; height: 40px; object-fit: contain; image-rendering: pixelated; display: block; }
.item-grid-loading {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 20px;
}

/* ── Legacy item-card ── */
.item-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-bg2); border: 1px solid var(--border);
  padding: 8px; margin-bottom: 10px; border-radius: 6px;
}
.item-icon-box {
  width: 50px; height: 50px;
  background: var(--panel-bg2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; position: relative; overflow: hidden; border-radius: 4px;
}
.item-icon-box img { max-width: 42px; max-height: 42px; image-rendering: pixelated; }
.destroy-overlay {
  position: absolute; inset: 0;
  background: rgba(200,30,30,.72);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: #fff; font-weight: bold;
}
.item-name { font-size: 12px; font-weight: bold; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.item-cat  { font-size: 10px; color: var(--text-dim); margin-top: 2px; }
.item-card.destroyed .item-name { color: var(--destroy); text-decoration: line-through; }

/* ── Stat box ── */
.stat-box { background: var(--panel-bg2); border: 1px solid var(--border); padding: 8px 10px; margin-bottom: 10px; min-height: 50px; border-radius: 6px; }
.srow { display: flex; justify-content: space-between; font-size: 11px; padding: 1.5px 0; }
.srow-lbl { color: var(--text-dim); }
.srow-val { color: var(--accent); }
.srow-val.plus { color: var(--enhanced); }
.srow-bonus { color: var(--enhanced); font-size: 10px; }

/* ── Slots ── */
.slot-section { margin-bottom: 10px; }
.slot-label { font-size: 10px; color: var(--text-dim); margin-bottom: 4px; }
.slot-count { color: var(--text); }
.slot-dots { display: flex; flex-wrap: wrap; gap: 3px; }
.sdot { width: 14px; height: 14px; border-radius: 50%; }
.sdot.on {
  background: radial-gradient(circle at 35% 35%, #80aaff, #2858d8);
  box-shadow: 0 0 4px rgba(74,110,232,.5);
}
.sdot.off { background: var(--slot-off); border: 1px solid var(--border); }

/* ── Rate filters ── */
.rate-filters { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.rate-btn {
  background: var(--panel-bg2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 11px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  border-radius: 20px;
  transition: all .15s;
}
.rate-btn:hover  { border-color: var(--accent); color: var(--accent); }
.rate-btn.active { color: #fff; border-color: transparent; }
.rate-btn.active[data-rate="all"] { background: var(--accent); }
.rate-btn.active.c100 { background: #3a56c0; }
.rate-btn.active.c60  { background: #2068b0; }
.rate-btn.active.c30  { background: #b07820; }
.rate-btn.active.c10  { background: #c04820; }

/* ── Scroll list ── */
.scroll-list {
  max-height: 270px;
  overflow-y: auto;
  background: var(--panel-bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 12px;
}
.scroll-list::-webkit-scrollbar { width: 5px; }
.scroll-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sentry {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; cursor: pointer;
  border-bottom: 1px solid var(--border-dim);
  font-size: 11px; transition: background .1s;
}
.sentry:hover { background: var(--accent-light); }
.sentry.selected { background: var(--accent-light); border-left: 3px solid var(--accent); }

.sentry-img {
  width: 30px; height: 30px; object-fit: contain; image-rendering: pixelated;
  background: var(--panel-bg); border: 1px solid var(--border);
  border-radius: 4px; flex-shrink: 0;
}
.sentry-ph {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  background: var(--panel-bg2); border: 1px solid var(--border);
  font-size: 9px; font-weight: bold; flex-shrink: 0; border-radius: 4px;
}
.sentry-name { flex: 1; color: var(--text); line-height: 1.3; }
.sentry-rate { font-size: 12px; font-weight: bold; flex-shrink: 0; }
.r100 { color: #3a56c0; }
.r60  { color: #2068b0; }
.r30  { color: #b07820; }
.r10  { color: #c04820; }
.r1   { color: #c02020; }

/* ── Buttons ── */
.btn {
  width: 100%;
  background: var(--panel-bg2);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 7px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  margin-top: 6px;
  border-radius: 6px;
  transition: all .15s;
}
.btn:hover:not(:disabled) { background: var(--border); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-sm { padding: 5px; font-size: 11px; color: var(--text-dim); }

.btn-enhance {
  width: 100%;
  background: var(--accent);
  border: none;
  color: #ffffff;
  padding: 13px;
  font-size: 15px;
  letter-spacing: 4px;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 8px;
  font-family: inherit;
  transition: all .15s;
}
.btn-enhance:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(74,110,232,.4);
}
.btn-enhance:disabled {
  background: var(--border);
  color: var(--text-dim);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn-enhance:not(:disabled) {
  animation: glow 2.2s ease-in-out infinite;
}
@keyframes glow {
  0%,100% { box-shadow: 0 2px 8px rgba(74,110,232,.2); }
  50%      { box-shadow: 0 4px 20px rgba(74,110,232,.5); }
}

/* ── Result box ── */
.result-box {
  min-height: 110px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--panel-bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}
.result-icon { font-size: 36px; margin-bottom: 6px; line-height: 1; }
.result-text { font-size: 20px; font-weight: bold; letter-spacing: 3px; margin-bottom: 5px; color: var(--text); }
.result-text.s { color: var(--success); }
.result-text.f { color: var(--fail); }
.result-text.d { color: var(--destroy); }
.result-sub { font-size: 12px; color: var(--text-dim); }

/* ── Bonus box ── */
.bonus-box {
  background: #f0faf4;
  border: 1px solid #b8e0c8;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11px;
}
.bonus-title { color: #508060; font-size: 10px; margin-bottom: 4px; }
.bonus-line { color: var(--enhanced); font-weight: bold; }

/* ── Log ── */
.log-header {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px; margin-bottom: 8px;
}
.btn-tiny {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 2px 7px;
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
  border-radius: 3px;
  transition: all .15s;
}
.btn-tiny:hover { border-color: var(--accent); color: var(--accent); }
.log-list { max-height: 260px; overflow-y: auto; font-size: 11px; flex: 1; }
.log-list::-webkit-scrollbar { width: 4px; }
.log-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.lentry {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 5px;
  border-bottom: 1px solid var(--border-dim);
  color: var(--text-2);
}
.lentry.s { color: var(--enhanced); }
.lentry.f { color: var(--text-dim); }
.lentry.d { color: var(--destroy); }
.lnum { color: var(--border); font-size: 10px; min-width: 20px; }

/* ── Flash ── */
.flash {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 999; opacity: 0;
}
.flash.fs { animation: aflash .4s ease-out; background: rgba(74,110,232,.1); }
.flash.ff { animation: aflash .3s ease-out; background: rgba(0,0,0,.06); }
.flash.fd { animation: fdflash .6s ease-out; background: rgba(200,30,30,.1); }
@keyframes aflash  { 0% { opacity:1; } 100% { opacity:0; } }
@keyframes fdflash { 0%{opacity:0;} 20%{opacity:1;} 100%{opacity:0;} }

/* ── Scrollbar global ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--panel-bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ─────────────────────────────────────────────
   MapleStory Item Tooltip  (light / authentic)
───────────────────────────────────────────── */
.maple-tooltip {
  background: #d8dce8;
  border: 2px solid #6878a8;
  border-radius: 0;
  margin-bottom: 12px;
  position: relative;
  font-family: '돋움체','DotumChe','굴림체',monospace;
  min-width: 210px;
}
.maple-tooltip::before { display: none; }
.maple-tooltip.destroyed { border-color: #a03030; }

/* ── 아이템 이름 ── */
.tt-name-row {
  background: #d8dce8;
  border-bottom: 1px solid #8890b8;
  padding: 5px 10px 6px;
  font-size: 14px;
  font-weight: bold;
  text-align: center;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: none;
  word-break: break-all;
  letter-spacing: 0;
}

/* ── 구분선 ── */
.tt-divider {
  height: 1px;
  background: #8890b8;
  margin: 0;
}

/* ── 아이콘 + REQ 영역 ── */
.tt-body {
  display: flex;
  align-items: flex-start;
  padding: 6px 8px;
  gap: 8px;
  min-height: 56px;
  background: #d8dce8;
}
.tt-icon-col { flex-shrink: 0; }
.tt-icon-box {
  width: 64px; height: 64px;
  background: #c0c4d4;
  border: 1px solid #8890b8;
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.tt-icon-box img { max-width: 56px; max-height: 56px; image-rendering: pixelated; }

.tt-req-col {
  flex: 1;
  font-size: 10px;
  line-height: 1.8;
  padding-top: 2px;
  font-family: '돋움체','DotumChe','굴림체',monospace;
  color: #1a1e30;
}
.tt-req-row { display: flex; justify-content: space-between; gap: 4px; }
.tt-req-lbl { color: #1a1e30; white-space: nowrap; }
.tt-req-val { color: #1a1e30; }
.tt-req-val.red { color: #cc2020; }

/* ── 스탯 영역 (좌측 정렬) ── */
.tt-stats {
  padding: 5px 8px 5px;
  font-size: 11px;
  background: #d8dce8;
  font-family: '돋움체','DotumChe','굴림체',monospace;
  text-align: left;
}
.tt-type-row {
  color: #1a1e30;
  padding: 1px 0 4px 0;
  border-bottom: 1px solid #8890b8;
  margin-bottom: 3px;
  text-align: left;
}

.tt-stat-row {
  color: #1a1e30;
  padding: 1.5px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.tt-stat-row.enhanced { color: #1040a0; }
.tt-stat-bonus { color: #1040a0; }
.stat-elevator {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex-shrink: 0;
}
.elev-btn {
  background: #b0b8d0;
  border: 1px solid #8890b8;
  color: #1a1e30;
  font-size: 7px;
  line-height: 1;
  padding: 0px 3px;
  cursor: pointer;
  border-radius: 1px;
  transition: background .1s;
}
.elev-btn:hover { background: #4a6ee8; color: #fff; border-color: #3a5ed8; }

/* ── 업그레이드 슬롯 ── */
.tt-slots {
  padding: 4px 8px 8px;
  font-size: 11px;
  background: #d8dce8;
  border-top: 1px solid #8890b8;
  font-family: '돋움체','DotumChe','굴림체',monospace;
}
.tt-slots-label {
  color: #1a1e30;
  text-align: left;
  margin-bottom: 5px;
}
.tt-slots-count { color: #1a1e30; font-weight: normal; }
.tt-slot-dots { display: flex; flex-wrap: wrap; gap: 3px; justify-content: flex-start; }

/* 슬롯 도트 */
.sdot { width: 12px; height: 12px; border-radius: 2px; }
.sdot.on {
  background: linear-gradient(135deg, #5088e0 0%, #1848b0 100%);
  box-shadow: 0 0 3px rgba(40,80,200,.5);
}
.sdot.off { background: #a8aec4; border: 1px solid #7880a8; }

/* 파괴 오버레이 */
.destroy-overlay {
  position: absolute; inset: 0;
  background: rgba(160,10,10,.75);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: #fff; font-weight: bold;
  font-family: '돋움체','DotumChe',monospace;
}
