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

:root {
  --bg: var(--ui-bg);
  --surface: var(--ui-surface);
  --surface2: var(--ui-surface-3);
  --border: var(--ui-border);
  --text: var(--ui-text);
  --muted: var(--ui-muted);
  --rad: var(--ui-radius-sm);
  --item-size: 80px;
}

body {
  font-family: var(--ui-font);
  background: var(--bg);
  color: var(--text);
  min-height: calc(100vh - var(--ui-bar-h, 0px));
  display: flex;
  flex-direction: column;
  user-select: none;
}

/* HEADER */
.app-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: .75rem 1.2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.header-brand { display: flex; align-items: center; gap: .5rem; font-size: 1.15rem; font-weight: 800; color: var(--ui-accent); }
.header-sub { font-size: .78rem; color: var(--muted); flex: 1; }
.header-actions { display: flex; gap: .5rem; margin-left: auto; }
.hdr-btn {
  padding: 5px 14px; border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface2); color: var(--text);
  font-size: .78rem; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: .35rem;
  transition: all .15s;
}
.hdr-btn:hover { border-color: var(--ui-accent); color: var(--ui-accent); }
.hdr-btn-primary { background: var(--ui-accent); border-color: var(--ui-accent); color: #fff; }
.hdr-btn-primary:hover { opacity: .85; color: #000; }

/* BODY */
.app-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: .8rem 1rem;
  gap: .8rem;
}

/* TIER ROW */
.tier-list-area {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--rad);
  overflow: hidden;
}
.tier-row {
  display: flex;
  align-items: stretch;
  min-height: calc(var(--item-size) + 8px);
  border-bottom: 1px solid var(--border);
}
.tier-row:last-child { border-bottom: none; }
.tier-label {
  width: 80px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: -.02em;
  cursor: default;
}
.tier-items {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 4px;
  padding: 4px 6px;
  min-height: calc(var(--item-size) + 8px);
  border-left: 1px solid var(--border);
  transition: background .15s;
}
.tier-items.drag-over { background: rgba(255,255,255,.04); outline: 2px dashed rgba(255,255,255,.18); outline-offset: -2px; }

/* ITEMS */
.tier-item {
  width: var(--item-size);
  height: var(--item-size);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: .7rem;
  font-weight: 700;
  cursor: grab;
  background: var(--surface2);
  border: 2px solid var(--border);
  overflow: hidden;
  position: relative;
  transition: transform .12s, box-shadow .12s;
  flex-shrink: 0;
}
.tier-item:hover { transform: scale(1.06); box-shadow: 0 4px 12px rgba(0,0,0,.4); z-index: 2; }
.tier-item.dragging { opacity: .4; cursor: grabbing; }
.tier-item img { width: 100%; height: 100%; object-fit: cover; }
.tier-item-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,.65);
  padding: 2px 3px;
  font-size: .6rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
}
.tier-item-label.only-text { position: static; background: none; font-size: .7rem; padding: 4px; color: var(--text); }
.item-ctx-menu {
  position: fixed; z-index: 9999;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 0;
  min-width: 140px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.ctx-item {
  padding: 7px 14px;
  font-size: .78rem;
  cursor: pointer;
  display: flex; align-items: center; gap: .5rem;
  transition: background .1s;
}
.ctx-item:hover { background: var(--surface); }
.ctx-item.danger { color: #ef4444; }

/* ITEM POOL */
.item-pool-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--rad);
  padding: .75rem;
}
.pool-header {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  margin-bottom: .6rem;
}
.pool-title { font-size: .8rem; font-weight: 700; color: var(--muted); display: flex; align-items: center; gap: .4rem; flex: 1; }
.pool-actions { display: flex; gap: .4rem; }
.new-item-input {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 7px;
  padding: 5px 10px; font-size: .8rem;
  width: 200px;
}
.new-item-input:focus { border-color: var(--ui-accent); outline: none; }
.pool-btn {
  width: 32px; height: 32px; border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface2); color: var(--text);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: .82rem; transition: all .15s;
}
.pool-btn:hover { border-color: var(--ui-accent); color: var(--ui-accent); }
.item-pool {
  display: flex; flex-wrap: wrap; gap: 5px;
  min-height: 60px;
  padding: 4px 0;
}
.item-pool.drag-over { background: rgba(255,255,255,.03); border-radius: 6px; outline: 2px dashed rgba(255,255,255,.15); outline-offset: -2px; }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.4rem 1.6rem;
  width: min(340px, 90vw);
  display: flex; flex-direction: column; gap: .8rem;
}
.modal-box h3 { font-size: .95rem; font-weight: 700; }
.rename-input {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 7px;
  padding: 6px 10px; font-size: .9rem; width: 100%;
}
.rename-input:focus { border-color: var(--ui-accent); outline: none; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.modal-btn {
  padding: 6px 18px; border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface2); color: var(--text);
  font-size: .82rem; font-weight: 700; cursor: pointer; transition: all .15s;
}
.modal-btn:hover { border-color: var(--ui-accent); }
.modal-btn-primary { background: var(--ui-accent); border-color: var(--ui-accent); color: #fff; }
.modal-btn-primary:hover { opacity: .85; }

